Reedy has submitted this change and it was merged. Change subject: Use array_replace_recursive to merge jsonconfigs ......................................................................
Use array_replace_recursive to merge jsonconfigs TBD: It seems we can safely get rid of all array_replace_recursive( ...->getAttribute( 'JsonConfigs' ), $wgJsonConfigs ); and $wgJsonConfigModels because the globals by that time already contain everything we need. @legoktm? Bug: T147971 Depends-on: Ibd88c4dc98f36d7d8336691884bbaa9a4864da83 Depends-on: Ica6ddd0ae76f23e60de9b6235c6e2a3f2754a95d Change-Id: I830bfa81ee882029b9017e141d73182556ebb1cf --- M extension.json M includes/JCSingleton.php 2 files changed, 26 insertions(+), 12 deletions(-) Approvals: Reedy: Looks good to me, approved Jdlrobson: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/extension.json b/extension.json index 43afcd2..75d46cc 100644 --- a/extension.json +++ b/extension.json @@ -119,12 +119,26 @@ ] }, "config": { - "JsonConfigs": [], - "JsonConfigModels": [], - "JsonConfigDisableCache": false, - "JsonConfigCacheKeyPrefix": "1", - "JsonConfigEnableLuaSupport": false, - "JsonConfigInterwikiPrefix": "commons" + "JsonConfigs": { + "merge_strategy": "array_replace_recursive", + "value": {} + }, + "JsonConfigModels": { + "merge_strategy": "array_replace_recursive", + "value": {} + }, + "JsonConfigDisableCache": { + "value": false + }, + "JsonConfigCacheKeyPrefix": { + "value": "1" + }, + "JsonConfigEnableLuaSupport": { + "value": false + }, + "JsonConfigInterwikiPrefix": { + "value": "commons" + } }, - "manifest_version": 1 + "manifest_version": 2 } diff --git a/includes/JCSingleton.php b/includes/JCSingleton.php index 15d98c8..7adb634 100644 --- a/includes/JCSingleton.php +++ b/includes/JCSingleton.php @@ -69,8 +69,8 @@ list( self::$titleMap, self::$namespaces ) = self::parseConfiguration( $wgNamespaceContentModels, $wgContentHandlers, - \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigs' ) + $wgJsonConfigs, - \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigModels' ) + $wgJsonConfigModels + array_replace_recursive( \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigs' ), $wgJsonConfigs ), + array_replace_recursive( \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigModels' ), $wgJsonConfigModels ) ); } @@ -384,7 +384,7 @@ public static function getContentClass( $modelId ) { global $wgJsonConfigModels; - $configModels = \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigModels' ) + $wgJsonConfigModels; + $configModels = array_replace_recursive( \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigModels' ), $wgJsonConfigModels ); $class = null; if ( array_key_exists( $modelId, $configModels ) ) { $value = $configModels[$modelId]; @@ -579,7 +579,7 @@ } self::init(); - $models = \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigModels' ) + $wgJsonConfigModels; + $models = array_replace_recursive( \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigModels' ), $wgJsonConfigModels ); if ( array_key_exists( $modelId, $models ) ) { // This is one of our model IDs $handler = new JCContentHandler( $modelId ); @@ -784,7 +784,7 @@ if ( $isStorage === null ) { global $wgJsonConfigs; $isStorage = false; - $configs = \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigs' ) + $wgJsonConfigs; + $configs = array_replace_recursive( \ExtensionRegistry::getInstance()->getAttribute( 'JsonConfigs' ), $wgJsonConfigs ); foreach ( $configs as $jc ) { if ( ( !array_key_exists( 'isLocal', $jc ) || $jc['isLocal'] ) || ( array_key_exists( 'store', $jc ) ) -- To view, visit https://gerrit.wikimedia.org/r/316523 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I830bfa81ee882029b9017e141d73182556ebb1cf Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/JsonConfig Gerrit-Branch: master Gerrit-Owner: Yurik <yu...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Paladox <thomasmulhall...@yahoo.com> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits