WordPress.org

Make WordPress Core

Changeset 47926


Ignore:
Timestamp:
06/08/2020 07:53:19 PM (5 months ago)
Author:
desrosj
Message:

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.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/IXR/class-IXR-server.php

    r45424 r47926  
    4848            }
    4949
    50             global $HTTP_RAW_POST_DATA;
    51             if (empty($HTTP_RAW_POST_DATA)) {
    52                 // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293
    53                 $data = file_get_contents('php://input');
    54             } else {
    55                 $data =& $HTTP_RAW_POST_DATA;
    56             }
     50            $data = file_get_contents('php://input');
    5751        }
    5852        $this->message = new IXR_Message($data);
  • trunk/src/wp-includes/rest-api/class-wp-rest-server.php

    r47849 r47926  
    13721372     */
    13731373    public static function get_raw_data() {
     1374        // phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved
    13741375        global $HTTP_RAW_POST_DATA;
    13751376
    1376         /*
    1377          * A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
    1378          * but we can do it ourself.
    1379          */
     1377        // $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0.
    13801378        if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
    13811379            $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
     
    13831381
    13841382        return $HTTP_RAW_POST_DATA;
     1383        // phpcs:enable
    13851384    }
    13861385
  • trunk/src/xmlrpc.php

    r47198 r47926  
    1616$_COOKIE = array();
    1717
    18 // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
    19 // but we can do it ourself.
     18// $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0.
     19// phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved
    2020if ( ! isset( $HTTP_RAW_POST_DATA ) ) {
    2121    $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
     
    2626    $HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA );
    2727}
     28// phpcs:enable
    2829
    2930/** Include the bootstrap for setting up WordPress environment */
Note: See TracChangeset for help on using the changeset viewer.