Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix PHP Deprecated Automatically populating $HTTP_RAW_POST_DATA is deprecated issue? [duplicate]

Tags:

php

wordpress

hello i'm getting this error in my error log:

"PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0"

My wordpress version is 4.8.1 and the php version is 5.6.30.

I tried fixing the issue by creating a php ini file and setting always_populate_raw_post_data value to -1. But i still get the error.

If it cannot be fixed, how can i prevent it prints on the error log?

I'm using a shared hosting.


2 Answers

how can i prevent it prints on the error log?

Your problem here is not that you cannot access php.ini and it is not that error shows.

Your problem, in fact, is that you use deprecated variable

instead, you could try using

file_get_contents('php://input');

php.ini is located somewhere in the php files on the server, which I assume you have no access to on shared hosting.

like image 144
Cezary Avatar answered Mar 15 '26 12:03

Cezary


The php.ini file you created needs to be located where PHP expects to find its config files. You can see the configs which PHP is already loading using the phpinfo() function:

Upload a file named info.php with the following contents to your web server root:

<?php
// delete this file or comment out the below function when not in use
phpinfo();
?>

Then use a browser to navigate to http://yourwebsite.com/info.php. A page should load which tells you all about your php configuration. Look for the part near the top which shows information about the loaded configuration files. In particular, look for these entries: "Loaded Configuration File" and "Scan this dir for additional .ini files".

If you have access to the .ini file listed as the Loaded Configuration File simply modify the value for always_populate_raw_post_data there. Otherwise, upload the .ini file you already created to the directory that is scanned for additional configuration files. Of course, you'll need to reload or restart php in order to reparse the configuration files.

If you don't have access to any of the locations listed from the above steps, it's possible your hosting provider may give you access to your php.ini file through cPanel or a similar means. Otherwise, your best bet is to contact them directly.

Finally, if you don't care about the actual configuration value as much as just suppressing the warning message, you could use the ini_set() function to set your error reporting to a different value, eliminating any deprecation warnings. The variable you want to set is "error_reporting" and a list of possible values can be found here.

In addition, since you are running WordPress there are some debug and error reporting options you can set in the wp-config.php file.

like image 34
Kevin Briggs Avatar answered Mar 15 '26 13:03

Kevin Briggs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!