diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2017-05-16 04:00:28 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2017-05-16 04:00:28 +0000 |
commit | 5891a2e733106fa1290f36c749e89d74b46ba2cb (patch) | |
tree | 92d63bc019eeaded62d1ed11481973a781501b6c /includes/registration | |
parent | 5ec6fd945cb2889482eb47002205ff7288faacfe (diff) | |
parent | fdb7e9410465fd8f2370c182dc18221cb7bd8470 (diff) | |
download | mediawikicore-5891a2e733106fa1290f36c749e89d74b46ba2cb.tar.gz mediawikicore-5891a2e733106fa1290f36c749e89d74b46ba2cb.zip |
Merge "registration: Move attributes out of the top level"
Diffstat (limited to 'includes/registration')
-rw-r--r-- | includes/registration/ExtensionProcessor.php | 75 | ||||
-rw-r--r-- | includes/registration/ExtensionRegistry.php | 2 |
2 files changed, 72 insertions, 5 deletions
diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 1212f9972cba..d14be3ff8dd7 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -57,6 +57,16 @@ class ExtensionProcessor implements Processor { ]; /** + * Top-level attributes that come from MW core + * + * @var string[] + */ + protected static $coreAttributes = [ + 'SkinOOUIThemes', + 'TrackingCategories', + ]; + + /** * Mapping of global settings to their specific merge strategies. * * @see ExtensionRegistry::exportExtractedData @@ -161,6 +171,14 @@ class ExtensionProcessor implements Processor { protected $attributes = []; /** + * Extension attributes, keyed by name => + * settings. + * + * @var array + */ + protected $extAttributes = []; + + /** * @param string $path * @param array $info * @param int $version manifest_version for info @@ -186,14 +204,47 @@ class ExtensionProcessor implements Processor { $this->callbacks[$name] = $info['callback']; } + if ( $version === 2 ) { + $this->extractAttributes( $path, $info ); + } + foreach ( $info as $key => $val ) { + // If it's a global setting, if ( in_array( $key, self::$globalSettings ) ) { $this->storeToArray( $path, "wg$key", $val, $this->globals ); + continue; + } // Ignore anything that starts with a @ - } elseif ( $key[0] !== '@' && !in_array( $key, self::$notAttributes ) - && !in_array( $key, self::$creditsAttributes ) - ) { - $this->storeToArray( $path, $key, $val, $this->attributes ); + if ( $key[0] === '@' ) { + continue; + } + + if ( $version === 2 ) { + // Only whitelisted attributes are set + if ( in_array( $key, self::$coreAttributes ) ) { + $this->storeToArray( $path, $key, $val, $this->attributes ); + } + } else { + // version === 1 + if ( !in_array( $key, self::$notAttributes ) + && !in_array( $key, self::$creditsAttributes ) + ) { + // If it's not blacklisted, it's an attribute + $this->storeToArray( $path, $key, $val, $this->attributes ); + } + } + + } + } + + /** + * @param string $path + * @param array $info + */ + protected function extractAttributes( $path, array $info ) { + if ( isset( $info['attributes'] ) ) { + foreach ( $info['attributes'] as $extName => $value ) { + $this->storeToArray( $path, $extName, $value, $this->extAttributes ); } } } @@ -206,6 +257,22 @@ class ExtensionProcessor implements Processor { } } + // Merge $this->extAttributes into $this->attributes depending on what is loaded + foreach ( $this->extAttributes as $extName => $value ) { + // Only set the attribute if $extName is loaded (and hence present in credits) + if ( isset( $this->credits[$extName] ) ) { + foreach ( $value as $attrName => $attrValue ) { + $this->storeToArray( + '', // Don't provide a path since it's impossible to generate an error here + $extName . $attrName, + $attrValue, + $this->attributes + ); + } + unset( $this->extAttributes[$extName] ); + } + } + return [ 'globals' => $this->globals, 'defines' => $this->defines, diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 54e394a09f0e..0423f71af591 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -31,7 +31,7 @@ class ExtensionRegistry { /** * Bump whenever the registration cache needs resetting */ - const CACHE_VERSION = 5; + const CACHE_VERSION = 6; /** * Special key that defines the merge strategy |