[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Change internal data structure for extensions

2016-12-26 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/329223 )

Change subject: Change internal data structure for extensions
..


Change internal data structure for extensions

Architecture:
* Previously there were two associative arrays for extensions
  and skins, with $name => $loadingMechanism. Now there is only
  one (list) array with values array( $name, $type,
  $loadingMechanism, $initialOrder ), with $type == 'extension'
  or 'skin'. The order of this list is used to create
  the LocalSettings.php. This change is in preparation of
  Composer-managed extensions, to allow activation of some
  extensions before other (typically PageForms 4.0+ and
  SemanticFormsSelect).
* The extensions+skins list can be sorted. Currently it is sorted
  with the following order: require_once(skins), require_once(exts),
  wfLoadSkin, wfLoadExtension. The sorting is stable, so that
  it is possible to impose some order inside each category.

Code:
* The previous associative array is transformed in a list of tuples
  because standard PHP functions do not allow to sort by key *and*
  value (it’s key *xor* value). The new information $initialOrder
  is added to allow a stable sort (standard PHP sorting is not
  stable).

Change-Id: Idb60c537da3c99a9cdec7a80f31acaf597bcd1fa
---
M src/MediaWikiFarm.php
M src/main.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
5 files changed, 121 insertions(+), 115 deletions(-)

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



diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5f5c309..7c544b5 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -73,7 +73,6 @@
protected $configuration = array(
'settings' => array(),
'arrays' => array(),
-   'skins' => array(),
'extensions' => array(),
'execFiles' => array(),
);
@@ -174,8 +173,7 @@
 * This associative array contains four sections:
 *   - 'settings': associative array of MediaWiki configuration (e.g. 
'wgServer' => '//example.org');
 *   - 'arrays': associative array of MediaWiki configuration of type 
array (e.g. 'wgGroupPermissions' => array( 'edit' => false ));
-*   - 'skins': associative array of skins configuration (e.g. 'Vector' 
=> 'wfLoadSkin' );
-*   - 'extensions': associative array of extensions configuration 
(e.g. 'ParserFunctions' => 'wfLoadExtension' );
+*   - 'extensions': list of extensions and skins (e.g. 0 => array( 
'ParserFunctions', 'extension', 'wfLoadExtension' ));
 *   - 'execFiles': list of PHP files to execute at the end.
 *
 * @mediawikifarm-const
@@ -360,30 +358,31 @@
$GLOBALS[$setting] = self::arrayMerge( 
$GLOBALS[$setting], $value );
}
 
