[wp-trac] [WordPress Trac] #36819: Load plugin.php earlier in wp-settings.php
WordPress Trac
noreply at wordpress.org
Fri Aug 5 09:09:21 UTC 2016
#36819: Load plugin.php earlier in wp-settings.php
-----------------------------------+------------------------
Reporter: jorbin | Owner: jorbin
Type: task (blessed) | Status: reviewing
Priority: normal | Milestone: 4.6
Component: Bootstrap/Load | Version:
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion | Focuses:
-----------------------------------+------------------------
Comment (by schlessera):
Argh, of course `array_replace_recursive()` has only been introduced with
PHP 5.3. I think that a polyfill would be best suited then. It will have
slightly worse performance of custom PHP looping in PHP 5.2, but provide
full implemented speed from PHP 5.3 onwards.
Something like this is proposed in PHP docs:
{{{#!php
<?php
if ( ! function_exists( 'array_replace_recursive' ) ) {
function array_replace_recursive( $array, $array1 ) {
function recurse( $array, $array1 ) {
foreach ( $array1 as $key => $value ) {
// create new key in $array, if it is
empty or not an array
if ( ! isset( $array[ $key ] ) || ( isset(
$array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) {
$array[ $key ] = [ ];
}
// overwrite the value in the base array
if ( is_array( $value ) ) {
$value = recurse( $array[ $key ],
$value );
}
$array[ $key ] = $value;
}
return $array;
}
// handle the arguments, merge one by one
$args = func_get_args();
$array = $args[0];
if ( ! is_array( $array ) ) {
return $array;
}
for ( $i = 1; $i < count( $args ); $i ++ ) {
if ( is_array( $args[ $i ] ) ) {
$array = recurse( $array, $args[ $i ] );
}
}
return $array;
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36819#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list