Make WordPress Core

Ticket #46630: 46630.patch

File 46630.patch, 3.6 KB (added by ayeshrajans, 6 years ago)

Travis: https://travis-ci.org/Ayesh/wordpress-develop/builds/510720605

  • src/wp-includes/compat.php

    diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php
    index aae4f73416..12a9c6d255 100644
    a b function array_replace_recursive( $base = array(), $replacements = array() ) { 
    500500        }
    501501endif;
    502502
    503 /**
    504  * Polyfill for the SPL autoloader. In PHP 5.2 (but not 5.3 and later), SPL can
    505  * be disabled, and PHP 7.2 raises notices if the compiler finds an __autoload()
    506  * function declaration. Function availability is checked here, and the
    507  * autoloader is included only if necessary.
    508  */
    509 if ( ! function_exists( 'spl_autoload_register' ) ) {
    510         require_once ABSPATH . WPINC . '/spl-autoload-compat.php';
    511 }
    512503
    513504if ( ! function_exists( 'is_countable' ) ) {
    514505        /**
  • deleted file src/wp-includes/spl-autoload-compat.php

    diff --git a/src/wp-includes/spl-autoload-compat.php b/src/wp-includes/spl-autoload-compat.php
    deleted file mode 100644
    index 599b6046b3..0000000000
    + -  
    1 <?php
    2 /**
    3  * Polyfill for SPL autoload feature. This file is separate to prevent compiler notices
    4  * on the deprecated __autoload() function.
    5  *
    6  * See https://core.trac.wordpress.org/ticket/41134
    7  *
    8  * @package PHP
    9  * @access private
    10  */
    11 
    12 if ( ! function_exists( 'spl_autoload_register' ) ) {
    13         $_wp_spl_autoloaders = array();
    14 
    15         /**
    16          * Autoloader compatibility callback.
    17          *
    18          * @since 4.6.0
    19          *
    20          * @param string $classname Class to attempt autoloading.
    21          */
    22         function __autoload( $classname ) {
    23                 global $_wp_spl_autoloaders;
    24                 foreach ( $_wp_spl_autoloaders as $autoloader ) {
    25                         if ( ! is_callable( $autoloader ) ) {
    26                                 // Avoid the extra warning if the autoloader isn't callable.
    27                                 continue;
    28                         }
    29 
    30                         call_user_func( $autoloader, $classname );
    31 
    32                         // If it has been autoloaded, stop processing.
    33                         if ( class_exists( $classname, false ) ) {
    34                                 return;
    35                         }
    36                 }
    37         }
    38 
    39         /**
    40          * Registers a function to be autoloaded.
    41          *
    42          * @since 4.6.0
    43          *
    44          * @param callable $autoload_function The function to register.
    45          * @param bool     $throw             Optional. Whether the function should throw an exception
    46          *                                    if the function isn't callable. Default true.
    47          * @param bool     $prepend           Whether the function should be prepended to the stack.
    48          *                                    Default false.
    49          */
    50         function spl_autoload_register( $autoload_function, $throw = true, $prepend = false ) {
    51                 if ( $throw && ! is_callable( $autoload_function ) ) {
    52                         // String not translated to match PHP core.
    53                         throw new Exception( 'Function not callable' );
    54                 }
    55 
    56                 global $_wp_spl_autoloaders;
    57 
    58                 // Don't allow multiple registration.
    59                 if ( in_array( $autoload_function, $_wp_spl_autoloaders ) ) {
    60                         return;
    61                 }
    62 
    63                 if ( $prepend ) {
    64                         array_unshift( $_wp_spl_autoloaders, $autoload_function );
    65                 } else {
    66                         $_wp_spl_autoloaders[] = $autoload_function;
    67                 }
    68         }
    69 
    70         /**
    71          * Unregisters an autoloader function.
    72          *
    73          * @since 4.6.0
    74          *
    75          * @param callable $function The function to unregister.
    76          * @return bool True if the function was unregistered, false if it could not be.
    77          */
    78         function spl_autoload_unregister( $function ) {
    79                 global $_wp_spl_autoloaders;
    80                 foreach ( $_wp_spl_autoloaders as &$autoloader ) {
    81                         if ( $autoloader === $function ) {
    82                                 unset( $autoloader );
    83                                 return true;
    84                         }
    85                 }
    86 
    87                 return false;
    88         }
    89 
    90         /**
    91          * Retrieves the registered autoloader functions.
    92          *
    93          * @since 4.6.0
    94          *
    95          * @return array List of autoloader functions.
    96          */
    97         function spl_autoload_functions() {
    98                 return $GLOBALS['_wp_spl_autoloaders'];
    99         }
    100 }