-   # Load skins with the wfLoadSkin mechanism
-   foreach( $this->configuration['skins'] as $skin => $value ) {
+   # Load extensions and skins with the wfLoadExtension/wfLoadSkin 
mechanism
+   $loadMediaWikiFarm = false;
+   foreach( $this->configuration['extensions'] as $extension ) {
 
-   if( $value == 'wfLoadSkin' ) {
+   if( $extension[2] == 'wfLoadExtension' ) {
 
-   wfLoadSkin( $skin );
+   if( $extension[0] != 'MediaWikiFarm' || 
!$this->codeDir ) {
+   wfLoadExtension( $extension[0] );
+   } else {
+   wfLoadExtension( 'MediaWikiFarm', 
$this->farmDir . '/extension.json' );
+   $loadedMediaWikiFarm = true;
+   }
}
-   }
+   elseif( $extension[2] == 'wfLoadSkin' ) {
 
-   # Load extensions with the wfLoadExtension mechanism
-   foreach( $this->configuration['extensions'] as $extension => 
$value ) {
+   wfLoadSkin( $extension[0] );
+   }
+   elseif( $extension[0] == 'MediaWikiFarm' && 
$extension[1] == 'extension' && $extension[2] == 'require_once' ) {
 
-   if( $value == 'wfLoadExtension' && ( $extension != 
'MediaWikiFarm' || !$this->codeDir ) ) {
-
-   wfLoadExtension( $extension );
+   $loadMediaWikiFarm = true;
}
}
 
# Register this extension MediaWikiFarm to appear in 
Special:Version
-   if( $this->configuration['extensions']['MediaWikiFarm'] == 
'wfLoadExtension' && $this->codeDir ) {
-
-   wfLoadExtension( 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Change internal data structure for extensions

2016-12-26 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/329223 )

Change subject: Change internal data structure for extensions
..

Change internal data structure for extensions

Architecture:
* Previously there were two associative arrays for extensions
  and skins, with $name => $loadingMechanism. Now there is only
  one (list) array with values array( $name, $type,
  $loadingMechanism, $initialOrder ), with $type == 'extension'
  or 'skin'. The order of this list is used to create
  the LocalSettings.php. This change is in preparation of
  Composer-managed extensions, to allow activation of some
  extensions before other (typically PageForms 4.0+ and
  SemanticFormsSelect).
* The extensions+skins list can be sorted. Currently it is sorted
  with the following order: require_once(skins), require_once(exts),
  wfLoadSkin, wfLoadExtension. The sorting is stable, so that
  it is possible to impose some order inside each category.

Code:
* The previous associative array is transformed in a list of tuples
  because standard PHP functions do not allow to sort by key *and*
  value (it’s key *xor* value). The new information $initialOrder
  is added to allow a stable sort (standard PHP sorting is not
  stable).

Change-Id: Idb60c537da3c99a9cdec7a80f31acaf597bcd1fa
---
M src/MediaWikiFarm.php
M src/main.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
5 files changed, 121 insertions(+), 115 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm 
refs/changes/23/329223/1

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5f5c309..7c544b5 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -73,7 +73,6 @@
protected $configuration = array(
'settings' => array(),
'arrays' => array(),
-   'skins' => array(),
'extensions' => array(),
'execFiles' => array(),
);
@@ -174,8 +173,7 @@
 * This associative array contains four sections:
 *   - 'settings': associative array of MediaWiki configuration (e.g. 
'wgServer' => '//example.org');
 *   - 'arrays': associative array of MediaWiki configuration of type 
array (e.g. 'wgGroupPermissions' => array( 'edit' => false ));
-*   - 'skins': associative array of skins configuration (e.g. 'Vector' 
=> 'wfLoadSkin' );
-*   - 'extensions': associative array of extensions configuration 
(e.g. 'ParserFunctions' => 'wfLoadExtension' );
+*   - 'extensions': list of extensions and skins (e.g. 0 => array( 
'ParserFunctions', 'extension', 'wfLoadExtension' ));
 *   - 'execFiles': list of PHP files to execute at the end.
 *
 * @mediawikifarm-const
@@ -360,30 +358,31 @@
$GLOBALS[$setting] = self::arrayMerge( 
$GLOBALS[$setting], $value );
}
 
-   # Load skins with the wfLoadSkin mechanism
-   foreach( $this->configuration['skins'] as $skin => $value ) {
+   # Load extensions and skins with the wfLoadExtension/wfLoadSkin 
mechanism
+   $loadMediaWikiFarm = false;
+   foreach( $this->configuration['extensions'] as $extension ) {
 
-   if( $value == 'wfLoadSkin' ) {
+   if( $extension[2] == 'wfLoadExtension' ) {
 
-   wfLoadSkin( $skin );
+   if( $extension[0] != 'MediaWikiFarm' || 
!$this->codeDir ) {
+   wfLoadExtension( $extension[0] );
+   } else {
+   wfLoadExtension( 'MediaWikiFarm', 
$this->farmDir . '/extension.json' );
+   $loadedMediaWikiFarm = true;
+   }
}
-   }
+   elseif( $extension[2] == 'wfLoadSkin' ) {
 
-   # Load extensions with the wfLoadExtension mechanism
-   foreach( $this->configuration['extensions'] as $extension => 
$value ) {
+   wfLoadSkin( $extension[0] );
+   }
+   elseif( $extension[0] == 'MediaWikiFarm' && 
$extension[1] == 'extension' && $extension[2] == 'require_once' ) {
 
-   if( $value == 'wfLoadExtension' && ( $extension != 
'MediaWikiFarm' || !$this->codeDir ) ) {
-
-   wfLoadExtension( $extension );
+   $loadMediaWikiFarm = true;
}
}
 
# Register this extension MediaWikiFarm to appear in 
Special:Version
-   if( $this->configuration['extensions']['MediaWikiFarm'] == 
'wfLoadExtension' && $this->codeDir ) {
-
-