Merge "registration: Convert "config" into an object with metadata"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 14 Jul 2016 13:12:27 +0000 (13:12 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 14 Jul 2016 13:12:27 +0000 (13:12 +0000)
1  2 
docs/extension.schema.json
includes/registration/ExtensionProcessor.php

                        "type": "object",
                        "description": "Central ID lookup providers"
                },
 +              "ChangeCredentialsBlacklist": {
 +                      "type": "object",
 +                      "description": "AuthenticationRequest classes which can only be used internally for credentials change"
 +              },
 +              "RemoveCredentialsBlacklist": {
 +                      "type": "object",
 +                      "description": "AuthenticationRequest classes which can only be used internally for credentials removal"
 +              },
                "namespaces": {
                        "type": "array",
                        "description": "Method to add extra namespaces",
                        ],
                        "description": "A function to be called right after MediaWiki processes this file"
                },
+               "config_prefix": {
+                       "type": "string",
+                       "default": "wg",
+                       "description": "Prefix to put in front of configuration settings when exporting them to $GLOBALS"
+               },
                "config": {
                        "type": "object",
                        "description": "Configuration options for this extension",
-                       "properties": {
-                               "_prefix": {
-                                       "type": "string",
-                                       "default": "wg",
-                                       "description": "Prefix to put in front of configuration settings when exporting them to $GLOBALS"
-                               }
-                       },
                        "patternProperties": {
                                "^[a-zA-Z_\u007f-\u00ff][a-zA-Z0-9_\u007f-\u00ff]*$": {
                                        "properties": {
-                                               "_merge_strategy": {
+                                               "value": {
+                                                       "required": true
+                                               },
+                                               "merge_strategy": {
                                                        "type": "string",
                                                        "enum": [
                                                                "array_merge_recursive",
                                                                "array_merge"
                                                        ],
                                                        "default": "array_merge"
+                                               },
+                                               "description": {
+                                                       "type": ["string", "array"],
+                                                       "description": "A description of the config setting, mostly for documentation/developers"
                                                }
                                        }
                                }
@@@ -27,8 -27,6 +27,8 @@@ class ExtensionProcessor implements Pro
                'SessionProviders',
                'AuthManagerAutoConfig',
                'CentralIdLookupProviders',
 +              'ChangeCredentialsBlacklist',
 +              'RemoveCredentialsBlacklist',
                'RateLimits',
                'RecentChangesFlags',
                'MediaHandlers',
                'MessagesDirs',
                'type',
                'config',
+               'config_prefix',
                'ParserTestFiles',
                'AutoloadClasses',
                'manifest_version',
         * @return array
         */
        public function extractInfo( $path, array $info, $version ) {
-               $this->extractConfig( $info );
+               if ( $version === 2 ) {
+                       $this->extractConfig2( $info );
+               } else {
+                       // $version === 1
+                       $this->extractConfig1( $info );
+               }
                $this->extractHooks( $info );
                $dir = dirname( $path );
                $this->extractExtensionMessagesFiles( $dir, $info );
        }
  
        /**
-        * Set configuration settings
+        * Set configuration settings for manifest_version == 1
         * @todo In the future, this should be done via Config interfaces
         *
         * @param array $info
         */
-       protected function extractConfig( array $info ) {
+       protected function extractConfig1( array $info ) {
                if ( isset( $info['config'] ) ) {
                        if ( isset( $info['config']['_prefix'] ) ) {
                                $prefix = $info['config']['_prefix'];
                }
        }
  
+       /**
+        * Set configuration settings for manifest_version == 2
+        * @todo In the future, this should be done via Config interfaces
+        *
+        * @param array $info
+        */
+       protected function extractConfig2( array $info ) {
+               if ( isset( $info['config_prefix'] ) ) {
+                       $prefix = $info['config_prefix'];
+               } else {
+                       $prefix = 'wg';
+               }
+               if ( isset( $info['config'] ) ) {
+                       foreach ( $info['config'] as $key => $data ) {
+                               $value = $data['value'];
+                               if ( isset( $value['merge_strategy'] ) ) {
+                                       $value[ExtensionRegistry::MERGE_STRATEGY] = $value['merge_strategy'];
+                               }
+                               $this->globals["$prefix$key"] = $value;
+                       }
+               }
+       }
        protected function extractParserTestFiles( $dir, array $info ) {
                if ( isset( $info['ParserTestFiles'] ) ) {
                        foreach ( $info['ParserTestFiles'] as $path ) {