From: Kunal Mehta Date: Thu, 1 Dec 2016 07:19:37 +0000 (-0800) Subject: registration: Provide credits information to callbacks X-Git-Tag: 1.31.0-rc.0~4661^2 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=b54acaf847131fdac9352aa35e4b82327751a3de;p=lhc%2Fweb%2Fwiklou.git registration: Provide credits information to callbacks Registration callbacks now provide basic credits information (name, path, type, authors, license-name, version, etc.) as the first argument. The main use case right now for this is to support extension VERSION constants for backwards-compatibility. In addition, callbacks now run *after* attributes are exposed, so callbacks could use data from them if they wanted to. Bug: T151136 Change-Id: Ic5965dd4e259e1f46222ac92b8e78750e67b51d6 --- diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 207f88423e..d9671324fe 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -141,6 +141,7 @@ class ExtensionProcessor implements Processor { /** * Things to be called once registration of these extensions are done + * keyed by the name of the extension that it belongs to * * @var callable[] */ @@ -180,11 +181,11 @@ class ExtensionProcessor implements Processor { $this->extractResourceLoaderModules( $dir, $info ); $this->extractServiceWiringFiles( $dir, $info ); $this->extractParserTestFiles( $dir, $info ); + $name = $this->extractCredits( $path, $info ); if ( isset( $info['callback'] ) ) { - $this->callbacks[] = $info['callback']; + $this->callbacks[$name] = $info['callback']; } - $this->extractCredits( $path, $info ); foreach ( $info as $key => $val ) { if ( in_array( $key, self::$globalSettings ) ) { $this->storeToArray( $path, "wg$key", $val, $this->globals ); @@ -335,6 +336,7 @@ class ExtensionProcessor implements Processor { /** * @param string $path * @param array $info + * @return string Name of thing * @throws Exception */ protected function extractCredits( $path, array $info ) { @@ -360,6 +362,8 @@ class ExtensionProcessor implements Processor { $this->credits[$name] = $credits; $this->globals['wgExtensionCredits'][$credits['type']][] = $credits; + + return $name; } /** diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index b5c70e984b..01838dd1fe 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 = 3; + const CACHE_VERSION = 4; /** * Special key that defines the merge strategy @@ -285,9 +285,6 @@ class ExtensionRegistry { foreach ( $info['autoloaderPaths'] as $path ) { require_once $path; } - foreach ( $info['callbacks'] as $cb ) { - call_user_func( $cb ); - } $this->loaded += $info['credits']; if ( $info['attributes'] ) { @@ -297,6 +294,10 @@ class ExtensionRegistry { $this->attributes = array_merge_recursive( $this->attributes, $info['attributes'] ); } } + + foreach ( $info['callbacks'] as $name => $cb ) { + call_user_func( $cb, $info['credits'][$name] ); + } } /**