Skip to:
Content

BuddyPress.org

Changeset 11359


Ignore:
Timestamp:
12/29/2016 08:39:07 PM (8 years ago)
Author:
boonebgorges
Message:

Remove PHP 5.2 polyfill for array_replace_recursive() in BP_Activity_Activity.

Fixes #7334.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-activity.php

    r11312 r11359  
    427427            // Override some arguments if needed.
    428428            if ( ! empty( $scope_query['override'] ) ) {
    429                 $r = self::array_replace_recursive( $r, $scope_query['override'] );
     429                $r = array_replace_recursive( $r, $scope_query['override'] );
    430430            }
    431431
     
    18711871        return $wpdb->get_var( $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET hide_sitewide = 1 WHERE user_id = %d", $user_id ) );
    18721872    }
    1873 
    1874     /**
    1875      * PHP-agnostic version of {@link array_replace_recursive()}.
    1876      *
    1877      * The array_replace_recursive() function is a PHP 5.3 function.  BuddyPress (and
    1878      * WordPress) currently supports down to PHP 5.2, so this method is a workaround
    1879      * for PHP 5.2.
    1880      *
    1881      * Note: array_replace_recursive() supports infinite arguments, but for our use-
    1882      * case, we only need to support two arguments.
    1883      *
    1884      * Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.
    1885      *
    1886      * @since 2.2.0
    1887      *
    1888      * @see http://php.net/manual/en/function.array-replace-recursive.php#109390
    1889      *
    1890      * @param  array $base         Array with keys needing to be replaced.
    1891      * @param  array $replacements Array with the replaced keys.
    1892      * @return array
    1893      */
    1894     protected static function array_replace_recursive( $base = array(), $replacements = array() ) {
    1895         if ( function_exists( 'array_replace_recursive' ) ) {
    1896             return array_replace_recursive( $base, $replacements );
    1897         }
    1898 
    1899         // PHP 5.2-compatible version
    1900         // http://php.net/manual/en/function.array-replace-recursive.php#109390.
    1901         foreach ( array_slice( func_get_args(), 1 ) as $replacements ) {
    1902             $bref_stack = array( &$base );
    1903             $head_stack = array( $replacements );
    1904 
    1905             do {
    1906                 end( $bref_stack );
    1907 
    1908                 $bref = &$bref_stack[ key( $bref_stack ) ];
    1909                 $head = array_pop( $head_stack );
    1910 
    1911                 unset( $bref_stack[ key($bref_stack) ] );
    1912 
    1913                 foreach ( array_keys( $head ) as $key ) {
    1914                     if ( isset( $key, $bref ) && is_array( $bref[$key] ) && is_array( $head[$key] ) ) {
    1915                         $bref_stack[] = &$bref[ $key ];
    1916                         $head_stack[] = $head[ $key ];
    1917                     } else {
    1918                         $bref[ $key ] = $head[ $key ];
    1919                     }
    1920                 }
    1921             } while( count( $head_stack ) );
    1922         }
    1923 
    1924         return $base;
    1925     }
    19261873}
Note: See TracChangeset for help on using the changeset viewer.