[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Always check Composer extensions independantly of ExtensionR...

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

Change subject: Always check Composer extensions independantly of 
ExtensionRegistration
..


Always check Composer extensions independantly of ExtensionRegistration

Sometimes, when MediaWikiFarm is in monoversion mode, ExtensionRegistry
is known, and we should check if some extension should be loaded with
Composer; it was no more the case since ca185e0.

Also, the function MediaWikiFarmConfiguration::detectLoadingMechanism
no more tries to detect Composer extension given the case is handled
in an other way.

Change-Id: I6b1379826f698861d66016c836b3d867d2d85fec
---
M src/MediaWikiFarmConfiguration.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/LoadingTest.php
3 files changed, 17 insertions(+), 30 deletions(-)

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



diff --git a/src/MediaWikiFarmConfiguration.php 
b/src/MediaWikiFarmConfiguration.php
index 62d7eb6..a9d92f3 100644
--- a/src/MediaWikiFarmConfiguration.php
+++ b/src/MediaWikiFarmConfiguration.php
@@ -430,16 +430,13 @@
unset( $this->configuration['extensions'][$key] 
);
 
# Mechanism Composer wanted
-   } elseif( $value === 'composer' && 
$this->detectComposer( $type, $name ) ) {
+   } elseif( ( $value === 'composer' || $value === true ) 
&& $this->detectComposer( $type, $name ) ) {
$status = 'composer';
$value = true;
 
-   # MediaWiki still not loaded: we must wait before 
taking a decision except for Composer loading
+   # MediaWiki still not loaded: we must wait before 
taking a decision
} elseif( $ExtensionRegistry === null ) {
-   if( $this->detectComposer( $type, $name ) ) {
-   $status = 'composer';
-   $value = true;
-   }
+   # nop
 
# Mechanism require_once wanted
} elseif( $value === 'require_once' && 
$this->detectLoadingMechanism( $type, $name, true ) == $value ) {
@@ -529,10 +526,10 @@
 *
 * @param string $type Type, in ['extension', 'skin'].
 * @param string $name Name of the extension/skin.
-* @param string $preferedRO Prefered require_once mechanism.
-* @return string|null Loading mechnism in ['wfLoadExtension', 
'wfLoadSkin', 'require_once', 'composer'] or null if all mechanisms failed.
+* @param bool $preferedRO Prefered require_once mechanism.
+* @return string|null Loading mechnism in ['wfLoadExtension', 
'wfLoadSkin', 'require_once'] or null if all mechanisms failed.
 */
-   function detectLoadingMechanism( $type, $name, $preferedRO = null ) {
+   function detectLoadingMechanism( $type, $name, $preferedRO = false ) {
 
# Search base directory
$base = $this->farm->getVariable( '$CODE' ) . '/' . $type . 's';
@@ -555,11 +552,6 @@
# An extension.json/skin.json file is in the directory -> 
assume it is the loading mechanism
if( $this->environment['ExtensionRegistry'] && is_file( $base . 
'/' . $name . '/' . $type . '.json' ) ) {
return 'wfLoad' . ucfirst( $type );
-   }
-
-   # A composer.json file is in the directory and the extension is 
properly autoloaded by Composer
-   elseif( $this->detectComposer( $type, $name ) ) {
-   return 'composer';
}
 
# A MyExtension.php file is in the directory -> assume it is 
the loading mechanism
diff --git a/tests/phpunit/ConfigurationTest.php 
b/tests/phpunit/ConfigurationTest.php
index 67a10da..7ca59f1 100644
--- a/tests/phpunit/ConfigurationTest.php
+++ b/tests/phpunit/ConfigurationTest.php
@@ -276,11 +276,8 @@
 * @uses MediaWikiFarmConfiguration::detectComposer
 * @uses MediaWikiFarmConfiguration::setEnvironment
 * @uses MediaWikiFarmConfiguration::getConfiguration
-* @uses MediaWikiFarmConfiguration::setComposer
-* @uses AbstractMediaWikiFarmScript::rmdirr
-* @uses MediaWikiFarmUtils::arrayMerge
-* @uses MediaWikiFarmUtils::isMediaWiki
-* @uses MediaWikiFarmUtils::readFile
+* @uses AbstractMediaWikiFarmScript
+* @uses MediaWikiFarmUtils
 */
function testLoadMediaWikiConfigMultiversion() {
 
@@ -346,7 +343,6 @@
 * @uses MediaWikiFarm::readFile
 * @uses MediaWikiFarmConfiguration::__construct
 * @uses MediaWikiFarmConfiguration::getConfiguration
-* @uses MediaWikiFarmConfiguration::setComposer
 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Always check Composer extensions independantly of ExtensionR...

2017-09-24 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/380317 )

Change subject: Always check Composer extensions independantly of 
ExtensionRegistration
..

Always check Composer extensions independantly of ExtensionRegistration

Sometimes, when MediaWikiFarm is in monoversion mode, ExtensionRegistry
is known, and we should check if some extension should be loaded with
Composer; it was no more the case since ca185e0.

Also, the function MediaWikiFarmConfiguration::detectLoadingMechanism
no more tries to detect Composer extension given the case is handled
in an other way.

Change-Id: I6b1379826f698861d66016c836b3d867d2d85fec
---
M src/MediaWikiFarmConfiguration.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/LoadingTest.php
3 files changed, 17 insertions(+), 30 deletions(-)


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

diff --git a/src/MediaWikiFarmConfiguration.php 
b/src/MediaWikiFarmConfiguration.php
index 62d7eb6..a9d92f3 100644
--- a/src/MediaWikiFarmConfiguration.php
+++ b/src/MediaWikiFarmConfiguration.php
@@ -430,16 +430,13 @@
unset( $this->configuration['extensions'][$key] 
);
 
# Mechanism Composer wanted
-   } elseif( $value === 'composer' && 
$this->detectComposer( $type, $name ) ) {
+   } elseif( ( $value === 'composer' || $value === true ) 
&& $this->detectComposer( $type, $name ) ) {
$status = 'composer';
$value = true;
 
-   # MediaWiki still not loaded: we must wait before 
taking a decision except for Composer loading
+   # MediaWiki still not loaded: we must wait before 
taking a decision
} elseif( $ExtensionRegistry === null ) {
-   if( $this->detectComposer( $type, $name ) ) {
-   $status = 'composer';
-   $value = true;
-   }
+   # nop
 
# Mechanism require_once wanted
} elseif( $value === 'require_once' && 
$this->detectLoadingMechanism( $type, $name, true ) == $value ) {
@@ -529,10 +526,10 @@
 *
 * @param string $type Type, in ['extension', 'skin'].
 * @param string $name Name of the extension/skin.
-* @param string $preferedRO Prefered require_once mechanism.
-* @return string|null Loading mechnism in ['wfLoadExtension', 
'wfLoadSkin', 'require_once', 'composer'] or null if all mechanisms failed.
+* @param bool $preferedRO Prefered require_once mechanism.
+* @return string|null Loading mechnism in ['wfLoadExtension', 
'wfLoadSkin', 'require_once'] or null if all mechanisms failed.
 */
-   function detectLoadingMechanism( $type, $name, $preferedRO = null ) {
+   function detectLoadingMechanism( $type, $name, $preferedRO = false ) {
 
# Search base directory
$base = $this->farm->getVariable( '$CODE' ) . '/' . $type . 's';
@@ -555,11 +552,6 @@
# An extension.json/skin.json file is in the directory -> 
assume it is the loading mechanism
if( $this->environment['ExtensionRegistry'] && is_file( $base . 
'/' . $name . '/' . $type . '.json' ) ) {
return 'wfLoad' . ucfirst( $type );
-   }
-
-   # A composer.json file is in the directory and the extension is 
properly autoloaded by Composer
-   elseif( $this->detectComposer( $type, $name ) ) {
-   return 'composer';
}
 
# A MyExtension.php file is in the directory -> assume it is 
the loading mechanism
diff --git a/tests/phpunit/ConfigurationTest.php 
b/tests/phpunit/ConfigurationTest.php
index 67a10da..7ca59f1 100644
--- a/tests/phpunit/ConfigurationTest.php
+++ b/tests/phpunit/ConfigurationTest.php
@@ -276,11 +276,8 @@
 * @uses MediaWikiFarmConfiguration::detectComposer
 * @uses MediaWikiFarmConfiguration::setEnvironment
 * @uses MediaWikiFarmConfiguration::getConfiguration
-* @uses MediaWikiFarmConfiguration::setComposer
-* @uses AbstractMediaWikiFarmScript::rmdirr
-* @uses MediaWikiFarmUtils::arrayMerge
-* @uses MediaWikiFarmUtils::isMediaWiki
-* @uses MediaWikiFarmUtils::readFile
+* @uses AbstractMediaWikiFarmScript
+* @uses MediaWikiFarmUtils
 */
function testLoadMediaWikiConfigMultiversion() {
 
@@ -346,7 +343,6 @@
 * @uses MediaWikiFarm::readFile
 * @uses MediaWikiFarmConfiguration::__construct
 * @uses MediaWikiFarmConfiguration::getConfiguration
-* @uses