From c591d94cc5b43297a679df54d9a7fd55a7284972 Mon Sep 17 00:00:00 2001 From: desrosj Date: Mon, 8 Jun 2020 19:55:10 +0000 Subject: [PATCH] General: Remove or add inline comments to `$HTTP_RAW_POST_DATA` occurrences. The `$HTTP_RAW_POST_DATA` global was deprecated in PHP 5.6 and removed completely in PHP 7.0. In general, `php://input` should be used instead of `$HTTP_RAW_POST_DATA`. Because WordPress Core still supports PHP 5.6, some plugins or sites may still rely on this variable being present and populated with the expected data. For that reason, occurrences of the variable will remain with updated inline documentation until support for PHP 5.6 is officially dropped in WordPress. Props skoskie, jrf, desrosj, TimothyBlynJacobs. See #49922. Fixes #49810. Built from https://develop.svn.wordpress.org/trunk@47926 git-svn-id: http://core.svn.wordpress.org/trunk@47700 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/IXR/class-IXR-server.php | 8 +------- wp-includes/rest-api/class-wp-rest-server.php | 7 +++---- wp-includes/version.php | 2 +- xmlrpc.php | 5 +++-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/wp-includes/IXR/class-IXR-server.php b/wp-includes/IXR/class-IXR-server.php index 9702ba28b7..3112d23815 100644 --- a/wp-includes/IXR/class-IXR-server.php +++ b/wp-includes/IXR/class-IXR-server.php @@ -47,13 +47,7 @@ class IXR_Server die('XML-RPC server accepts POST requests only.'); } - global $HTTP_RAW_POST_DATA; - if (empty($HTTP_RAW_POST_DATA)) { - // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293 - $data = file_get_contents('php://input'); - } else { - $data =& $HTTP_RAW_POST_DATA; - } + $data = file_get_contents('php://input'); } $this->message = new IXR_Message($data); if (!$this->message->parse()) { diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index 0ab94bbbde..a7c43b041f 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -1371,17 +1371,16 @@ class WP_REST_Server { * @return string Raw request data. */ public static function get_raw_data() { + // phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved global $HTTP_RAW_POST_DATA; - /* - * A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, - * but we can do it ourself. - */ + // $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0. if ( ! isset( $HTTP_RAW_POST_DATA ) ) { $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); } return $HTTP_RAW_POST_DATA; + // phpcs:enable } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index e8b649e760..4a21a973bc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47925'; +$wp_version = '5.5-alpha-47926'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/xmlrpc.php b/xmlrpc.php index 00bd97e8df..341a6dc84d 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -15,8 +15,8 @@ define( 'XMLRPC_REQUEST', true ); // Some browser-embedded clients send cookies. We don't want them. $_COOKIE = array(); -// A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, -// but we can do it ourself. +// $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0. +// phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved if ( ! isset( $HTTP_RAW_POST_DATA ) ) { $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); } @@ -25,6 +25,7 @@ if ( ! isset( $HTTP_RAW_POST_DATA ) ) { if ( isset( $HTTP_RAW_POST_DATA ) ) { $HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA ); } +// phpcs:enable /** Include the bootstrap for setting up WordPress environment */ require_once __DIR__ . '/wp-load.php';