[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_27]: registration: Provide credits information to callbacks

2017-07-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/325081 )

Change subject: registration: Provide credits information to callbacks
..


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
(cherry picked from commit b54acaf847131fdac9352aa35e4b82327751a3de)
---
M includes/registration/ExtensionProcessor.php
M includes/registration/ExtensionRegistry.php
2 files changed, 11 insertions(+), 6 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/registration/ExtensionProcessor.php 
b/includes/registration/ExtensionProcessor.php
index 3763960..cbe0949 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -132,6 +132,7 @@
 
/**
 * Things to be called once registration of these extensions are done
+* keyed by the name of the extension that it belongs to
 *
 * @var callable[]
 */
@@ -165,11 +166,11 @@
$this->extractNamespaces( $info );
$this->extractResourceLoaderModules( $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 );
@@ -320,6 +321,7 @@
/**
 * @param string $path
 * @param array $info
+* @return string Name of thing
 * @throws Exception
 */
protected function extractCredits( $path, array $info ) {
@@ -345,6 +347,8 @@
 
$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 dc53ca4..ebcddb2 100644
--- a/includes/registration/ExtensionRegistry.php
+++ b/includes/registration/ExtensionRegistry.php
@@ -29,7 +29,7 @@
/**
 * Bump whenever the registration cache needs resetting
 */
-   const CACHE_VERSION = 3;
+   const CACHE_VERSION = 4;
 
/**
 * Special key that defines the merge strategy
@@ -277,9 +277,6 @@
foreach ( $info['autoloaderPaths'] as $path ) {
require_once $path;
}
-   foreach ( $info['callbacks'] as $cb ) {
-   call_user_func( $cb );
-   }
 
$this->loaded += $info['credits'];
if ( $info['attributes'] ) {
@@ -289,6 +286,10 @@
$this->attributes = array_merge_recursive( 
$this->attributes, $info['attributes'] );
}
}
+
+   foreach ( $info['callbacks'] as $name => $cb ) {
+   call_user_func( $cb, $info['credits'][$name] );
+   }
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/325081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic5965dd4e259e1f46222ac92b8e78750e67b51d6
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Paladox 
Gerrit-Reviewer: Chad 
Gerrit-Reviewer: Florianschmidtwelzow 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Mwjames 
Gerrit-Reviewer: Reedy 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_27]: registration: Provide credits information to callbacks

2016-12-02 Thread Paladox (Code Review)
Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325081

Change subject: registration: Provide credits information to callbacks
..

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
---
M includes/registration/ExtensionProcessor.php
M includes/registration/ExtensionRegistry.php
2 files changed, 11 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/81/325081/1

diff --git a/includes/registration/ExtensionProcessor.php 
b/includes/registration/ExtensionProcessor.php
index 78f9370..eba6b36 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -132,6 +132,7 @@
 
/**
 * Things to be called once registration of these extensions are done
+* keyed by the name of the extension that it belongs to
 *
 * @var callable[]
 */
@@ -165,11 +166,11 @@
$this->extractNamespaces( $info );
$this->extractResourceLoaderModules( $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 );
@@ -317,6 +318,7 @@
/**
 * @param string $path
 * @param array $info
+* @return string $name
 * @throws Exception
 */
protected function extractCredits( $path, array $info ) {
@@ -342,6 +344,8 @@
 
$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 dc53ca4..ebcddb2 100644
--- a/includes/registration/ExtensionRegistry.php
+++ b/includes/registration/ExtensionRegistry.php
@@ -29,7 +29,7 @@
/**
 * Bump whenever the registration cache needs resetting
 */
-   const CACHE_VERSION = 3;
+   const CACHE_VERSION = 4;
 
/**
 * Special key that defines the merge strategy
@@ -277,9 +277,6 @@
foreach ( $info['autoloaderPaths'] as $path ) {
require_once $path;
}
-   foreach ( $info['callbacks'] as $cb ) {
-   call_user_func( $cb );
-   }
 
$this->loaded += $info['credits'];
if ( $info['attributes'] ) {
@@ -289,6 +286,10 @@
$this->attributes = array_merge_recursive( 
$this->attributes, $info['attributes'] );
}
}
+
+   foreach ( $info['callbacks'] as $name => $cb ) {
+   call_user_func( $cb, $info['credits'][$name] );
+   }
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/325081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5965dd4e259e1f46222ac92b8e78750e67b51d6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Paladox 
Gerrit-Reviewer: Legoktm 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits