Opened 10 years ago
Closed 6 years ago
#31806 closed defect (bug) (invalid)
PHP Deprecated: $HTTP_RAW_POST_DATA
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1.1 |
Component: | REST API | Keywords: | |
Focuses: | Cc: |
Description
Hi,
On PHP 5.6 the error_log for WordPress is giving this error:
[29-Mar-2015 20:04:43 UTC] 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
Change History (7)
#3
follow-up:
↓ 4
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Since we don't require the presence of HTTP_RAW_POST_DATA
(We already include back-compat, and now, forward-compat for it) and the warning can't be controlled by WordPress, there doesn't appear to be anything we can do about this.
For reference, the two locations using it are:
./src/wp-includes/class-IXR.php ~line 400 ./src/xmlrpc.php ~line 20
#4
in reply to:
↑ 3
@
10 years ago
Replying to dd32:
For reference, the two locations using it are:
./src/wp-includes/class-IXR.php ~line 400 ./src/xmlrpc.php ~line 20
Just a note for posterity: This error will occur regardless of whether HTTP_RAW_POST_DATA
is actually used.
#6
@
6 years ago
- Component changed from General to REST API
- Resolution invalid deleted
- Status changed from closed to reopened
Reopening this since it's referenced in WP_REST_Server::get_raw_data() as of WP 4.4. Still seeing this error sometimes happening, which WooCommerce may have found a way around it at one point with their legacy REST API endpoints using the following code above the $HTTP_RAW_POST_DATA
usage:
<?php // $HTTP_RAW_POST_DATA is deprecated on PHP 5.6. if ( function_exists( 'phpversion' ) && version_compare( phpversion(), '5.6', '>=' ) ) { return file_get_contents( 'php://input' ); }
Should a similar fix be considered in core now that PHP 5.6+ is the requirement and this error will trigger on 5.6.x unless you are running 7.0+?
Asking because I'm seeing this crop up on certain sites which causes WP 5.x editor save failures (using default Gutenberg editor) with certain blocks that have more data to submit to the WP Posts REST API.
I've gotten this error occasionally on a site running PHP 5.6 as well.
This error actually has nothing to do with WordPress. Here is a good read on it:
Note also that:
So there is absolutely nothing that WordPress can do about this.