Make WordPress Core


Ignore:
Timestamp:
04/22/2020 03:40:41 PM (4 years ago)
Author:
desrosj
Message:

Bootstrap/Load: Deprecate wp_unregister_GLOBALS().

The register_globals directive in PHP was deprecated in version 5.3 and removed entirely in 5.4.

Now that WordPress only supports PHP 5.6.20 and newer, the wp_unregister_GLOBALS() function can be deprecated.

Props ayeshrajans, desrosj, SergeyBiryukov.
Fixes #49938.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r47550 r47612  
    1919    }
    2020    return $protocol;
    21 }
    22 
    23 /**
    24  * Turn register globals off.
    25  *
    26  * @since 2.1.0
    27  * @access private
    28  */
    29 function wp_unregister_GLOBALS() {  // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
    30     if ( ! ini_get( 'register_globals' ) ) {
    31         return;
    32     }
    33 
    34     if ( isset( $_REQUEST['GLOBALS'] ) ) {
    35         die( 'GLOBALS overwrite attempt detected' );
    36     }
    37 
    38     // Variables that shouldn't be unset.
    39     $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );
    40 
    41     $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
    42     foreach ( $input as $k => $v ) {
    43         if ( ! in_array( $k, $no_unset, true ) && isset( $GLOBALS[ $k ] ) ) {
    44             unset( $GLOBALS[ $k ] );
    45         }
    46     }
    4721}
    4822
Note: See TracChangeset for help on using the changeset viewer.