Fix array order for array_replace_recursive merge strategy

Prior to this change, if a configuration array is defined
in extension.json, array elements cannot be overridden by
setting values in the corresponding configuration variable,
as intended by the array_replace_recursive merge strategy.
This is because the order of the arrays in the
array_replace_recursive() function call need to be
reversed.

Bug: T283464
Change-Id: I55561232a994f745c5f3cd8394674b18c0529d13
This commit is contained in:
Cindy Cicalese 2021-05-23 13:29:35 -04:00
parent 6feb8d7834
commit 4d413376b9
2 changed files with 6 additions and 6 deletions

View file

@ -494,7 +494,7 @@ class ExtensionRegistry {
$GLOBALS[$key] = array_merge_recursive( $GLOBALS[$key], $val );
break;
case 'array_replace_recursive':
$GLOBALS[$key] = array_replace_recursive( $GLOBALS[$key], $val );
$GLOBALS[$key] = array_replace_recursive( $val, $GLOBALS[$key] );
break;
case 'array_plus_2d':
$GLOBALS[$key] = wfArrayPlus2d( $GLOBALS[$key], $val );

View file

@ -361,17 +361,17 @@ class ExtensionRegistryTest extends MediaWikiIntegrationTestCase {
'JsonZeroConfig' => [
'namespace' => 480,
'nsName' => 'Zero',
'isLocal' => true,
'isLocal' => false,
'remote' => [
'username' => 'foo',
],
],
],
],
[
'mwtestJsonConfigs' => [
'JsonZeroConfig' => [
'isLocal' => false,
'remote' => [
'username' => 'foo',
],
'isLocal' => true,
],
ExtensionRegistry::MERGE_STRATEGY => 'array_replace_recursive',
],