[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Don't use deprecated DatabaseMysql

2018-01-17 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404712 )

Change subject: Don't use deprecated DatabaseMysql
..

Don't use deprecated DatabaseMysql

Bug: T120333
Change-Id: Ice89b5aee20881b665f935acc8090cc4a91d4905
---
M repo/tests/phpunit/includes/Store/Sql/DatabaseSchemaUpdaterTest.php
M repo/tests/phpunit/includes/Store/Sql/WikiPageEntityRedirectLookupTest.php
2 files changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/12/404712/1

diff --git 
a/repo/tests/phpunit/includes/Store/Sql/DatabaseSchemaUpdaterTest.php 
b/repo/tests/phpunit/includes/Store/Sql/DatabaseSchemaUpdaterTest.php
index 6175cb6..1d08b4d 100644
--- a/repo/tests/phpunit/includes/Store/Sql/DatabaseSchemaUpdaterTest.php
+++ b/repo/tests/phpunit/includes/Store/Sql/DatabaseSchemaUpdaterTest.php
@@ -5,7 +5,7 @@
 use MysqlUpdater;
 use Wikibase\Repo\Store\Sql\DatabaseSchemaUpdater;
 use Wikibase\Store;
-use Wikimedia\Rdbms\DatabaseMysql;
+use Wikimedia\Rdbms\DatabaseMysqli;
 
 /**
  * @covers Wikibase\Repo\Store\Sql\DatabaseSchemaUpdater
@@ -24,7 +24,7 @@
public function testDoSchemaUpdate() {
$store = $this->getMock( Store::class );
 
-   $db = $this->getMockBuilder( DatabaseMysql::class )
+   $db = $this->getMockBuilder( DatabaseMysqli::class )
->disableOriginalConstructor()
->getMock();
 
diff --git 
a/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityRedirectLookupTest.php 
b/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityRedirectLookupTest.php
index 968a9ee..761e454 100644
--- a/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityRedirectLookupTest.php
+++ b/repo/tests/phpunit/includes/Store/Sql/WikiPageEntityRedirectLookupTest.php
@@ -8,7 +8,7 @@
 use Wikibase\DataModel\Services\Lookup\EntityRedirectLookupException;
 use Wikibase\Repo\Store\EntityTitleStoreLookup;
 use Wikibase\Store\EntityIdLookup;
-use Wikimedia\Rdbms\DatabaseMysql;
+use Wikimedia\Rdbms\DatabaseMysqli;
 use Wikimedia\Rdbms\LoadBalancer;
 use WikiPage;
 use Wikibase\DataModel\Entity\EntityId;
@@ -180,10 +180,10 @@
/**
 * @param array $row
 *
-* @return DatabaseMysql
+* @return DatabaseMysqli
 */
private function getMockDatabase( array $row ) {
-   $db = $this->getMockBuilder( DatabaseMysql::class )
+   $db = $this->getMockBuilder( DatabaseMysqli::class )
->disableOriginalConstructor()
->getMock();
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice89b5aee20881b665f935acc8090cc4a91d4905
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...OdbcDatabase[master]: Don't use deprecated DatabaseMysql

2018-01-16 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404543 )

Change subject: Don't use deprecated DatabaseMysql
..

Don't use deprecated DatabaseMysql

Bug: T120333
Change-Id: I6c2c37b6393848268f5f67a333c95819c149d337
---
M OdbcDatabase.body.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OdbcDatabase 
refs/changes/43/404543/1

diff --git a/OdbcDatabase.body.php b/OdbcDatabase.body.php
index 42da7c2..db76ba8 100644
--- a/OdbcDatabase.body.php
+++ b/OdbcDatabase.body.php
@@ -253,7 +253,7 @@
 * @param $fname string
 * @return false|array
 */
-   function indexInfo( $table, $index, $fname = 'DatabaseMysql::indexInfo' 
) {
+   function indexInfo( $table, $index, $fname = 
'DatabaseMysqli::indexInfo' ) {
/*
 * For now, always return false. Not sure how
 * to generically find this info using no

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c2c37b6393848268f5f67a333c95819c149d337
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OdbcDatabase
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...Flow[master]: Don't use deprecated DatabaseMysql

2018-01-16 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404541 )

Change subject: Don't use deprecated DatabaseMysql
..

Don't use deprecated DatabaseMysql

Bug: T120333
Change-Id: Ib24561d815d28ea5887a7bd5c598340e961b2f5b
---
M tests/phpunit/Data/Storage/RevisionStorageTest.php
M tests/phpunit/Repository/TreeRepositoryTest.php
M tests/phpunit/WatchedTopicItemsTest.php
3 files changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/41/404541/1

diff --git a/tests/phpunit/Data/Storage/RevisionStorageTest.php 
b/tests/phpunit/Data/Storage/RevisionStorageTest.php
index 59c95e8..7687f7f 100644
--- a/tests/phpunit/Data/Storage/RevisionStorageTest.php
+++ b/tests/phpunit/Data/Storage/RevisionStorageTest.php
@@ -156,7 +156,7 @@
 
// A rev ID will be added to $old and $new automatically.
protected function helperToTestUpdating( $old, $new, 
$expectedUpdateValues, $isContentUpdatingAllowed ) {
-   $dbw = $this->getMockBuilder( 'DatabaseMysql' )
+   $dbw = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->getMock();
$factory = $this->getMockBuilder( 'Flow\DbFactory' )
@@ -389,7 +389,7 @@
}
 
protected function mockDbFactory() {
-   $dbw = $this->getMockBuilder( 'DatabaseMysql' )
+   $dbw = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->getMock();
 
diff --git a/tests/phpunit/Repository/TreeRepositoryTest.php 
b/tests/phpunit/Repository/TreeRepositoryTest.php
index a4792bf..17771ea 100644
--- a/tests/phpunit/Repository/TreeRepositoryTest.php
+++ b/tests/phpunit/Repository/TreeRepositoryTest.php
@@ -5,7 +5,7 @@
 use Flow\Model\UUID;
 use Flow\Repository\TreeRepository;
 use Flow\Tests\FlowTestCase;
-use Wikimedia\Rdbms\DatabaseMysql;
+use Wikimedia\Rdbms\DatabaseMysqli;
 
 /**
  * @group Flow
@@ -46,7 +46,7 @@
}
 
protected function mockDb( $dbResult ) {
-   $db = $this->getMockBuilder( DatabaseMysql::class )
+   $db = $this->getMockBuilder( DatabaseMysqli::class )
->disableOriginalConstructor()
->getMock();
$db->expects( $this->any() )
diff --git a/tests/phpunit/WatchedTopicItemsTest.php 
b/tests/phpunit/WatchedTopicItemsTest.php
index e55c496..1453fc2 100644
--- a/tests/phpunit/WatchedTopicItemsTest.php
+++ b/tests/phpunit/WatchedTopicItemsTest.php
@@ -5,7 +5,7 @@
 use Flow\Model\UUID;
 use Flow\WatchedTopicItems;
 use User;
-use Wikimedia\Rdbms\DatabaseMysql;
+use Wikimedia\Rdbms\DatabaseMysqli;
 
 /**
  * @group Flow
@@ -72,7 +72,7 @@
}
 
protected function mockDb( $dbResult ) {
-   $db = $this->getMockBuilder( DatabaseMysql::class )
+   $db = $this->getMockBuilder( DatabaseMysqli::class )
->disableOriginalConstructor()
->getMock();
$db->expects( $this->any() )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib24561d815d28ea5887a7bd5c598340e961b2f5b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Remove support for PHP extension 'mysql' (not mysqli!)

2018-01-16 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404523 )

Change subject: Remove support for PHP extension 'mysql' (not mysqli!)
..

Remove support for PHP extension 'mysql' (not mysqli!)

This PHP extension was deprecated in PHP 5.5 and removed in PHP 7.0.
The newer MySQL driver 'mysqli' is the default driver since MediaWiki
1.22 and 'mysql' was deprecated in MediaWiki 1.30.

Bug: T120333
Change-Id: Icff7a63ab47ae1483de87ba6486945974699362b
---
M RELEASE-NOTES-1.31
M autoload.php
M includes/DefaultSettings.php
M includes/installer/MysqlInstaller.php
M includes/libs/rdbms/database/Database.php
D includes/libs/rdbms/database/DatabaseMysql.php
M tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php
7 files changed, 9 insertions(+), 218 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/23/404523/1

diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31
index fca71a7..b5cdb2c 100644
--- a/RELEASE-NOTES-1.31
+++ b/RELEASE-NOTES-1.31
@@ -166,6 +166,9 @@
   has been deprecated since 1.27 and was removed as well.
 * The HtmlFormatter class was removed (deprecated in 1.27). The namespaced
   HtmlFormatter\HtmlFormatter class should be used instead.
+* The driver 'mysql' for MySQL has been deprecated in 1.30 and is removed. It 
was itself
+  deprecated in PHP 5.5 and removed in PHP 7.0. The default driver for MySQL 
has
+  been 'mysqli' since 1.22.
 
 == Compatibility ==
 MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is 
supported,
diff --git a/autoload.php b/autoload.php
index 5d6104c..cc35dc3 100644
--- a/autoload.php
+++ b/autoload.php
@@ -345,7 +345,6 @@
'DatabaseLag' => __DIR__ . '/maintenance/lag.php',
'DatabaseLogEntry' => __DIR__ . '/includes/logging/LogEntry.php',
'DatabaseMssql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMssql.php',
-   'DatabaseMysql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysql.php',
'DatabaseMysqlBase' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqlBase.php',
'DatabaseMysqli' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqli.php',
'DatabaseOracle' => __DIR__ . '/includes/db/DatabaseOracle.php',
@@ -1673,7 +1672,6 @@
'Wikimedia\\Rdbms\\Database' => __DIR__ . 
'/includes/libs/rdbms/database/Database.php',
'Wikimedia\\Rdbms\\DatabaseDomain' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseDomain.php',
'Wikimedia\\Rdbms\\DatabaseMssql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMssql.php',
-   'Wikimedia\\Rdbms\\DatabaseMysql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysql.php',
'Wikimedia\\Rdbms\\DatabaseMysqlBase' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqlBase.php',
'Wikimedia\\Rdbms\\DatabaseMysqli' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqli.php',
'Wikimedia\\Rdbms\\DatabasePostgres' => __DIR__ . 
'/includes/libs/rdbms/database/DatabasePostgres.php',
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index ee10a6d..6dfbd6a 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -1940,6 +1940,7 @@
  *   - user:DB user
  *   - password:DB password
  *   - type:DB type
+ *   - driver:  DB driver (when there are multiple drivers)
  *
  *   - load:Ratio of DB_REPLICA load, must be >=0, the sum of all 
loads must be >0.
  *  If this is zero for any given server, no normal query 
traffic will be
diff --git a/includes/installer/MysqlInstaller.php 
b/includes/installer/MysqlInstaller.php
index ab5701a..6256204 100644
--- a/includes/installer/MysqlInstaller.php
+++ b/includes/installer/MysqlInstaller.php
@@ -73,7 +73,7 @@
 * @return bool
 */
public function isCompiled() {
-   return self::checkExtension( 'mysql' ) || self::checkExtension( 
'mysqli' );
+   return self::checkExtension( 'mysqli' );
}
 
/**
diff --git a/includes/libs/rdbms/database/Database.php 
b/includes/libs/rdbms/database/Database.php
index 2eb5c54..323c147 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -317,8 +317,8 @@
 *   - flags : Optional bitfield of DBO_* constants that define 
connection, protocol,
 *  buffering, and transaction behavior. It is STRONGLY adviced to 
leave the DBO_DEFAULT
 *  flag in place UNLESS this this database simply acts as a 
key/value store.
-*   - driver: Optional name of a specific DB client driver. For MySQL, 
there is the old
-*  'mysql' driver and the newer 'mysqli' driver.
+*   - driver: Optional name of a specific DB client driver. For MySQL, 
there is only the
+*  'mysqli' driver; the old one 'mysql' has been removed.
 *   

[MediaWiki-commits] [Gerrit] mediawiki...ApprovedRevs[master]: Error when displaying a blank page

2018-01-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404167 )

Change subject: Error when displaying a blank page
..

Error when displaying a blank page

When the content is set to blank for unapproved revisions, an error
was displayed instead since MediaWiki 1.31-alpha.

Bug: T18487
Change-Id: Idb16ca46f3a1ee7dd32c3925d9a985d0ba8193a3
---
M ApprovedRevs.hooks.php
1 file changed, 3 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ApprovedRevs 
refs/changes/67/404167/1

diff --git a/ApprovedRevs.hooks.php b/ApprovedRevs.hooks.php
index 6d35378..4f6097f 100644
--- a/ApprovedRevs.hooks.php
+++ b/ApprovedRevs.hooks.php
@@ -203,7 +203,7 @@
return true;
}
 
-   public static function showBlankIfUnapproved( &$article, &$content ) {
+   public static function showBlankIfUnapproved( &$article, Content 
&$content ) {
global $egApprovedRevsBlankIfUnapproved;
if ( ! $egApprovedRevsBlankIfUnapproved ) {
return true;
@@ -236,16 +236,7 @@
ApprovedRevs::addCSS();
 
// Set the content to blank.
-   // There's possibly a bug in MW 1.28, where the second argument
-   // (called from the hook 'ArticleAfterFetchContentObject') is
-   // sometimes (or always?) a string, instead of a Content object.
-   // We'll just get around it here with a check. (In theory, 
$content
-   // could also be null, so this check is a good idea anyway.)
-   if ( is_object( $content ) ) {
-   $content->mText = '';
-   } else {
-   $content = '';
-   }
+   $content = new WikitextContent( '' );
 
return true;
}
@@ -950,4 +941,4 @@
$qp['SpecialApprovedRevsPage'] = 'ApprovedRevs';
return true;
}
-}
\ No newline at end of file
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb16ca46f3a1ee7dd32c3925d9a985d0ba8193a3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ApprovedRevs
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improve discoverability of $wgMediaWikiFarmSyslog

2017-12-04 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394993 )

Change subject: Improve discoverability of $wgMediaWikiFarmSyslog
..

Improve discoverability of $wgMediaWikiFarmSyslog

Particularly for monoversion case, $wgMediaWikiFarmSyslog is included in the
template config file, hence people will be aware some things are logged through
syslog. Also tread $wgMediaWikiFarmSyslog === null similarly to === false,
hence when people remove this config parameter it will not spam the logs (and
now it is pretty sure they ''knowingly'' remove this config parameter).

Bug: T181212
Change-Id: Ie68cd1260416c2ef22eaa475717781f5183841ca
---
M docs/config/LocalSettings.php
M src/MediaWikiFarm.php
2 files changed, 7 insertions(+), 1 deletion(-)


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

diff --git a/docs/config/LocalSettings.php b/docs/config/LocalSettings.php
index 5af9feb..2f8e644 100644
--- a/docs/config/LocalSettings.php
+++ b/docs/config/LocalSettings.php
@@ -9,9 +9,15 @@
 }
 
 // Configuration directory.
+// Type: string
 // There must be a file 'farms.yml' or 'farms.php' or 'farms.json' inside.
 $wgMediaWikiFarmConfigDir = '/etc/mediawiki';
 
+// Syslog tag.
+// Type: string|false
+$wgMediaWikiFarmSyslog = 'mediawikifarm';
+
+
 # Include the code.
 require "$IP/extensions/MediaWikiFarm/MediaWikiFarm.php";
 
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 71596cd..cf7438e 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -602,7 +602,7 @@
static function prepareLog( $wgMediaWikiFarmSyslog, $wgMediaWikiFarm, 
$exception = null ) {
 
$log = array();
-   if( $wgMediaWikiFarmSyslog === false ) {
+   if( $wgMediaWikiFarmSyslog === false || $wgMediaWikiFarmSyslog 
=== null ) {
return $log;
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie68cd1260416c2ef22eaa475717781f5183841ca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Alternative declaration of wikis for small setups

2017-12-04 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394974 )

Change subject: Alternative declaration of wikis for small setups
..

Alternative declaration of wikis for small setups

This was suggested in T181212 and will improve the first experience
with MediaWikiFarm, but could be also useful for small setups.

Bug: T181212
Change-Id: I314e1a953d53b0540a8c78ec8e01aaddebd95c85
---
M src/MediaWikiFarm.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/data/config/farms.php
3 files changed, 56 insertions(+), 12 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 365cbf8..71596cd 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -929,21 +929,27 @@
}
$value = $this->variables[ '$' . strtolower( $key ) ];
 
-   # If every values are correct, continue
-   if( !array_key_exists( 'file', $variable ) || 
!is_string( $variable['file'] ) ) {
+   # Get the values
+   if( array_key_exists( 'file', $variable ) && is_string( 
$variable['file'] ) ) {
+
+   # Really check if the variable is in the 
listing file
+   $filename = $this->replaceVariables( 
$variable['file'] );
+   $choices = $this->readFile( $filename, 
$this->configDir );
+   if( $choices === false ) {
+   throw new MWFConfigurationException( 
'Missing or badly formatted file \'' . $variable['file'] .
+   '\' defining existing values 
for variable \'' . $key . '\''
+   );
+   }
+   $this->farmConfig['coreconfig'][] = $filename;
+
+   } elseif( array_key_exists( 'values', $variable ) && 
is_array( $variable['values'] ) ) {
+
+   $choices = $variable['values'];
+
+   } else {
$explicitExistence = 
$explicitExistenceUnderScrutiny ? false : $explicitExistence;
continue;
}
-
-   # Really check if the variable is in the listing file
-   $filename = $this->replaceVariables( $variable['file'] 
);
-   $choices = $this->readFile( $filename, $this->configDir 
);
-   if( $choices === false ) {
-   throw new MWFConfigurationException( 'Missing 
or badly formatted file \'' . $variable['file'] .
-   '\' defining existing values for 
variable \'' . $key . '\''
-   );
-   }
-   $this->farmConfig['coreconfig'][] = $filename;
 
# Check if the array is a simple list of wiki 
identifiers without version information…
if( array_keys( $choices ) === range( 0, count( 
$choices ) - 1 ) ) {
diff --git a/tests/phpunit/MonoversionInstallationTest.php 
b/tests/phpunit/MonoversionInstallationTest.php
index baf9435..9244abe 100644
--- a/tests/phpunit/MonoversionInstallationTest.php
+++ b/tests/phpunit/MonoversionInstallationTest.php
@@ -169,6 +169,24 @@
}
 
/**
+* Test a existing host in a farm with a “values” variable without 
version defined inside.
+*/
+   function testVariableValuesWithoutVersion() {
+
+   $farm = self::constructMediaWikiFarm( 
'a.testfarm-monoversion-with-values-variable-without-version.example.org' );
+   $this->assertTrue( $farm->checkExistence() );
+   }
+
+   /**
+* Test a nonexistant host in a farm with a “values” variable without 
version defined inside.
+*/
+   function testVariableValuesWithoutVersionNonexistant() {
+
+   $farm = self::constructMediaWikiFarm( 
'c.testfarm-monoversion-with-values-variable-without-version.example.org' );
+   $this->assertFalse( $farm->checkExistence() );
+   }
+
+   /**
 * Test a existing host in a farm with a file variable with version 
defined inside.
 */
function testVariableFileWithVersion() {
diff --git a/tests/phpunit/data/config/farms.php 
b/tests/phpunit/data/config/farms.php
index c90206d..88d4ead 100644
--- a/tests/phpunit/data/config/farms.php
+++ b/tests/phpunit/data/config/farms.php
@@ -134,6 +134,26 @@
),
),
 
+   'testfarm-monoversion-with-values-variable-without-version' => array(
+
+   'server' => 

[MediaWiki-commits] [Gerrit] mediawiki...Arrays[master]: Use dedicated functions for i18n

2017-11-29 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394032 )

Change subject: Use dedicated functions for i18n
..

Use dedicated functions for i18n

A specific call triggers a 'Sessions are disabled for this entry point'
exception in load.php. This fix replaces by an equivalent function.

By the way, it is used here the '''content language''' and not the user
language, which is better else the result could be misinterpreted depending
on the user language.

Change-Id: Icc69115758c2ac0b5d0c87c855187e5d24559caf
---
M Arrays.php
1 file changed, 1 insertion(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Arrays 
refs/changes/32/394032/1

diff --git a/Arrays.php b/Arrays.php
index fc9e7df..a04de8a 100644
--- a/Arrays.php
+++ b/Arrays.php
@@ -104,9 +104,7 @@
}
else {
// since 2.0 the default separator for arrayprint is 
set to the languages default
-   global $wgLang;
-   $wgLang->getMessageFromDB( 'comma-separator' );
-   self::$mDefaultSep = $wgLang->getMessageFromDB( 
'comma-separator' );
+   self::$mDefaultSep = wfMessage( 'comma-separator' 
)->inContentLanguage()->text();
}
 
// Parser::SFH_OBJECT_ARGS available since MW 1.12

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc69115758c2ac0b5d0c87c855187e5d24559caf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Arrays
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...WikiEditor[master]: Cancel button returns Undefined error

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

Change subject: Cancel button returns Undefined error
..

Cancel button returns Undefined error

The associated HTML changed in MediaWiki commit 97d7de0b.

Bug: T177313
Change-Id: I360fbd375efd7090256626df3fce418a5aa45ac2
---
M modules/jquery.wikiEditor.publish.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiEditor 
refs/changes/82/393282/1

diff --git a/modules/jquery.wikiEditor.publish.js 
b/modules/jquery.wikiEditor.publish.js
index b2ec8c6..a46da23 100644
--- a/modules/jquery.wikiEditor.publish.js
+++ b/modules/jquery.wikiEditor.publish.js
@@ -152,7 +152,7 @@
context.fn.addButton( {
captionMsg: 
'wikieditor-publish-button-cancel',
action: function () {
-   window.location.href = $( 
'#mw-editform-cancel' ).attr( 'href' );
+   window.location.href = $( 
'#mw-editform-cancel a' ).attr( 'href' );
return false;
}
} );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I360fbd375efd7090256626df3fce418a5aa45ac2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiEditor
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...HitCounters[master]: Fix {{NUMBEROFVIEWS}} in MediaWiki 1.29

2017-11-22 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393010 )

Change subject: Fix {{NUMBEROFVIEWS}} in MediaWiki 1.29
..

Fix {{NUMBEROFVIEWS}} in MediaWiki 1.29

The function CoreParserFunctions::formatRaw now has a third parameter.

Bug: T142127
Change-Id: I982d684618e32333fb63b05a8c8a6379531d2a8b
---
M includes/HitCounters.body.php
M includes/HitCounters.hooks.php
2 files changed, 6 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/HitCounters 
refs/changes/10/393010/1

diff --git a/includes/HitCounters.body.php b/includes/HitCounters.body.php
index 2f5bd62..173e0c3 100644
--- a/includes/HitCounters.body.php
+++ b/includes/HitCounters.body.php
@@ -93,7 +93,7 @@
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
public static function numberOfViews(
-   Parser &$parser, PPFrame $frame, $args
+   Parser $parser, PPFrame $frame, $args
) {
return self::views();
}
@@ -104,7 +104,7 @@
 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
 */
public static function numberOfPageViews(
-   Parser &$parser, PPFrame $frame, $args
+   Parser $parser, PPFrame $frame, $args
) {
return self::getCount( $frame->title );
}
diff --git a/includes/HitCounters.hooks.php b/includes/HitCounters.hooks.php
index 1d5105f..e13d5af 100644
--- a/includes/HitCounters.hooks.php
+++ b/includes/HitCounters.hooks.php
@@ -101,7 +101,10 @@
if ( $magicWord === $magicWordId ) {
if ( !$wgDisableCounters ) {
$ret = CoreParserFunctions::formatRaw(
-   call_user_func( 
$processingFunction, $parser, $frame, null ), null );
+   call_user_func( 
$processingFunction, $parser, $frame, null ),
+   null,
+   $parser->getFunctionLang()
+   );
return true;
} else {
wfDebugLog( 'HitCounters', 'Counters 
are disabled!' );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I982d684618e32333fb63b05a8c8a6379531d2a8b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/HitCounters
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Enumerate all known wikis

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

Change subject: Enumerate all known wikis
..

Enumerate all known wikis

A CLI script is added to output the list of wikis known by MediaWikiFarm
in its configuration files. This is achieved by reading the server
regexes, reading the values of the variables, and re-creating the URLs.
Thanks to the previous commit c8124a3 all wikis are always explicitely
known, hence this method will create exhaustive lists, except one
mechanism is not currently implemented in this feature (the “versions”
mechanism).

A class MediaWikiFarmList is created for this feature; this is the “model”
class for this feature.

It should be added in the future an extension in mwscript.php to run a
MediaWiki script on all or part of a farm; a difficulty to take into account
is that independant scripts must be launched (not in the current PHP script)
because wikis are possibly in different MediaWiki versions and it could
create “redefinition of classes” errors.

Bug: T162737
Change-Id: I48a0898160d6aab0338c29d7e9ddca24c81d81df
---
M .gitignore
A bin/mwlistwikis.php
M extension.json
M src/Hooks.php
A src/List.php
A src/bin/ScriptListWikis.php
A tests/phpunit/ListTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/bin/MediaWikiFarmScriptComposerTest.php
A tests/phpunit/bin/ScriptListWikisTest.php
A tests/phpunit/data/config2/farms.php
A tests/phpunit/data/config2/varwiki.php
A tests/phpunit/data/config2/varwikibis.php
A tests/phpunit/data/config2/versions.php
A tests/phpunit/data/config2/versionster.php
15 files changed, 616 insertions(+), 3 deletions(-)


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

diff --git a/.gitignore b/.gitignore
index 050dc52..35a9671 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@
 /tests/phpunit/data/config/empty.json
 /tests/phpunit/data/config/testdeploymentsfarmversions.php
 /tests/phpunit/data/mediawiki/vstub3
+/tests/phpunit/data/readAnyFile/badsyntax.json
 
 # Compiled code documentation
 /docs/code
diff --git a/bin/mwlistwikis.php b/bin/mwlistwikis.php
new file mode 100644
index 000..2aebc18
--- /dev/null
+++ b/bin/mwlistwikis.php
@@ -0,0 +1,27 @@
+load();
+
+if( !$wgMediaWikiFarmScriptListWikis->main() ) {
+   exit( $wgMediaWikiFarmScriptListWikis->status );
+}
+// @codeCoverageIgnoreEnd
diff --git a/extension.json b/extension.json
index 2b317ab..550823a 100644
--- a/extension.json
+++ b/extension.json
@@ -31,10 +31,13 @@
"MediaWikiFarm": "src/MediaWikiFarm.php",
"MediaWikiFarmConfiguration": 
"src/MediaWikiFarmConfiguration.php",
"AbstractMediaWikiFarmScript": 
"src/bin/AbstractMediaWikiFarmScript.php",
+   "MediaWikiFarmHooks": "src/Hooks.php",
+   "MediaWikiFarmList": "src/List.php",
"MediaWikiFarmScript": "src/bin/MediaWikiFarmScript.php",
+   "MediaWikiFarmScriptComposer": 
"src/bin/MediaWikiFarmScriptComposer.php",
+   "MediaWikiFarmScriptListWikis": "src/bin/ScriptListWikis.php",
"MediaWikiFarmUtils": "src/Utils.php",
"MediaWikiFarmUtils5_3": "src/Utils5_3.php",
-   "MediaWikiFarmHooks": "src/Hooks.php",
"MWFConfigurationException": "src/MediaWikiFarm.php"
},
"manifest_version": 1
diff --git a/src/Hooks.php b/src/Hooks.php
index 946c6ca..9441d85 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -3,7 +3,6 @@
  * Class MediaWikiFarmHooks.
  *
  * @package MediaWikiFarm
- * @author Sébastien Beyou ~ Seb35 
  * @license GPL-3.0+ GNU General Public License v3.0, or (at your option) any 
later version.
  * @license AGPL-3.0+ GNU Affero General Public License v3.0, or (at your 
option) any later version.
  */
@@ -34,12 +33,14 @@
$files[] = $dir . 'FunctionsTest.php';
$files[] = $dir . 'HooksTest.php';
$files[] = $dir . 'InstallationIndependantTest.php';
+   $files[] = $dir . 'ListTest.php';
$files[] = $dir . 'LoadingTest.php';
$files[] = $dir . 'LoggingTest.php';
$files[] = $dir . 'MonoversionInstallationTest.php';
$files[] = $dir . 'MultiversionInstallationTest.php';
$files[] = $dir . 'bin/MediaWikiFarmScriptComposerTest.php';
$files[] = $dir . 'bin/MediaWikiFarmScriptTest.php';
+   $files[] = $dir . 'bin/ScriptListWikisTest.php';
 
return true;
}
diff --git a/src/List.php b/src/List.php
new file mode 100644
index 000..5761700
--- /dev/null
+++ b/src/List.php
@@ -0,0 +1,195 @@
+configDir = $configDir;
+   $this->cacheDir = $cacheDir;
+   $log = array();
+
+   list( $this->farms, /* unused */ ) = 
MediaWikiFarmUtils::readAnyFile( 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: New function readAnyFile to read a file with any extension

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

Change subject: New function readAnyFile to read a file with any extension
..

New function readAnyFile to read a file with any extension

This is mainly used for the main config file farms.yml/.php/.json and will
be useful to implement T162737.

Also starting with this commit I will try to tag new tests (and possibly
some old tests) with “[unit]” when it is clearly a unit test (=assumes the
underlying functions are blackboxes and supposed to work as described) and
“[integration]” when it clearly test an entire stack. This is a step
forward to separate unit and integration tests (T162686).

Also starting with this commit it is recommended to use "@uses ClassName"
instead of "@uses ClassName::methodName" to reduce the burden of maintenance
on the tests. This does not cover "@covers" annotations, which must stay
"@covers ClassName::methodName".

I will document these test-related changes on
https://www.mediawiki.org/wiki/Extension:MediaWikiFarm and subpages.

Change-Id: If01341da9fd6d099baadb61bf51d86eadbbfc919
---
M src/MediaWikiFarm.php
M src/Utils.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/LoggingTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
M tests/phpunit/bin/MediaWikiFarmScriptTest.php
A tests/phpunit/data/readAnyFile/success.json
A tests/phpunit/data/readAnyFile/success.php
13 files changed, 215 insertions(+), 65 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 7b6cb5e..365cbf8 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -837,17 +837,12 @@
 
# Read the farms configuration
if( !$farms ) {
-   // @codingStandardsIgnoreStart 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
-   if( $farms = $this->readFile( 'farms.yml', 
$this->configDir ) ) {
-   $this->farmConfig['coreconfig'][] = 'farms.yml';
-   } elseif( $farms = $this->readFile( 'farms.php', 
$this->configDir ) ) {
-   $this->farmConfig['coreconfig'][] = 'farms.php';
-   } elseif( $farms = $this->readFile( 'farms.json', 
$this->configDir ) ) {
-   $this->farmConfig['coreconfig'][] = 
'farms.json';
+   list( $farms, $file ) = 
MediaWikiFarmUtils::readAnyFile( 'farms', $this->configDir, $this->cacheDir, 
$this->log );
+   if( $file ) {
+   $this->farmConfig['coreconfig'][] = $file;
} else {
return array( 'host' => $host, 'farm' => false, 
'config' => false, 'variables' => false, 'farms' => false, 'redirects' => 
$redirects );
}
-   // @codingStandardsIgnoreEnd 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
}
 
# For each proposed farm, check if the host matches
diff --git a/src/Utils.php b/src/Utils.php
index 46a1ea9..dcb31ff 100644
--- a/src/Utils.php
+++ b/src/Utils.php
@@ -194,6 +194,36 @@
}
 
/**
+* Read a file with any of the listed extensions.
+*
+* If multiple files exist with different extensions, the first 
(without syntax error)
+* in the extensions list is returned. If some previous files had 
syntax errors, these
+* syntax errors appear in the log.
+*
+* The available extensions are listed in the function 
MediaWikiFarmUtils::readFile.
+*
+* @param string $filename File name without the extension.
+* @param string $directory Directory containing the file.
+* @param string $cacheDir Cache directory.
+* @param string[] $log Error log.
+* @param string[] $formats List of possible extensions of the file.
+* @param bool $cache The successfully file read must be cached.
+* @return array 2-tuple with the result (array) and file read 
(string); in case no files were found, the second value is an empty string.
+*/
+   static function readAnyFile( $filename, $directory, $cacheDir, array 
&$log, $formats = array( 'yml', 'php', 'json' ), $cache = true ) {
+
+   foreach( $formats as $format ) {
+
+   $array = self::readFile( $filename . '.' . $format, 
$cacheDir, $log, $directory, $cache );
+   if( is_array( $array ) ) {
+   

[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 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Bug: Relaunch the tests before 5 minutes removed some coverage

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

Change subject: Bug: Relaunch the tests before 5 minutes removed some coverage
..

Bug: Relaunch the tests before 5 minutes removed some coverage

Given a test touch the mtime of a file with 5 minutes in the future,
the next launch before 5 minutes elapsed lacked some coverage. Resetting
the mtime to its original value at the end of the test.

PS: commit sent from a French train TGV :)

Change-Id: I2808e3d22a70cb4cdff3e09f315915a5687cddb1
---
M tests/phpunit/MultiversionInstallationTest.php
1 file changed, 5 insertions(+), 2 deletions(-)


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

diff --git a/tests/phpunit/MultiversionInstallationTest.php 
b/tests/phpunit/MultiversionInstallationTest.php
index 4a0186e..5ff1323 100644
--- a/tests/phpunit/MultiversionInstallationTest.php
+++ b/tests/phpunit/MultiversionInstallationTest.php
@@ -512,8 +512,8 @@
# Read the existence cache
$farm = new MediaWikiFarm( 
'a.testfarm-multiversion.example.org', null,
   self::$wgMediaWikiFarmConfigDir, 
self::$wgMediaWikiFarmCodeDir, self::$wgMediaWikiFarmCacheDir,
-  array( 'EntryPoint' => 'index.php' )
-   );
+  array( 'EntryPoint' => 'index.php' )
+   );
 
$this->assertTrue( $farm->checkExistence() );
 
@@ -538,6 +538,9 @@
   array( 'EntryPoint' => 'index.php' )
);
$this->assertFalse( is_file( self::$wgMediaWikiFarmCacheDir . 
'/LocalSettings/a.testfarm-multiversion.example.org.php' ) );
+
+   # Reinit mtime of farms.php for further tests
+   $this->assertTrue( touch( self::$wgMediaWikiFarmConfigDir . 
'/farms.php', time() - 5 ) );
}
 
/**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2808e3d22a70cb4cdff3e09f315915a5687cddb1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Bug: Composer extensions were no more loaded

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

Change subject: Bug: Composer extensions were no more loaded
..

Bug: Composer extensions were no more loaded

When fixing T168807 in 442efe5, it was mistakenly removed the loading
through Composer in early loading ($ExtensionRegistry === null). Only
Composer loading should be checked during this stage.

Change-Id: Id3a611c47a56d4feaf6516a2d455325076ce2684
---
M src/MediaWikiFarmConfiguration.php
1 file changed, 5 insertions(+), 2 deletions(-)


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

diff --git a/src/MediaWikiFarmConfiguration.php 
b/src/MediaWikiFarmConfiguration.php
index 9d70f51..62d7eb6 100644
--- a/src/MediaWikiFarmConfiguration.php
+++ b/src/MediaWikiFarmConfiguration.php
@@ -434,9 +434,12 @@
$status = 'composer';
$value = true;
 
-   # MediaWiki still not loaded: we must wait before 
taking a decision
+   # MediaWiki still not loaded: we must wait before 
taking a decision except for Composer loading
} elseif( $ExtensionRegistry === null ) {
-   # nop
+   if( $this->detectComposer( $type, $name ) ) {
+   $status = 'composer';
+   $value = true;
+   }
 
# Mechanism require_once wanted
} elseif( $value === 'require_once' && 
$this->detectLoadingMechanism( $type, $name, true ) == $value ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3a611c47a56d4feaf6516a2d455325076ce2684
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Add LICENSE

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

Change subject: Add LICENSE
..

Add LICENSE

Bug: T123943
Change-Id: If1285cc848734b24f579190ae03d1e22d1f8aa1e
---
A LICENSE
1 file changed, 674 insertions(+), 0 deletions(-)


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

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000..94a9ed0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. 
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+   TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Improve GitInfo for reading packed refs

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

Change subject: Improve GitInfo for reading packed refs
..

Improve GitInfo for reading packed refs

GitInfo only reads branches in files /refs/heads/*; it should also
read those in /.git/packed-refs.

Bug: T155747
Change-Id: Icccdf3ec797788582f836e2d8e267a1d714d50dc
---
M includes/GitInfo.php
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/23/378223/1

diff --git a/includes/GitInfo.php b/includes/GitInfo.php
index 4351acc..3c600ed 100644
--- a/includes/GitInfo.php
+++ b/includes/GitInfo.php
@@ -191,8 +191,14 @@
} else {
// If not a SHA1 it may be a ref:
$refFile = "{$this->basedir}/{$head}";
+   $packedRefs = "{$this->basedir}/packed-refs";
+   $headRegex = preg_quote( $head, '/' );
if ( is_readable( $refFile ) ) {
$sha1 = rtrim( file_get_contents( 
$refFile ) );
+   } elseif ( is_readable( $packedRefs ) &&
+   preg_match( "/^([0-9A-Fa-f]{40}) 
$headRegex$/m", file_get_contents( $packedRefs ), $matches )
+   ) {
+   $sha1 = $matches[1];
}
}
$this->cache['headSHA1'] = $sha1;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icccdf3ec797788582f836e2d8e267a1d714d50dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improved reading of config files

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

Change subject: Improved reading of config files
..

Improved reading of config files

1. The cached files are always prefered over the origin files, even for the
   files in .php or .ser format.
2. An additional safeguard is in place for PHP files in case of parsing
   errors; this will only work for PHP 7+, but is compatible with PHP 5.2.
3. Avoid edge cases when the origin file and the cached file have the same
   timestamp: possibly the cached file has an old version and there is no
   mean to know this fact (I guess I/O are sometimes written in batch with
   the same timestamp, explaining this fact).

Change-Id: Ia76d2ad46f9f3124da8e681c73de275d0da579ef
---
M .gitignore
M src/Utils.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MultiversionInstallationTest.php
5 files changed, 39 insertions(+), 13 deletions(-)


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

diff --git a/.gitignore b/.gitignore
index 07aae69..050dc52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@
 # Tests
 /phpunitHTTP404.php
 /tests/perfs/results
+/tests/phpunit/data/config/badsyntax.php
 /tests/phpunit/data/config/badsyntax.json
 /tests/phpunit/data/config/deployments.php
 /tests/phpunit/data/config/empty.json
diff --git a/src/Utils.php b/src/Utils.php
index 59125c8..46a1ea9 100644
--- a/src/Utils.php
+++ b/src/Utils.php
@@ -46,10 +46,20 @@
$format = null;
}
 
-   # Format PHP
-   if( $format == '.php' ) {
+   # Cached version - avoid the case where the timestamps are the 
same, the two files could have non-coherent versions
+   if( $cachedFile && is_string( $format ) && is_file( $cachedFile 
) && filemtime( $cachedFile ) > filemtime( $prefixedFile ) ) {
 
-   $array = include $prefixedFile;
+   return self::readFile( $filename . '.php', $cacheDir, 
$log, $cacheDir . '/config', false );
+   }
+
+   # Format PHP
+   elseif( $format == '.php' ) {
+
+   try {
+   $array = @include $prefixedFile;
+   } catch( Throwable $e ) {
+   $array = null;
+   }
}
 
# Format 'serialisation'
@@ -63,12 +73,6 @@
else {
$array = unserialize( $content );
}
-   }
-
-   # Cached version
-   elseif( $cachedFile && is_string( $format ) && is_file( 
$cachedFile ) && filemtime( $cachedFile ) >= filemtime( $prefixedFile ) ) {
-
-   return self::readFile( $filename . '.php', $cacheDir, 
$log, $cacheDir . '/config', false );
}
 
# Format YAML
@@ -136,7 +140,8 @@
# Regular return for arrays
if( is_array( $array ) ) {
 
-   if( $cachedFile && $directory != $cacheDir . '/config' 
&& ( !is_file( $cachedFile ) || ( filemtime( $cachedFile ) < filemtime( 
$prefixedFile ) ) ) ) {
+   # Cache this version - avoid the case where the 
timestamps are the same, the two files could have non-coherent versions
+   if( $cachedFile && $directory != $cacheDir . '/config' 
&& ( !is_file( $cachedFile ) || ( filemtime( $cachedFile ) <= filemtime( 
$prefixedFile ) ) ) ) {
self::cacheFile( $array, $filename . '.php', 
$cacheDir . '/config' );
}
 
diff --git a/tests/phpunit/InstallationIndependantTest.php 
b/tests/phpunit/InstallationIndependantTest.php
index 250fd61..ea1b88a 100644
--- a/tests/phpunit/InstallationIndependantTest.php
+++ b/tests/phpunit/InstallationIndependantTest.php
@@ -242,6 +242,21 @@
}
 
/**
+* Test reading a badly-formatted PHP file.
+*
+* @requires PHP 7.0
+* @covers MediaWikiFarm::readFile
+* @covers MediaWikiFarmUtils::readFile
+* @uses MediaWikiFarm::__construct
+* @uses MediaWikiFarm::selectFarm
+*/
+   function testBadSyntaxFileReadingPHP() {
+
+   $result = $this->farm->readFile( 'badsyntax.php', 
self::$wgMediaWikiFarmConfigDir );
+   $this->assertFalse( $result );
+   }
+
+   /**
 * Test reading a badly-formatted YAML file.
 *
 * @covers MediaWikiFarm::readFile
@@ -342,7 +357,9 @@
 
$farm = new MediaWikiFarm( 
'a.testfarm-monoversion.example.org', null, self::$wgMediaWikiFarmConfigDir, 
null, self::$wgMediaWikiFarmCacheDir );
 
+   # Simulate an old origin file, so that the cached version 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Fix MW-CS to a fixed version

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

Change subject: Fix MW-CS to a fixed version
..

Fix MW-CS to a fixed version

Change-Id: I9c0c6dc09b07100f3d2b64be27f301dcc0b98c6b
---
M composer.json
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/composer.json b/composer.json
index b9b93f9..f24c940 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,7 @@
"phpunit/phpunit": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"jakub-onderka/php-parallel-lint": "*",
"phpmd/phpmd": "*",
-   "mediawiki/mediawiki-codesniffer": "*",
+   "mediawiki/mediawiki-codesniffer": "~0.12.0",
"jakub-onderka/php-console-highlighter": "0.3.2"
},
"suggest": {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c0c6dc09b07100f3d2b64be27f301dcc0b98c6b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Use xxx.php as an alias of maintenance/xxx.php

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

Change subject: Use xxx.php as an alias of maintenance/xxx.php
..

Use xxx.php as an alias of maintenance/xxx.php

Previously only xxx was an alias of maintenance/xxx.php.

Change-Id: I3330d47cf901f5f1e37f97e41ebd4a23d17444e4
---
M src/bin/MediaWikiFarmScript.php
M tests/phpunit/bin/MediaWikiFarmScriptTest.php
2 files changed, 3 insertions(+), 5 deletions(-)


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

diff --git a/src/bin/MediaWikiFarmScript.php b/src/bin/MediaWikiFarmScript.php
index 1262fe8..49a902f 100644
--- a/src/bin/MediaWikiFarmScript.php
+++ b/src/bin/MediaWikiFarmScript.php
@@ -95,11 +95,9 @@
 
# Get script
$this->script = $this->getParam( 1, false );
-   if( preg_match( '/^[a-zA-Z-]+$/', $this->script ) ) {
-   $this->script = 'maintenance/' . $this->script . '.php';
-   }
+   $this->script = preg_replace( '/^([a-zA-Z0-9-]+)(\.php)?$/', 
'maintenance/$1.php', $this->script );
 
-   if( is_null( $this->script ) ) {
+   if( !$this->script ) {
$this->usage();
$this->status = 4;
return false;
diff --git a/tests/phpunit/bin/MediaWikiFarmScriptTest.php 
b/tests/phpunit/bin/MediaWikiFarmScriptTest.php
index 461975b..50e0370 100644
--- a/tests/phpunit/bin/MediaWikiFarmScriptTest.php
+++ b/tests/phpunit/bin/MediaWikiFarmScriptTest.php
@@ -288,7 +288,7 @@
$wgMediaWikiFarmScript->main();
 
$this->assertEquals( 4, $wgMediaWikiFarmScript->status );
-   $this->assertNull( $wgMediaWikiFarmScript->script );
+   $this->assertEquals( '', $wgMediaWikiFarmScript->script );
$this->assertEquals( 1, $wgMediaWikiFarmScript->argc );
$this->assertEquals( array( self::$mwscriptPath ), 
$wgMediaWikiFarmScript->argv );
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3330d47cf901f5f1e37f97e41ebd4a23d17444e4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Always verify an extension exists, even if the mechanism is ...

2017-08-26 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374034 )

Change subject: Always verify an extension exists, even if the mechanism is 
forced
..

Always verify an extension exists, even if the mechanism is forced

When an extension is loaded with a forced mechanism, it was not verified the
extension really exists; it is now the case.

Bug: T168807
Change-Id: I8146406a9a5139b8d86dcffd18c342fc16a2b94c
---
M src/MediaWikiFarmConfiguration.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/data/config/extensionssettings.php
3 files changed, 40 insertions(+), 19 deletions(-)


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

diff --git a/src/MediaWikiFarmConfiguration.php 
b/src/MediaWikiFarmConfiguration.php
index 458a247..9d70f51 100644
--- a/src/MediaWikiFarmConfiguration.php
+++ b/src/MediaWikiFarmConfiguration.php
@@ -424,32 +424,45 @@
$setting = 'wgUse' . preg_replace( 
'/[^a-zA-Z0-9_\x7f\xff]/', '', $key );
$value =& $this->configuration['settings'][$setting];
 
+   # Extension is deactivated
if( $value === false ) {
$status = null;
unset( $this->configuration['extensions'][$key] 
);
-   } elseif( $ExtensionRegistry === null || $value === 
'composer' ) {
-   if( $this->detectComposer( $type, $name ) ) {
-   $status = 'composer';
-   $value = true;
-   } elseif( $value === 'composer' ) {
-   $value = false;
-   unset( 
$this->configuration['extensions'][$key] );
-   }
-   } elseif( $value === 'require_once' || $value === 
'wfLoad' . ucfirst( $type ) ) {
+
+   # Mechanism Composer wanted
+   } elseif( $value === 'composer' && 
$this->detectComposer( $type, $name ) ) {
+   $status = 'composer';
+   $value = true;
+
+   # MediaWiki still not loaded: we must wait before 
taking a decision
+   } elseif( $ExtensionRegistry === null ) {
+   # nop
+
+   # Mechanism require_once wanted
+   } elseif( $value === 'require_once' && 
$this->detectLoadingMechanism( $type, $name, true ) == $value ) {
$status = $value;
$value = true;
-   // @codingStandardsIgnoreLine 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
-   } elseif( $status = $this->detectLoadingMechanism( 
$type, $name ) ) {
+
+   # Mechanism wfLoadSkin/wfLoadExtension wanted
+   } elseif( $value === 'wfLoad' . ucfirst( $type ) && 
$this->detectLoadingMechanism( $type, $name ) == $value ) {
+   $status = $value;
$value = true;
+
+   # Any mechanism to load the extension
+   // @codingStandardsIgnoreLine 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
+   } elseif( $value === true && $status = 
$this->detectLoadingMechanism( $type, $name ) ) {
+   # nop
+
+   # Missing extension or wrong configuration value
} elseif( $key != 'ExtensionMediaWikiFarm' ) {
-   if( $value ) {
-   $this->farm->log[] = "Requested but 
missing $type $name for wiki " .
-   $this->farm->getVariable( 
'$WIKIID' ) . ' in version ' .
-   $this->farm->getVariable( 
'$VERSION' );
-   }
+   $this->farm->log[] = "Requested but missing 
$type $name for wiki " .
+   $this->farm->getVariable( '$WIKIID' ) . 
' in version ' .
+   $this->farm->getVariable( '$VERSION' );
$value = false;
$status = null;
unset( $this->configuration['extensions'][$key] 
);
+
+   # MediaWikiFarm is specific because in a non-standard 
location
} else {
$status = $ExtensionRegistry ? 
'wfLoadExtension' : 'require_once';
}
@@ -513,9 +526,10 @@
 *
 * 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Bug: a Composer extension could not be deactivated

2017-08-26 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374031 )

Change subject: Bug: a Composer extension could not be deactivated
..

Bug: a Composer extension could not be deactivated

In the case of a Composer extension was marked as not to be activated
(value false), this value was not taken into account and the extension
was activated. It worked (a Composer extension not wanted is deactivated)
when it was never marked in the configuration.

Change-Id: Ida82bbc45c9cb2ad094e6cd416044a995f1304cf
---
M src/MediaWikiFarmConfiguration.php
1 file changed, 6 insertions(+), 2 deletions(-)


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

diff --git a/src/MediaWikiFarmConfiguration.php 
b/src/MediaWikiFarmConfiguration.php
index 4da1b5d..458a247 100644
--- a/src/MediaWikiFarmConfiguration.php
+++ b/src/MediaWikiFarmConfiguration.php
@@ -424,7 +424,10 @@
$setting = 'wgUse' . preg_replace( 
'/[^a-zA-Z0-9_\x7f\xff]/', '', $key );
$value =& $this->configuration['settings'][$setting];
 
-   if( $ExtensionRegistry === null || $value === 
'composer' ) {
+   if( $value === false ) {
+   $status = null;
+   unset( $this->configuration['extensions'][$key] 
);
+   } elseif( $ExtensionRegistry === null || $value === 
'composer' ) {
if( $this->detectComposer( $type, $name ) ) {
$status = 'composer';
$value = true;
@@ -436,7 +439,7 @@
$status = $value;
$value = true;
// @codingStandardsIgnoreLine 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
-   } elseif( $value !== false && ( $status = 
$this->detectLoadingMechanism( $type, $name ) ) ) {
+   } elseif( $status = $this->detectLoadingMechanism( 
$type, $name ) ) {
$value = true;
} elseif( $key != 'ExtensionMediaWikiFarm' ) {
if( $value ) {
@@ -445,6 +448,7 @@
$this->farm->getVariable( 
'$VERSION' );
}
$value = false;
+   $status = null;
unset( $this->configuration['extensions'][$key] 
);
} else {
$status = $ExtensionRegistry ? 
'wfLoadExtension' : 'require_once';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida82bbc45c9cb2ad094e6cd416044a995f1304cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Split out utilitary functions into dedicated classes

2017-08-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373941 )

Change subject: Split out utilitary functions into dedicated classes
..

Split out utilitary functions into dedicated classes

This reduces the complexity of the main class (CRAP from 253 to 202) and make
possible the use of these functions without creating the main object. In
particular I need the function readFile for the “list wikis” feature, but
don’t need the main object.

By the way, the function dedicated to read YAML files is enclosed in a class,
so that it is a general design to have utils functions in classes.

Small thing: I remove the @author given there will be many authors in the
long term (and Git history lists the authors), and it removes one publication
on the Web of my email address, hence a source of information for spammers.

Change-Id: Id9a47bf64061ab6d292e338c750d311f96be0e32
---
M extension.json
M src/MediaWikiFarm.php
M src/MediaWikiFarmConfiguration.php
A src/Utils.php
A src/Utils5_3.php
D src/Yaml.php
M src/bin/MediaWikiFarmScriptComposer.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/FunctionsTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/LoggingTest.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
M tests/phpunit/bin/MediaWikiFarmScriptComposerTest.php
M tests/phpunit/bin/MediaWikiFarmScriptTest.php
17 files changed, 423 insertions(+), 333 deletions(-)


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

diff --git a/extension.json b/extension.json
index 5a44c0f..2b317ab 100644
--- a/extension.json
+++ b/extension.json
@@ -32,6 +32,8 @@
"MediaWikiFarmConfiguration": 
"src/MediaWikiFarmConfiguration.php",
"AbstractMediaWikiFarmScript": 
"src/bin/AbstractMediaWikiFarmScript.php",
"MediaWikiFarmScript": "src/bin/MediaWikiFarmScript.php",
+   "MediaWikiFarmUtils": "src/Utils.php",
+   "MediaWikiFarmUtils5_3": "src/Utils5_3.php",
"MediaWikiFarmHooks": "src/Hooks.php",
"MWFConfigurationException": "src/MediaWikiFarm.php"
},
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 56c47be..3492211 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -3,7 +3,6 @@
  * Classes MediaWikiFarm and MWFConfigurationException.
  *
  * @package MediaWikiFarm
- * @author Sébastien Beyou ~ Seb35 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
  *
@@ -12,6 +11,7 @@
  */
 
 // @codeCoverageIgnoreStart
+require_once dirname( __FILE__ ) . '/Utils.php';
 require_once dirname( __FILE__ ) . '/MediaWikiFarmConfiguration.php';
 // @codeCoverageIgnoreEnd
 
@@ -381,7 +381,7 @@
$variables = $this->variables;
$variables['$CORECONFIG'] = 
$this->farmConfig['coreconfig'];
$variables['$CONFIG'] = $this->farmConfig['config'];
-   self::cacheFile( $variables, 
$this->variables['$SERVER'] . '.php', $this->cacheDir . '/wikis' );
+   MediaWikiFarmUtils::cacheFile( $variables, 
$this->variables['$SERVER'] . '.php', $this->cacheDir . '/wikis' );
}
 
return true;
@@ -426,7 +426,7 @@
 
# Save Composer key if available
if( $this->cacheDir && !array_key_exists( 
'unreadable-file', $this->log ) ) {
-   self::cacheFile( $this->getConfiguration( 
'composer' ),
+   MediaWikiFarmUtils::cacheFile( 
$this->getConfiguration( 'composer' ),
$this->variables['$SERVER'] . '.php',
$this->cacheDir . '/composer'
);
@@ -444,7 +444,7 @@
 
# Create the final LocalSettings.php
if( $this->cacheDir && !array_key_exists( 
'unreadable-file', $this->log ) ) {
-   self::cacheFile( 
MediaWikiFarmConfiguration::createLocalSettings( $this->getConfiguration(), 
(bool) $this->codeDir ),
+   MediaWikiFarmUtils::cacheFile( 
MediaWikiFarmConfiguration::createLocalSettings( $this->getConfiguration(), 
(bool) $this->codeDir ),
$this->variables['$SERVER'] . '.php',
$this->cacheDir . '/LocalSettings'
);
@@ -490,7 +490,7 @@
if( !array_key_exists( $setting, $GLOBALS ) ) {
$GLOBALS[$setting] = array();
 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Move classes for scripts from ./src to ./src/bin

2017-08-22 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373105 )

Change subject: Move classes for scripts from ./src to ./src/bin
..

Move classes for scripts from ./src to ./src/bin

- …and the same for the associated test classes;
- Make systematic use of constants for directories in the tests instead
  of recomputing the directories (less error-prone and clearer);
- Use absolute path in the header require_once in the tests.

Change-Id: Id7064473d42b516b40198510946e95bcd76c613e
---
M bin/mwcomposer.php
M bin/mwscript.php
M src/Hooks.php
R src/bin/AbstractMediaWikiFarmScript.php
R src/bin/MediaWikiFarmScript.php
R src/bin/MediaWikiFarmScriptComposer.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/FunctionsTest.php
M tests/phpunit/HooksTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/LoggingTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
R tests/phpunit/bin/MediaWikiFarmScriptComposerTest.php
R tests/phpunit/bin/MediaWikiFarmScriptTest.php
18 files changed, 134 insertions(+), 124 deletions(-)


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

diff --git a/bin/mwcomposer.php b/bin/mwcomposer.php
index c1372fc..6e00a31 100644
--- a/bin/mwcomposer.php
+++ b/bin/mwcomposer.php
@@ -15,16 +15,16 @@
 }
 
 # Load classes
-require_once dirname( dirname( __FILE__ ) ) . 
'/src/MediaWikiFarmComposerScript.php';
+require_once dirname( dirname( __FILE__ ) ) . 
'/src/bin/MediaWikiFarmScriptComposer.php';
 
 # Prepare environment
-$wgMediaWikiFarmComposerScript = new MediaWikiFarmComposerScript( $argc, $argv 
);
+$wgMediaWikiFarmScriptComposer = new MediaWikiFarmScriptComposer( $argc, $argv 
);
 
-$wgMediaWikiFarmComposerScript->load();
+$wgMediaWikiFarmScriptComposer->load();
 
-$wgMediaWikiFarmComposerScript->main();
+$wgMediaWikiFarmScriptComposer->main();
 
-if( $wgMediaWikiFarmComposerScript->status != 200 ) {
-   exit( $wgMediaWikiFarmComposerScript->status );
+if( $wgMediaWikiFarmScriptComposer->status != 200 ) {
+   exit( $wgMediaWikiFarmScriptComposer->status );
 }
 // @codeCoverageIgnoreEnd
diff --git a/bin/mwscript.php b/bin/mwscript.php
index 1767d71..80549a3 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -15,7 +15,7 @@
 }
 
 # Load classes
-require_once dirname( dirname( __FILE__ ) ) . '/src/MediaWikiFarmScript.php';
+require_once dirname( dirname( __FILE__ ) ) . 
'/src/bin/MediaWikiFarmScript.php';
 
 # Prepare environment
 $wgMediaWikiFarmScript = new MediaWikiFarmScript( $argc, $argv );
diff --git a/src/Hooks.php b/src/Hooks.php
index f14bf21..946c6ca 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -36,10 +36,10 @@
$files[] = $dir . 'InstallationIndependantTest.php';
$files[] = $dir . 'LoadingTest.php';
$files[] = $dir . 'LoggingTest.php';
-   $files[] = $dir . 'MediaWikiFarmComposerScriptTest.php';
-   $files[] = $dir . 'MediaWikiFarmScriptTest.php';
$files[] = $dir . 'MonoversionInstallationTest.php';
$files[] = $dir . 'MultiversionInstallationTest.php';
+   $files[] = $dir . 'bin/MediaWikiFarmScriptComposerTest.php';
+   $files[] = $dir . 'bin/MediaWikiFarmScriptTest.php';
 
return true;
}
diff --git a/src/AbstractMediaWikiFarmScript.php 
b/src/bin/AbstractMediaWikiFarmScript.php
similarity index 94%
rename from src/AbstractMediaWikiFarmScript.php
rename to src/bin/AbstractMediaWikiFarmScript.php
index bf0e0d6..d53929a 100644
--- a/src/AbstractMediaWikiFarmScript.php
+++ b/src/bin/AbstractMediaWikiFarmScript.php
@@ -9,7 +9,7 @@
  */
 
 // @codeCoverageIgnoreStart
-require_once dirname( __FILE__ ) . '/MediaWikiFarm.php';
+require_once dirname( dirname( __FILE__ ) ) . '/MediaWikiFarm.php';
 // @codeCoverageIgnoreEnd
 
 /**
@@ -155,22 +155,23 @@
global $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir, 
$wgMediaWikiFarmCacheDir, $wgMediaWikiFarmSyslog, $IP;
 
# Default values
-   $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) 
) );
+   $farmDir = dirname( dirname( dirname( __FILE__ ) ) );
+   $wgMediaWikiFarmCodeDir = dirname( $farmDir );
$wgMediaWikiFarmConfigDir = '/etc/mediawiki';
$wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
$wgMediaWikiFarmSyslog = 'mediawikifarm';
 
-   if( is_file( dirname( dirname( dirname( dirname( __FILE__ ) ) ) 
) . '/includes/DefaultSettings.php' ) ) {
+   if( is_file( dirname( dirname( $farmDir ) ) . 
'/includes/DefaultSettings.php' ) ) {
 
-   $IP = dirname( dirname( dirname( dirname( 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Small bug during logging

2017-08-22 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373034 )

Change subject: Small bug during logging
..

Small bug during logging

Missing global scope during configuration of logging in scripts, hence there
was no customisation of the tag.

Change-Id: I8a72b4491efccef895c461f00ab48cc62e428185
---
M src/AbstractMediaWikiFarmScript.php
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/src/AbstractMediaWikiFarmScript.php 
b/src/AbstractMediaWikiFarmScript.php
index 99f6283..bf0e0d6 100644
--- a/src/AbstractMediaWikiFarmScript.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -152,7 +152,7 @@
 */
function load() {
 
-   global $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir, 
$wgMediaWikiFarmCacheDir, $IP;
+   global $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir, 
$wgMediaWikiFarmCacheDir, $wgMediaWikiFarmSyslog, $IP;
 
# Default values
$wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) 
) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a72b4491efccef895c461f00ab48cc62e428185
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Define more precisely the set of existing wikis

2017-08-21 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372884 )

Change subject: Define more precisely the set of existing wikis
..

Define more precisely the set of existing wikis

Given there are two mechanism to check if a wiki exists (“variables” files and
“versions” file) and given the two mechanisms answer “possibly existing” if a
wiki is not registered in their mechanism, it was possible to define ghost
wikis, registered nowhere but with some default coarse-defined parameters (MW
parameters like a default database for a suffix, catching there all ghost
wikis).

This commit fixes this odd behaviour: wikis must be defined in at least one of
the two mechanisms (the first mechanism has precedence). More precisely either
the 'wikiID' is defined with at least one identifying variable checked against
a file of existing values, either the ”versions“ file must contain the wikiID.

BTW, remove the need to define the “variables” mechanism (it is possible to
entirely rely on the “versions” mechanism); it will be a bit more easier to
setup a basic installation as described in the “Quick start” guide.

Beyond this improvement in the definition, this is required to create
automatic lists of wikis; without it, the ghost wikis issue remains.

Also, strenghten some PHPCS exceptions and add some gitignored files
temporarily used in tests.

Change-Id: I569c780365022632d5db32e5406fbed86756290c
---
M .gitignore
M src/MediaWikiFarm.php
M src/MediaWikiFarmConfiguration.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
M tests/phpunit/data/config/farms.php
A tests/phpunit/data/config/versions-default.php
9 files changed, 115 insertions(+), 28 deletions(-)


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

diff --git a/.gitignore b/.gitignore
index c39412b..07aae69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,9 +12,13 @@
 /vendor
 
 # Tests
-/tests/phpunit/data/config/deployments.php
-/tests/phpunit/data/config/testdeploymentsfarmversions.php
+/phpunitHTTP404.php
 /tests/perfs/results
+/tests/phpunit/data/config/badsyntax.json
+/tests/phpunit/data/config/deployments.php
+/tests/phpunit/data/config/empty.json
+/tests/phpunit/data/config/testdeploymentsfarmversions.php
+/tests/phpunit/data/mediawiki/vstub3
 
 # Compiled code documentation
 /docs/code
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 147e1b7..56c47be 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -359,7 +359,8 @@
}
 
# Replace variables in the host name and possibly retrieve the 
version
-   if( !$this->checkHostVariables() ) {
+   $explicitExistence = $this->checkHostVariables();
+   if( $explicitExistence === false ) {
return false;
}
 
@@ -368,7 +369,7 @@
$this->setVariable( 'wikiID', true );
 
# Set the version of the wiki
-   if( !$this->setVersion() ) {
+   if( !$this->setVersion( (bool) $explicitExistence ) ) {
return false;
}
 
@@ -745,7 +746,7 @@
}
 
# Shortcut loading
-   // @codingStandardsIgnoreLine
+   // @codingStandardsIgnoreLine 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
if( $this->cacheDir && ( $result = $this->readFile( $host . ( 
$path ? $path : '' ) . '.php', $this->cacheDir . '/wikis', false ) ) ) {
$fresh = true;
$myfreshness = filemtime( $this->cacheDir . '/wikis/' . 
$host . ( $path ? $path : '' ) . '.php' );
@@ -817,7 +818,7 @@
 
# Read the farms configuration
if( !$farms ) {
-   // @codingStandardsIgnoreStart
+   // @codingStandardsIgnoreStart 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
if( $farms = $this->readFile( 'farms.yml', 
$this->configDir ) ) {
$this->farmConfig['coreconfig'][] = 'farms.yml';
} elseif( $farms = $this->readFile( 'farms.php', 
$this->configDir ) ) {
@@ -827,7 +828,7 @@
} else {
return array( 'host' => $host, 'farm' => false, 
'config' => false, 'variables' => false, 'farms' => false, 'redirects' => 
$redirects );
}
-   // @codingStandardsIgnoreEnd
+   // @codingStandardsIgnoreEnd 
MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures
}
 
# For each proposed farm, 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Update coding rules according to phpcs

2017-08-19 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372757 )

Change subject: Update coding rules according to phpcs
..

Update coding rules according to phpcs

Change-Id: I42a24b5000f50558f219622b08c5e49de754ca58
---
M src/AbstractMediaWikiFarmScript.php
M src/MediaWikiFarm.php
M src/MediaWikiFarmConfiguration.php
M tests/perfs/MediaWikiFarmTestPerfs.php
M tests/perfs/perfs.php
M tests/phpunit/MultiversionInstallationTest.php
6 files changed, 13 insertions(+), 12 deletions(-)


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

diff --git a/src/AbstractMediaWikiFarmScript.php 
b/src/AbstractMediaWikiFarmScript.php
index caa0659..99f6283 100644
--- a/src/AbstractMediaWikiFarmScript.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -90,7 +90,7 @@
break;
}
elseif( $this->argv[$posArg] == '--'.$name && 
$posArg < $this->argc - 1 ) {
-   $value = $this->argv[$posArg+1];
+   $value = $this->argv[$posArg + 1];
$nbArgs = 2;
break;
}
@@ -111,7 +111,7 @@
if( $shift ) {
 
$this->argc -= $nbArgs;
-   $this->argv = array_merge( array_slice( $this->argv, 0, 
$posArg ), array_slice( $this->argv, $posArg+$nbArgs ) );
+   $this->argv = array_merge( array_slice( $this->argv, 0, 
$posArg ), array_slice( $this->argv, $posArg + $nbArgs ) );
}
 
return $value;
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 7603cc9..147e1b7 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -806,7 +806,7 @@
 *
 * @param string $host Requested host.
 * @param array $farms All farm configurations.
-* @param integer $redirects Number of remaining internal redirects 
before error.
+* @param int $redirects Number of remaining internal redirects before 
error.
 * @return array
 */
function selectFarm( $host, $farms, $redirects ) {
diff --git a/src/MediaWikiFarmConfiguration.php 
b/src/MediaWikiFarmConfiguration.php
index 97cea26..5033c07 100644
--- a/src/MediaWikiFarmConfiguration.php
+++ b/src/MediaWikiFarmConfiguration.php
@@ -253,7 +253,7 @@

$settingsArray[$setting] = array();

$prioritiesArray[$setting] = 0;
}
-   $thisSetting =  
&$settingsArray[$setting];
+   $thisSetting = 
&$settingsArray[$setting];
$thisPriority = 
&$prioritiesArray[$setting];
} else {
$settingIsArray = false;
@@ -261,7 +261,7 @@
$settings[$setting] = 
null;
$priorities[$setting] = 
0;
}
-   $thisSetting =  
&$settings[$setting];
+   $thisSetting = 
&$settings[$setting];
$thisPriority = 
&$priorities[$setting];
if( substr( $setting, 0, 14 ) 
== 'wgUseExtension' ) {
$extensions['Extension' 
. substr( $rawSetting, 14 )] = array( substr( $rawSetting, 14 ), 'extension', 
null, count( $extensions ) );
@@ -489,7 +489,7 @@
 *
 * @param string $type Type, in ['extension', 'skin'].
 * @param string $name Name of the extension/skin.
-* @return boolean The extension/skin is Composer-managed (at least for 
its installation).
+* @return bool The extension/skin is Composer-managed (at least for 
its installation).
 */
function detectComposer( $type, $name ) {
 
@@ -609,7 +609,7 @@
 * @internal
 *
 * @param array $configuration Array with the schema defined for 
$this->configuration.
-* @param boolean $isMonoversion Is MediaWikiFarm configured for 
monoversion?
+* @param bool $isMonoversion Is MediaWikiFarm configured for 
monoversion?
 * @param string $preconfig PHP code to be added at the top of the file.
 * @param string $postconfig PHP code to be added at the end of the 
file.
 * @return string Content of the file LocalSettings.php.
diff --git 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: phpcs.xml: Escape . in exclude-pattern

2017-08-07 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/367485 )

Change subject: phpcs.xml: Escape . in exclude-pattern
..


phpcs.xml: Escape . in exclude-pattern

See T129664

Change-Id: If7e15aed1bd981008e5094358ce7938bc2500d70
---
M phpcs.xml
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Umherirrender: Verified; Looks good to me, approved



diff --git a/phpcs.xml b/phpcs.xml
index f89e22f..b0234eb 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,7 +1,7 @@
 
 
.
-   
+   



@@ -44,5 +44,5 @@

tests/perfs/results
vendor
-   .git
+   \.git
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If7e15aed1bd981008e5094358ce7938bc2500d70
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Umherirrender 
Gerrit-Reviewer: Umherirrender 
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...Cargo[master]: gitignore for the Composer files

2017-08-05 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370360 )

Change subject: gitignore for the Composer files
..

gitignore for the Composer files

Change-Id: I669685e653a5d8b65421494aae3e745f1c144298
---
M .gitignore
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo 
refs/changes/60/370360/1

diff --git a/.gitignore b/.gitignore
index 3c3629e..a8799a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
 node_modules
+/composer.lock
+/vendor

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I669685e653a5d8b65421494aae3e745f1c144298
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add logging for exceptions inside DerrableUpdate

2017-06-27 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/361787 )

Change subject: Add logging for exceptions inside DerrableUpdate
..

Add logging for exceptions inside DerrableUpdate

Bug: T168347
Change-Id: Iedf13b1cb69299648e154d72b614db66569c4782
---
M includes/deferred/DeferredUpdates.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/87/361787/1

diff --git a/includes/deferred/DeferredUpdates.php 
b/includes/deferred/DeferredUpdates.php
index a3a37f6..1fd54e8 100644
--- a/includes/deferred/DeferredUpdates.php
+++ b/includes/deferred/DeferredUpdates.php
@@ -259,6 +259,7 @@
$update->doUpdate();
$lbFactory->commitMasterChanges( $fnameTrxOwner );
} catch ( Exception $e ) {
+   wfDebugLog( 'DeferredUpdates', 'Exception triggered in 
' . get_class( $update ) . '::doUpdate(): ' . $e );
// Reporting GUI exceptions does not work post-send
if ( $e instanceof ErrorPageError && $stage === 
self::PRESEND ) {
$guiError = $e;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iedf13b1cb69299648e154d72b614db66569c4782
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Add support for wgExtensionDirectory and wgStyleDirectory

2017-06-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/361388 )

Change subject: Add support for wgExtensionDirectory and wgStyleDirectory
..

Add support for wgExtensionDirectory and wgStyleDirectory

By small extension, it also works for require_once extensions and skins, which
are expected to be found in the same directory.

By the way, fixed a bad PHP5.2 syntax in src/MediaWikiFarm.php; the new syntax
is also shorter and clearer.

Bug: T162690
Change-Id: I54eff7ca9159fdea20e38825d3f8a7a061aaaf79
---
M src/MediaWikiFarm.php
M src/MediaWikiFarmConfiguration.php
M src/main.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/data/config/extensionssettings.php
M tests/phpunit/data/config/testextensionsfarmversions.php
7 files changed, 83 insertions(+), 10 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index a223352..7603cc9 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -510,9 +510,8 @@
}
 
# Register this extension MediaWikiFarm to appear in 
Special:Version
-   if( array_key_exists( 'ExtensionMediaWikiFarm', 
$this->getConfiguration( 'extensions' ) ) &&
-$this->getConfiguration( 'extensions', 
'ExtensionMediaWikiFarm' )[2] == 'require_once' &&
-$this->codeDir ) {
+   $extMediaWikiFarm = $this->getConfiguration( 'extensions', 
'ExtensionMediaWikiFarm' );
+   if( $extMediaWikiFarm && $extMediaWikiFarm[2] == 'require_once' 
&& $this->codeDir ) {
$GLOBALS['wgExtensionCredits']['other'][] = array(
'path' => $this->farmDir . '/MediaWikiFarm.php',
'name' => 'MediaWikiFarm',
diff --git a/src/MediaWikiFarmConfiguration.php 
b/src/MediaWikiFarmConfiguration.php
index 3f2d901..97cea26 100644
--- a/src/MediaWikiFarmConfiguration.php
+++ b/src/MediaWikiFarmConfiguration.php
@@ -513,12 +513,21 @@
 */
function detectLoadingMechanism( $type, $name ) {
 
-   if( !is_dir( $this->farm->getVariable( '$CODE' 
).'/'.$type.'s/'.$name ) ) {
+   # Search base directory
+   $base = $this->farm->getVariable( '$CODE' ) . '/' . $type . 's';
+   if( $type == 'extension' && array_key_exists( 
'wgExtensionDirectory', $this->configuration['settings'] ) ) {
+   $base = 
$this->configuration['settings']['wgExtensionDirectory'];
+   }
+   elseif( $type == 'skin' && array_key_exists( 
'wgStyleDirectory', $this->configuration['settings'] ) ) {
+   $base = 
$this->configuration['settings']['wgStyleDirectory'];
+   }
+
+   if( !is_dir( $base . '/' . $name ) ) {
return null;
}
 
# An extension.json/skin.json file is in the directory -> 
assume it is the loading mechanism
-   if( $this->environment['ExtensionRegistry'] && is_file( 
$this->farm->getVariable( '$CODE' ).'/'.$type.'s/'.$name.'/'.$type.'.json' ) ) {
+   if( $this->environment['ExtensionRegistry'] && is_file( $base . 
'/' . $name . '/' . $type . '.json' ) ) {
return 'wfLoad' . ucfirst( $type );
}
 
@@ -528,7 +537,7 @@
}
 
# A MyExtension.php file is in the directory -> assume it is 
the loading mechanism
-   elseif( is_file( $this->farm->getVariable( '$CODE' 
).'/'.$type.'s/'.$name.'/'.$name.'.php' ) ) {
+   elseif( is_file( $base . '/' . $name . '/' . $name . '.php' ) ) 
{
return 'require_once';
}
 
@@ -607,6 +616,18 @@
 */
static function createLocalSettings( $configuration, $isMonoversion, 
$preconfig = '', $postconfig = '' ) {
 
+   # Prepare paths
+   $path = array(
+   'extension' => '$IP/extensions',
+   'skin' => '$IP/skins',
+   );
+   if( array_key_exists( 'wgExtensionDirectory', 
$configuration['settings'] ) ) {
+   $path['extension'] = 
$configuration['settings']['wgExtensionDirectory'];
+   }
+   if( array_key_exists( 'wgStyleDirectory', 
$configuration['settings'] ) ) {
+   $path['skin'] = 
$configuration['settings']['wgStyleDirectory'];
+   }
+
$localSettings = " $extension ) {
if( $extension[2] == 'require_once' && ( $key != 
'ExtensionMediaWikiFarm' || !$isMonoversion ) ) {
-   $extensions[$extension[1]]['require_once'] .= 
"require_once 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Execute scripts when wikis are path-based

2017-06-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/361302 )

Change subject: Execute scripts when wikis are path-based
..

Execute scripts when wikis are path-based

Change-Id: Ie54c52d0a57bf0b75fa8566dbcf6913eb83ad15e
---
M src/MediaWikiFarm.php
M src/MediaWikiFarmScript.php
M tests/phpunit/MediaWikiFarmScriptTest.php
3 files changed, 26 insertions(+), 13 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index f269008..a223352 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -271,7 +271,9 @@
$exists = $wgMediaWikiFarm->checkExistence();
 
# Compile configuration
-   $wgMediaWikiFarm->compileConfiguration();
+   if( $exists ) {
+   $wgMediaWikiFarm->compileConfiguration();
+   }
}
catch( Exception $exception ) {
 
@@ -720,6 +722,9 @@
# Sanitise host and path
$host = preg_replace( '/[^a-zA-Z0-9\\._-]/', '', $host );
$path = '/' . substr( $path, 1 );
+   if( $path === '/' ) {
+   $path = '';
+   }
 
# Set parameters
$this->farmDir = dirname( dirname( __FILE__ ) );
@@ -742,9 +747,9 @@
 
# Shortcut loading
// @codingStandardsIgnoreLine
-   if( $this->cacheDir && ( $result = $this->readFile( $host . 
'.php', $this->cacheDir . '/wikis', false ) ) ) {
+   if( $this->cacheDir && ( $result = $this->readFile( $host . ( 
$path ? $path : '' ) . '.php', $this->cacheDir . '/wikis', false ) ) ) {
$fresh = true;
-   $myfreshness = filemtime( $this->cacheDir . '/wikis/' . 
$host . '.php' );
+   $myfreshness = filemtime( $this->cacheDir . '/wikis/' . 
$host . ( $path ? $path : '' ) . '.php' );
foreach( $result['$CORECONFIG'] as $coreconfig ) {
if( !is_file( $this->configDir . '/' . 
$coreconfig ) ||
filemtime( $this->configDir . '/' . 
$coreconfig ) > $myfreshness ) {
@@ -759,12 +764,12 @@
$this->variables = $result;
return;
} else {
-   unlink( $this->cacheDir . '/wikis/' . $host . 
'.php' );
-   if( is_file( $this->cacheDir . 
'/LocalSettings/' . $host . '.php' ) ) {
-   unlink( $this->cacheDir . 
'/LocalSettings/' . $host . '.php' );
+   unlink( $this->cacheDir . '/wikis/' . $host . ( 
$path ? $path : '' ) . '.php' );
+   if( is_file( $this->cacheDir . 
'/LocalSettings/' . $host . ( $path ? $path : '' ) . '.php' ) ) {
+   unlink( $this->cacheDir . 
'/LocalSettings/' . $host . ( $path ? $path : '' ) . '.php' );
}
-   if( is_file( $this->cacheDir . '/composer/' . 
$host . '.php' ) ) {
-   unlink( $this->cacheDir . '/composer/' 
. $host . '.php' );
+   if( is_file( $this->cacheDir . '/composer/' . 
$host . ( $path ? $path : '' ) . '.php' ) ) {
+   unlink( $this->cacheDir . '/composer/' 
. $host . ( $path ? $path : '' ) . '.php' );
}
}
}
diff --git a/src/MediaWikiFarmScript.php b/src/MediaWikiFarmScript.php
index 3ec6e88..1262fe8 100644
--- a/src/MediaWikiFarmScript.php
+++ b/src/MediaWikiFarmScript.php
@@ -80,10 +80,17 @@
 
# Get wiki
$this->host = $this->getParam( 'wiki' );
+   $this->path = '';
+   $host = $this->host;
if( is_null( $this->host ) ) {
$this->usage();
$this->status = 4;
return false;
+   }
+   $posSlash = strpos( $this->host, '/' );
+   if( $posSlash !== false ) {
+   $this->path = substr( $this->host, $posSlash );
+   $this->host = substr( $this->host, 0, $posSlash );
}
 
# Get script
@@ -104,7 +111,7 @@
 
 
# Initialise the requested version
-   $code = MediaWikiFarm::load( $this->script, $this->host );
+   $code = MediaWikiFarm::load( $this->script, $this->host, 
$this->path );
if( $code == 404 ) {
$this->status = 1;
return 

[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_28]: Make DeferredUpdates detect LBFactory transaction rounds

2017-06-12 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/358461 )

Change subject: Make DeferredUpdates detect LBFactory transaction rounds
..

Make DeferredUpdates detect LBFactory transaction rounds

Previously, tryOpportunisticExecute() tried to nest transaction rounds,
which would fail. Added LBFactory::hasTransactionRound() as needed.

Also cleaned up some unqualified class names in callbacks and set the
PRESEND flag for the JobQueueDB AutoCommitUpdate callback. Use the
proper getMasterDB() method while at it. These follow up 24842cfac.

Bug: T154425
Change-Id: Ib1d38f68bd217903d1a7d46fb15b7d7d9620daa6
(cherry picked from commit 95fdff36c251d9d1807c7b5b0bf84acc457f0d1e)
---
M includes/MediaWiki.php
M includes/deferred/DeferredUpdates.php
M includes/jobqueue/JobQueueDB.php
M includes/jobqueue/JobRunner.php
M includes/libs/rdbms/lbfactory/ILBFactory.php
M includes/libs/rdbms/lbfactory/LBFactory.php
6 files changed, 32 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/61/358461/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index ba1c8c8..f129a8b 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -887,9 +887,8 @@
__METHOD__
);
 
-   // Push lazilly-pushed jobs
// Important: this must be the last deferred update added 
(T100085, T154425)
-   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
+   DeferredUpdates::addCallableUpdate( [ JobQueueGroup::class, 
'pushLazyJobs' ] );
 
// Do any deferred jobs
DeferredUpdates::doUpdates( 'enqueue' );
diff --git a/includes/deferred/DeferredUpdates.php 
b/includes/deferred/DeferredUpdates.php
index fd3a1af..069b092 100644
--- a/includes/deferred/DeferredUpdates.php
+++ b/includes/deferred/DeferredUpdates.php
@@ -283,7 +283,7 @@
}
 
// Avoiding running updates without them having outer scope
-   if ( !self::getBusyDbConnections() ) {
+   if ( !self::areDatabaseTransactionsActive() ) {
self::doUpdates( $mode );
return true;
}
@@ -337,16 +337,19 @@
}
 
/**
-* @return IDatabase[] Connection where commit() cannot be called yet
+* @return bool If a transaction round is active or connection is not 
ready for commit()
 */
-   private static function getBusyDbConnections() {
-   $connsBusy = [];
-
+   private static function areDatabaseTransactionsActive() {
$lbFactory = 
MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+   if ( $lbFactory->hasTransactionRound() ) {
+   return true;
+   }
+
+   $connsBusy = false;
$lbFactory->forEachLB( function ( LoadBalancer $lb ) use ( 
&$connsBusy ) {
$lb->forEachOpenMasterConnection( function ( IDatabase 
$conn ) use ( &$connsBusy ) {
if ( $conn->writesOrCallbacksPending() || 
$conn->explicitTrxActive() ) {
-   $connsBusy[] = $conn;
+   $connsBusy = true;
}
} );
} );
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index ea2b113..345b591 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -181,13 +181,16 @@
 * @return void
 */
protected function doBatchPush( array $jobs, $flags ) {
-   DeferredUpdates::addUpdate( new AutoCommitUpdate(
-   wfGetDB( DB_MASTER ),
-   __METHOD__,
-   function ( IDatabase $dbw, $fname ) use ( $jobs, $flags 
) {
-   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $fname );
-   }
-   ) );
+   DeferredUpdates::addUpdate(
+   new AutoCommitUpdate(
+   $this->getMasterDB(),
+   __METHOD__,
+   function ( IDatabase $dbw, $fname ) use ( 
$jobs, $flags ) {
+   $this->doBatchPushInternal( $dbw, 
$jobs, $flags, $fname );
+   }
+   ),
+   DeferredUpdates::PRESEND
+   );
}
 
/**
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index 127f929..5ed31e0 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -275,9 +275,8 @@
$status = $job->run();
$error = 

[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_28]: Use AutoCommitUpdate instead of Database->onTransactionIdle

2017-06-07 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357561 )

Change subject: Use AutoCommitUpdate instead of Database->onTransactionIdle
..

Use AutoCommitUpdate instead of Database->onTransactionIdle

This is needed for deferred updates LinksDeletionUpdate and LinksUpdate, else
callbacks registered with onTransactionIdle prevent other transactions from
being executed, at least in this case.

Bug: T154425
Bug: T154438
Bug: T157679
Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
(cherry picked from commit 24842cfac0f392e2ba60dfcbf419d89c8895c7ed)
---
M includes/MediaWiki.php
M includes/jobqueue/JobQueueDB.php
M includes/jobqueue/JobQueueGroup.php
M includes/jobqueue/JobRunner.php
4 files changed, 17 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/61/357561/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index f668717..ba1c8c8 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -887,11 +887,12 @@
__METHOD__
);
 
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update added 
(T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
+
// Do any deferred jobs
DeferredUpdates::doUpdates( 'enqueue' );
-
-   // Make sure any lazy jobs are pushed
-   JobQueueGroup::pushLazyJobs();
 
// Now that everything specific to this request is done,
// try to occasionally run jobs (if enabled) from the queues
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index aa01768..ea2b113 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -181,15 +181,13 @@
 * @return void
 */
protected function doBatchPush( array $jobs, $flags ) {
-   $dbw = $this->getMasterDB();
-
-   $method = __METHOD__;
-   $dbw->onTransactionIdle(
-   function () use ( $dbw, $jobs, $flags, $method ) {
-   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $method );
-   },
-   __METHOD__
-   );
+   DeferredUpdates::addUpdate( new AutoCommitUpdate(
+   wfGetDB( DB_MASTER ),
+   __METHOD__,
+   function ( IDatabase $dbw, $fname ) use ( $jobs, $flags 
) {
+   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $fname );
+   }
+   ) );
}
 
/**
diff --git a/includes/jobqueue/JobQueueGroup.php 
b/includes/jobqueue/JobQueueGroup.php
index 71d68d9..6df8b27 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -163,7 +163,9 @@
/**
 * Buffer jobs for insertion via push() or call it now if in CLI mode
 *
-* Note that MediaWiki::restInPeace() calls pushLazyJobs()
+* Note that pushLazyJobs() is registered as a deferred update just 
before
+* DeferredUpdates::doUpdates() in MediaWiki and JobRunner classes in 
order
+* to be executed as the very last deferred update (T100085, T154425).
 *
 * @param IJobSpecification|IJobSpecification[] $jobs A single Job or a 
list of Jobs
 * @return void
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index aa8917c..127f929 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -275,10 +275,11 @@
$status = $job->run();
$error = $job->getLastError();
$this->commitMasterChanges( $lbFactory, $job, 
$fnameTrxOwner );
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update 
added (T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
// Run any deferred update tasks; doUpdates() manages 
transactions itself
DeferredUpdates::doUpdates();
-   // Push lazy jobs added by the job or its deferred 
udpates
-   JobQueueGroup::pushLazyJobs();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
$status = false;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_28
Gerrit-Owner: Seb35 

[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_29]: Use AutoCommitUpdate instead of Database->onTransactionIdle

2017-06-07 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357560 )

Change subject: Use AutoCommitUpdate instead of Database->onTransactionIdle
..

Use AutoCommitUpdate instead of Database->onTransactionIdle

This is needed for deferred updates LinksDeletionUpdate and LinksUpdate, else
callbacks registered with onTransactionIdle prevent other transactions from
being executed, at least in this case.

Bug: T154425
Bug: T154438
Bug: T157679
Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
(cherry picked from commit 24842cfac0f392e2ba60dfcbf419d89c8895c7ed)
---
M includes/MediaWiki.php
M includes/jobqueue/JobQueueDB.php
M includes/jobqueue/JobQueueGroup.php
M includes/jobqueue/JobRunner.php
4 files changed, 17 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/60/357560/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index b80bcab..8dab16b 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -898,11 +898,12 @@
__METHOD__
);
 
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update added 
(T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
+
// Do any deferred jobs
DeferredUpdates::doUpdates( 'enqueue' );
-
-   // Make sure any lazy jobs are pushed
-   JobQueueGroup::pushLazyJobs();
 
// Now that everything specific to this request is done,
// try to occasionally run jobs (if enabled) from the queues
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 924aacc..5e45730 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -185,15 +185,13 @@
 * @return void
 */
protected function doBatchPush( array $jobs, $flags ) {
-   $dbw = $this->getMasterDB();
-
-   $method = __METHOD__;
-   $dbw->onTransactionIdle(
-   function () use ( $dbw, $jobs, $flags, $method ) {
-   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $method );
-   },
-   __METHOD__
-   );
+   DeferredUpdates::addUpdate( new AutoCommitUpdate(
+   wfGetDB( DB_MASTER ),
+   __METHOD__,
+   function ( IDatabase $dbw, $fname ) use ( $jobs, $flags 
) {
+   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $fname );
+   }
+   ) );
}
 
/**
diff --git a/includes/jobqueue/JobQueueGroup.php 
b/includes/jobqueue/JobQueueGroup.php
index 9f78404..5d5ea26 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -163,7 +163,9 @@
/**
 * Buffer jobs for insertion via push() or call it now if in CLI mode
 *
-* Note that MediaWiki::restInPeace() calls pushLazyJobs()
+* Note that pushLazyJobs() is registered as a deferred update just 
before
+* DeferredUpdates::doUpdates() in MediaWiki and JobRunner classes in 
order
+* to be executed as the very last deferred update (T100085, T154425).
 *
 * @param IJobSpecification|IJobSpecification[] $jobs A single Job or a 
list of Jobs
 * @return void
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index a1aeaba..0a0e9e0 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -289,10 +289,11 @@
$status = $job->run();
$error = $job->getLastError();
$this->commitMasterChanges( $lbFactory, $job, 
$fnameTrxOwner );
+   // Push lazilly-pushed jobs
+   // Important: this must be the last deferred update 
added (T100085, T154425)
+   DeferredUpdates::addCallableUpdate( [ 'JobQueueGroup', 
'pushLazyJobs' ] );
// Run any deferred update tasks; doUpdates() manages 
transactions itself
DeferredUpdates::doUpdates();
-   // Push lazy jobs added by the job or its deferred 
udpates
-   JobQueueGroup::pushLazyJobs();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
$status = false;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_29
Gerrit-Owner: Seb35 

[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_27]: Better handling of jobs execution in post-connection shutdown

2017-06-02 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356887 )

Change subject: Better handling of jobs execution in post-connection shutdown
..

Better handling of jobs execution in post-connection shutdown

Some DeferredUpdates callables use JobQueueGroup::lazyPush but this is
never executed by the job runner, so some jobs are never added in the job
queue.

In this change a call to JobQueueGroup::pushLazyJobs is done in
JobRunner::execute.

This change is cherry-picked from the master version, but is quite
heavily lightened since an additional issue has been introduced in 1.28.

Bug: T100085
Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
(cherry picked from commit d80fca05e18d9654b8458ed6966c5d3c4991d88e)
---
M includes/jobqueue/JobRunner.php
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/87/356887/1

diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index a2f55b9..f82dfc4 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -268,6 +268,8 @@
 
DeferredUpdates::doUpdates();
$this->commitMasterChanges( $job );
+   // Push lazy jobs added by the job or its deferred 
udpates
+   JobQueueGroup::pushLazyJobs();
$job->teardown();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_28]: Better handling of jobs execution in post-connection shutdown

2017-06-02 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356880 )

Change subject: Better handling of jobs execution in post-connection shutdown
..

Better handling of jobs execution in post-connection shutdown

In the postprocessing, some jobs can be executed but given the deferred
updates were already "closed", any new DeferredUpdate were directly called
(as explained by Krinkle on T165714), and the transactions opened by
classical jobs are badly mixed with transactions (directly) executed by
DeferredUpdates jobs, issuing a DBError, avoiding the job, which stays
in a 'claimed' status even if failed.

Quite similarly, some DeferredUpdates callables use JobQueueGroup::lazyPush
so it is needed to really push the generated jobs.

This change removes the run-immediately-deferred-updates behaviour even
in the post-connection shutdown, and given there is a call to
DeferredUpdates::doUpdates in JobRunner::execute it is not necessary to
add another one and hence execution of Web jobs is more similar to execution
of CLI jobs. In the same spirit to reconcile Web jobs and CLI jobs, the
call to JobQueueGroup::pushLazyJobs is done in JobRunner::execute.

Bug: T165714
Bug: T100085
Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
(cherry picked from commit d80fca05e18d9654b8458ed6966c5d3c4991d88e)
---
M includes/MediaWiki.php
M includes/deferred/DeferredUpdates.php
M includes/jobqueue/JobRunner.php
3 files changed, 4 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/80/356880/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index aabaf30..f668717 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -889,7 +889,6 @@
 
// Do any deferred jobs
DeferredUpdates::doUpdates( 'enqueue' );
-   DeferredUpdates::setImmediateMode( true );
 
// Make sure any lazy jobs are pushed
JobQueueGroup::pushLazyJobs();
diff --git a/includes/deferred/DeferredUpdates.php 
b/includes/deferred/DeferredUpdates.php
index 1ba6c1f..fd3a1af 100644
--- a/includes/deferred/DeferredUpdates.php
+++ b/includes/deferred/DeferredUpdates.php
@@ -52,8 +52,6 @@
private static $preSendUpdates = [];
/** @var DeferrableUpdate[] Updates to be deferred until after request 
end */
private static $postSendUpdates = [];
-   /** @var bool Whether to just run updates in addUpdate() */
-   private static $immediateMode = false;
 
const ALL = 0; // all updates; in web requests, use only after flushing 
the output buffer
const PRESEND = 1; // for updates that should run before flushing 
output buffer
@@ -85,12 +83,6 @@
self::push( self::$preSendUpdates, $update );
} else {
self::push( self::$postSendUpdates, $update );
-   }
-
-   if ( self::$immediateMode ) {
-   // No more explicit doUpdates() calls will happen, so 
run this now
-   self::doUpdates( 'run' );
-   return;
}
 
// Try to run the updates now if in CLI mode and no transaction 
is active.
@@ -137,9 +129,10 @@
/**
 * @param bool $value Whether to just immediately run updates in 
addUpdate()
 * @since 1.28
+* @deprecated 1.29 Causes issues in Web-executed jobs - see T165714 
and T100085.
 */
public static function setImmediateMode( $value ) {
-   self::$immediateMode = (bool)$value;
+   wfDeprecated( __METHOD__, '1.29' );
}
 
/**
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index 0469eeb..aa8917c 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -277,6 +277,8 @@
$this->commitMasterChanges( $lbFactory, $job, 
$fnameTrxOwner );
// Run any deferred update tasks; doUpdates() manages 
transactions itself
DeferredUpdates::doUpdates();
+   // Push lazy jobs added by the job or its deferred 
udpates
+   JobQueueGroup::pushLazyJobs();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
$status = false;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_28
Gerrit-Owner: Seb35 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org

[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_29]: Better handling of jobs execution in post-connection shutdown

2017-06-02 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356799 )

Change subject: Better handling of jobs execution in post-connection shutdown
..

Better handling of jobs execution in post-connection shutdown

In the postprocessing, some jobs can be executed but given the deferred
updates were already "closed", any new DeferredUpdate were directly called
(as explained by Krinkle on T165714), and the transactions opened by
classical jobs are badly mixed with transactions (directly) executed by
DeferredUpdates jobs, issuing a DBError, avoiding the job, which stays
in a 'claimed' status even if failed.

Quite similarly, some DeferredUpdates callables use JobQueueGroup::lazyPush
so it is needed to really push the generated jobs.

This change removes the run-immediately-deferred-updates behaviour even
in the post-connection shutdown, and given there is a call to
DeferredUpdates::doUpdates in JobRunner::execute it is not necessary to
add another one and hence execution of Web jobs is more similar to execution
of CLI jobs. In the same spirit to reconcile Web jobs and CLI jobs, the
call to JobQueueGroup::pushLazyJobs is done in JobRunner::execute.

Bug: T165714
Bug: T100085
Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
(cherry picked from commit d80fca05e18d9654b8458ed6966c5d3c4991d88e)
---
M includes/MediaWiki.php
M includes/deferred/DeferredUpdates.php
M includes/jobqueue/JobRunner.php
3 files changed, 4 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/99/356799/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index 0fd6b92..b80bcab 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -900,7 +900,6 @@
 
// Do any deferred jobs
DeferredUpdates::doUpdates( 'enqueue' );
-   DeferredUpdates::setImmediateMode( true );
 
// Make sure any lazy jobs are pushed
JobQueueGroup::pushLazyJobs();
diff --git a/includes/deferred/DeferredUpdates.php 
b/includes/deferred/DeferredUpdates.php
index bbe8687..9f5b31a 100644
--- a/includes/deferred/DeferredUpdates.php
+++ b/includes/deferred/DeferredUpdates.php
@@ -55,8 +55,6 @@
private static $preSendUpdates = [];
/** @var DeferrableUpdate[] Updates to be deferred until after request 
end */
private static $postSendUpdates = [];
-   /** @var bool Whether to just run updates in addUpdate() */
-   private static $immediateMode = false;
 
const ALL = 0; // all updates; in web requests, use only after flushing 
the output buffer
const PRESEND = 1; // for updates that should run before flushing 
output buffer
@@ -88,12 +86,6 @@
self::push( self::$preSendUpdates, $update );
} else {
self::push( self::$postSendUpdates, $update );
-   }
-
-   if ( self::$immediateMode ) {
-   // No more explicit doUpdates() calls will happen, so 
run this now
-   self::doUpdates( 'run' );
-   return;
}
 
// Try to run the updates now if in CLI mode and no transaction 
is active.
@@ -140,9 +132,10 @@
/**
 * @param bool $value Whether to just immediately run updates in 
addUpdate()
 * @since 1.28
+* @deprecated 1.29 Causes issues in Web-executed jobs - see T165714 
and T100085.
 */
public static function setImmediateMode( $value ) {
-   self::$immediateMode = (bool)$value;
+   wfDeprecated( __METHOD__, '1.29' );
}
 
/**
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index 6415533..a1aeaba 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -291,6 +291,8 @@
$this->commitMasterChanges( $lbFactory, $job, 
$fnameTrxOwner );
// Run any deferred update tasks; doUpdates() manages 
transactions itself
DeferredUpdates::doUpdates();
+   // Push lazy jobs added by the job or its deferred 
udpates
+   JobQueueGroup::pushLazyJobs();
} catch ( Exception $e ) {
MWExceptionHandler::rollbackMasterChangesAndLog( $e );
$status = false;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_29
Gerrit-Owner: Seb35 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Use AtomicSectionUpdate instead of Database->onTransactionIdle

2017-06-01 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356619 )

Change subject: Use AtomicSectionUpdate instead of Database->onTransactionIdle
..

Use AtomicSectionUpdate instead of Database->onTransactionIdle

This is needed for deferred updates LinksDeletionUpdate and LinksUpdate, else
callbacks registered with onTransactionIdle prevent other transactions from
being executed, at least in this case.

Bug: T154425
Bug: T154438
Bug: T157679
Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
---
M includes/jobqueue/JobQueueDB.php
1 file changed, 7 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/19/356619/1

diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 924aacc..3545ac0 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -185,15 +185,13 @@
 * @return void
 */
protected function doBatchPush( array $jobs, $flags ) {
-   $dbw = $this->getMasterDB();
-
-   $method = __METHOD__;
-   $dbw->onTransactionIdle(
-   function () use ( $dbw, $jobs, $flags, $method ) {
-   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $method );
-   },
-   __METHOD__
-   );
+   DeferredUpdates::addUpdate( new AtomicSectionUpdate(
+   wfGetDB( DB_MASTER ),
+   __METHOD__,
+   function ( IDatabase $dbw, $fname ) use ( $jobs, $flags 
) {
+   $this->doBatchPushInternal( $dbw, $jobs, 
$flags, $fname );
+   }
+   ) );
}
 
/**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iecd396d584a62ac936cd963915339159467b44cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: More properly close MediaWiki jobs

2017-05-29 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/356120 )

Change subject: More properly close MediaWiki jobs
..

More properly close MediaWiki jobs

In the postprocessing, some jobs can be executed but given the deferred
updates are already "closed", any new DeferredUpdate is directly called
(as explained by Krinkle on T165714), and some transactions opened by
classical jobs are badly mixed with transactions (directly) executed by
DeferredUpdates jobs, issueing a DBError, avoiding the job, which stays
in a 'claimed' status even if failed.

This change inhibits the run-immediately-deferred-updates behaviour even
in the postprocessing, instead a second call to doUpdates is done after
classical jobs (executed at the end of the Web request), so that if
the classical jobs add DeferredUpdates they are executed.

It remains in my error log an error about transactions during the first
call of doUpdates; I guess it is another issue.

Bug: T165714
Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
---
M includes/MediaWiki.php
M includes/deferred/DeferredUpdates.php
2 files changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/20/356120/1

diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index b18414d..6dd2322 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -911,6 +911,9 @@
$this->triggerJobs();
}
 
+   // Rerun deferred jobs if normal jobs added some
+   DeferredUpdates::doUpdates( 'enqueue' );
+
// Log profiling data, e.g. in the database or UDP
wfLogProfilingData();
 
diff --git a/includes/deferred/DeferredUpdates.php 
b/includes/deferred/DeferredUpdates.php
index bbe8687..a328a43 100644
--- a/includes/deferred/DeferredUpdates.php
+++ b/includes/deferred/DeferredUpdates.php
@@ -91,8 +91,6 @@
}
 
if ( self::$immediateMode ) {
-   // No more explicit doUpdates() calls will happen, so 
run this now
-   self::doUpdates( 'run' );
return;
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I721e7167eca5b0b6227234fe516005243ab22388
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Refactoring: extraction of configuration compilation

2017-05-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/355633 )

Change subject: Refactoring: extraction of configuration compilation
..

Refactoring: extraction of configuration compilation

The main class MediaWikiFarm had a lot of responsabilities, one of those was
to compile configuration for a specific wiki. This commits splits out this
configuration compilation into a dedicated class. In number of lines, the
main class MediaWikiFarm drops from 2030 to 1427.

This is a first step to more refactoring to create smaller functions and
possibly multiple classes, in order to facilitate long-term maintenance and
improve understanding. Possibly the 'existence' feature inside the main
class will be also splitted out into a dedicated class, which would become
sort of a (dependency injection) container.

Change-Id: I54d4d2739215f9cc4f59fb2671d2cd7e797d16f9
---
M extension.json
M src/MediaWikiFarm.php
M src/MediaWikiFarmComposerScript.php
A src/MediaWikiFarmConfiguration.php
M tests/perfs/MediaWikiFarmTestPerfs.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/MediaWikiFarmComposerScriptTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
11 files changed, 1,038 insertions(+), 784 deletions(-)


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

diff --git a/extension.json b/extension.json
index 0526ebb..5bd8da9 100644
--- a/extension.json
+++ b/extension.json
@@ -29,6 +29,7 @@
},
"AutoloadClasses": {
"MediaWikiFarm": "src/MediaWikiFarm.php",
+   "MediaWikiFarmConfiguration": 
"src/MediaWikiFarmConfiguration.php",
"AbstractMediaWikiFarmScript": 
"src/AbstractMediaWikiFarmScript.php",
"MediaWikiFarmScript": "src/MediaWikiFarmScript.php",
"MediaWikiFarmHooks": "src/Hooks.php",
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 6705369..f269008 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -11,6 +11,10 @@
  * PHP 5.2+, so please do not use "new" syntaxes (namespaces, 
arrays with [], etc.).
  */
 
+// @codeCoverageIgnoreStart
+require_once dirname( __FILE__ ) . '/MediaWikiFarmConfiguration.php';
+// @codeCoverageIgnoreEnd
+
 /**
  * Exception triggered when a configuration file is “wrong” or other internal 
issue.
  *
@@ -74,19 +78,8 @@
'$CODE' => '',
);
 
-   /** @var array Environment. */
-   protected $environment = array(
-   'ExtensionRegistry' => null,
-   );
-
-   /** @var array Configuration parameters for this wiki. */
-   protected $configuration = array(
-   'settings' => array(),
-   'arrays' => array(),
-   'extensions' => array(),
-   'execFiles' => array(),
-   'composer' => array(),
-   );
+   /** @var MediaWikiFarmConfiguration|null Object containing the 
configuration of the current (single) wiki. */
+   protected $configuration = null;
 
/** @var array Logs. */
public $log = array();
@@ -110,6 +103,32 @@
return $this->state[$key];
}
return null;
+   }
+
+   /**
+* Get farm this farm code directory.
+*
+* @api
+* @mediawikifarm-const
+* @mediawikifarm-idempotent
+*
+* @return string|null Farm code directory.
+*/
+   function getFarmDir() {
+   return $this->farmDir;
+   }
+
+   /**
+* Get config directory.
+*
+* @api
+* @mediawikifarm-const
+* @mediawikifarm-idempotent
+*
+* @return string|null Config directory.
+*/
+   function getConfigDir() {
+   return $this->configDir;
}
 
/**
@@ -198,23 +217,19 @@
 * @api
 * @mediawikifarm-const
 *
-* @param string|null $key Key of the wanted section or null for the 
whole array.
-* @param string|null $key2 Subkey (specific to each entry) or null for 
the whole entry.
-* @return array MediaWiki configuration, either entire, either a part 
depending on the parameter.
+* @param string|false|null $key Key of the wanted section or false for 
the whole array or null for the object configuration.
+* @param string|false $key2 Subkey (specific to each entry) or false 
for the whole entry.
+* @return array|MediaWikiFarmConfiguration MediaWiki configuration, 
either entire, either a part depending on the parameter, or the configuration 
object.
 */
-   function getConfiguration( $key = null, $key2 = null ) {
-   if( $key !== null ) {
-   if( array_key_exists( $key, 

[MediaWiki-commits] [Gerrit] mediawiki...Flow[REL1_28]: Fix warnings and bugs in generateForwardedCookieForCli()

2017-05-22 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/355088 )

Change subject: Fix warnings and bugs in generateForwardedCookieForCli()
..

Fix warnings and bugs in generateForwardedCookieForCli()

WebResponse's cookie data structure changed in c3dc3985,
so the elements of the cookie array are now arrays, not strings.
Use $value['value'] instead of $value to get the correct cookie
value and avoid "array to string conversion" warnings.

Also, c3dc3985 added a public getCookies() method, so we don't
need to use a reflection hack to get to the cookie data structure
any more.

Bug: T149579
Change-Id: I4ec67505a581c5d55e1e59b9cfa069ca5f722be9
(cherry picked from commit 502de3986c37ded4715770055fabcceb8df25f81)
---
M includes/Conversion/Utils.php
1 file changed, 2 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/88/355088/1

diff --git a/includes/Conversion/Utils.php b/includes/Conversion/Utils.php
index 56908df..512800f 100644
--- a/includes/Conversion/Utils.php
+++ b/includes/Conversion/Utils.php
@@ -453,16 +453,13 @@
if ( !$response instanceof FauxResponse ) {
throw new FlowException( 'Expected a FauxResponse in 
CLI environment' );
}
-   // FauxResponse does not yet expose the full set of cookies
-   $reflProp = new \ReflectionProperty( $response, 'cookies' );
-   $reflProp->setAccessible( true );
-   $cookies = $reflProp->getValue( $response );
+   $cookies = $response->getCookies();
 
// now we need to convert the array into the cookie format of
// foo=bar; baz=bang
$output = array();
foreach ( $cookies as $key => $value ) {
-   $output[] = "$wgCookiePrefix$key=$value";
+   $output[] = "$wgCookiePrefix$key={$value['value']}";
}
 
return implode( '; ', $output );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ec67505a581c5d55e1e59b9cfa069ca5f722be9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: REL1_28
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Catrope 

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


[MediaWiki-commits] [Gerrit] mediawiki...SecureSessions[master]: Better escaping

2017-05-21 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/354999 )

Change subject: Better escaping
..

Better escaping

In French, the special page Session displays " Adresse IP: "
because of a parser rule + HTML-escaping. This patch request a text
version of three messages instead of a wikitext version.

Change-Id: I852c1814d9ef84daf83c5f30dcf5fbea5ec74b06
---
M SpecialSessions.php
1 file changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecureSessions 
refs/changes/99/354999/1

diff --git a/SpecialSessions.php b/SpecialSessions.php
index f797e62..7b85365 100644
--- a/SpecialSessions.php
+++ b/SpecialSessions.php
@@ -83,11 +83,11 @@
// Make a table describing the session.
$description = Html::rawElement( 'table', array(),
Html::rawElement( 'tr', array(),
-   Html::element( 'td', array( 'class' => 
'mw-label' ), $this->msg( 'securesessions-sessions-ip' ) ) .
+   Html::element( 'td', array( 'class' => 
'mw-label' ), $this->msg( 'securesessions-sessions-ip' )->escaped() ) .
Html::element( 'td', array( 'class' => 
'mw-input' ), $session['ip'] )
) .
Html::rawElement( 'tr', array(),
-   Html::element( 'td', array( 'class' => 
'mw-label' ), $this->msg( 'securesessions-sessions-activity' ) ) .
+   Html::element( 'td', array( 'class' => 
'mw-label' ), $this->msg( 'securesessions-sessions-activity' )->escaped() ) .
Html::element( 'td', array( 'class' => 
'mw-input' ), $timestamp->getHumanTimestamp() )
)
);
@@ -119,7 +119,7 @@
 
$form = new HTMLForm( $this->fields, $this->getContext() );
$form->setSubmitCallback( array( $this, 'onSubmit' ) );
-   $form->setWrapperLegend( $this->msg( 
'securesessions-sessions-legend' ) );
+   $form->setWrapperLegend( $this->msg( 
'securesessions-sessions-legend' )->text() );
$form->addHeaderText(
$this->msg( 'securesessions-sessions-text' 
)->parseAsBlock() );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I852c1814d9ef84daf83c5f30dcf5fbea5ec74b06
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecureSessions
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: [i18n] Names of the new content models

2017-05-19 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/354543 )

Change subject: [i18n] Names of the new content models
..

[i18n] Names of the new content models

Bug: T155520
Change-Id: Ieed33bfd8773ab4ca07c3fc49ecef34f25456457
---
M i18n/en.json
M i18n/qqq.json
2 files changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/43/354543/1

diff --git a/i18n/en.json b/i18n/en.json
index e3da5bf..8118bf6 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -82,7 +82,8 @@
"proofreadpage-indexoai-error-schemanotfound-text": "The $1 schema have 
not been found.",
"proofreadpage-disambiguationspage": "Template:disambig",
"proofreadpage-indexquality-alt": "$1 validated 
{{PLURAL:$1|page|pages}}, $2 only proofread {{PLURAL:$2|page|pages}} and $3 not 
proofread {{PLURAL:$3|page|pages}}",
-   "content-model-proofread-page": "Page: page",
+   "content-model-proofread-page": "Book page",
+   "content-model-proofread-index": "Book index",
"apihelp-query+proofread-description": "Returns information about the 
current proofread status of the given pages.",
"apihelp-query+proofread-example-1": "Return proofread status for pages 
in namespace 250",
"apihelp-query+proofreadinfo-description": "Return information about 
configuration of ProofreadPage extension.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d45aa14..2d9ca69 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -108,6 +108,7 @@
"proofreadpage-disambiguationspage": "This message is the name of the 
template used for marking disambiguation pages. It is used to find all pages 
which link to disambiguation pages.\n\n{{doc-important|Don't translate the 
\"Template:\" part!}}\n{{Identical|Template:disambig}}",
"proofreadpage-indexquality-alt": "Textual alternative for display of 
proofreading level of the book. Parameters:\n* $1 is the number of validated 
pages.\n* $2 is the number of only proofread pages.\n* $3 is the number of not 
proofread pages.",
"content-model-proofread-page": "The name for Page: pages item content 
model, used when describing what type of content a page contains.",
+   "content-model-proofread-index": "The name for Index: pages item 
content model, used when describing what type of content a page contains.",
"apihelp-query+proofread-description": 
"{{doc-apihelp-description|query+proofread}}",
"apihelp-query+proofread-example-1": 
"{{doc-apihelp-example|query+proofread}}",
"apihelp-query+proofreadinfo-description": 
"{{doc-apihelp-description|query+proofreadinfo}}",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieed33bfd8773ab4ca07c3fc49ecef34f25456457
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Typo

2017-04-23 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/349794 )

Change subject: Typo
..

Typo

And added some missing parameter to make it explicit instead of implicit.

Change-Id: Ife3fc738c673b3516be5fda0c7cb270e162dbe6d
---
M src/AbstractMediaWikiFarmScript.php
M src/MediaWikiFarmComposerScript.php
M src/MediaWikiFarmScript.php
M tests/perfs/MediaWikiFarmTestPerfs.php
M tests/perfs/perfs.php
M tests/phpunit/MediaWikiFarmTestCase.php
6 files changed, 25 insertions(+), 19 deletions(-)


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

diff --git a/src/AbstractMediaWikiFarmScript.php 
b/src/AbstractMediaWikiFarmScript.php
index efe3705..caa0659 100644
--- a/src/AbstractMediaWikiFarmScript.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -65,7 +65,7 @@
/**
 * Get a command line parameter.
 *
-* The parameter can be removed from the list.
+* Optionally the parameter can be removed from the list.
 *
 * @internal
 *
@@ -99,7 +99,7 @@
 
# Search a positional parameter
elseif( is_int( $name ) ) {
-   if( $name >= $this->argc ) {
+   if( $name < 0 || $name >= $this->argc ) {
return null;
}
$value = $this->argv[$name];
@@ -123,7 +123,7 @@
 * @api
 *
 * @param bool $long Show extended usage.
-* @return void.
+* @return void
 */
function usage( $long = false ) {
 
@@ -148,7 +148,7 @@
 * @api
 * @codeCoverageIgnore
 *
-* @return void.
+* @return void
 */
function load() {
 
@@ -158,6 +158,7 @@
$wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) 
) );
$wgMediaWikiFarmConfigDir = '/etc/mediawiki';
$wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
+   $wgMediaWikiFarmSyslog = 'mediawikifarm';
 
if( is_file( dirname( dirname( dirname( dirname( __FILE__ ) ) ) 
) . '/includes/DefaultSettings.php' ) ) {
 
@@ -183,7 +184,7 @@
 *
 * @api
 *
-* @return void.
+* @return void
 */
function exportArguments() {
 
@@ -231,7 +232,7 @@
 *
 * @api
 *
-* @return void.
+* @return void
 */
function restInPeace() {}
 
@@ -242,13 +243,13 @@
 * - */
 
/**
-* Recursively delete a directory.
+* Delete recursively a directory or a file.
 *
 * @api
 *
-* @param string $dir Directory path.
-* @param bool $deleteDir Delete the root directory (or leave it empty).
-* @return void.
+* @param string $dir Directory or file path.
+* @param bool $deleteDir Delete the root directory? (Else leave it 
empty.)
+* @return void
 */
static function rmdirr( $dir, $deleteDir = true ) {
 
@@ -281,12 +282,12 @@
 * @param string $source Source path, can be a normal file or a 
directory.
 * @param string $dest Destination path, should be a directory.
 * @param bool $force If true, delete the destination directory before 
beginning.
-* @param string[] $blacklist Regular expression to blacklist some 
files; if begins
+* @param string[] $blacklist Regular expressions to blacklist some 
files; if it begins
 * with '/', only files from the root directory will be 
considered.
-* @param string[] $whitelist Regular expression to whitelist only some 
files; if begins
+* @param string[] $whitelist Regular expression to whitelist only some 
files; if it begins
 * with '/', only files from the root directory will be 
considered.
 * @param string $base Internal parameter to track the base directory.
-* @return void.
+* @return void
 */
static function copyr( $source, $dest, $force = false, $blacklist = 
array(), $whitelist = null, $base = '' ) {
 
diff --git a/src/MediaWikiFarmComposerScript.php 
b/src/MediaWikiFarmComposerScript.php
index cb48d07..ea755b4 100644
--- a/src/MediaWikiFarmComposerScript.php
+++ b/src/MediaWikiFarmComposerScript.php
@@ -62,7 +62,7 @@
 *
 * @api
 *
-* @return void.
+* @return void
 */
function main() {
 
diff --git a/src/MediaWikiFarmScript.php b/src/MediaWikiFarmScript.php
index 5d23178..3ec6e88 100644
--- a/src/MediaWikiFarmScript.php
+++ b/src/MediaWikiFarmScript.php
@@ -146,7 +146,7 @@
 *
 * @api
 *
-* @return void.
+* @return void
 */
function restInPeace() {
 
diff --git 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improve cache consistency

2017-04-23 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/349785 )

Change subject: Improve cache consistency
..

Improve cache consistency

* Check if origin file is still present, else cache is considered outdated
* When the main cache file becomes outdated, delete also the other cache files
  to avoid cache inconsistency.

Change-Id: I487ffdc8b806f807ecd2a8d9010bee8ba05821db
---
M src/MediaWikiFarm.php
1 file changed, 10 insertions(+), 3 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 055e529..6705369 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -712,7 +712,8 @@
$fresh = true;
$myfreshness = filemtime( $this->cacheDir . '/wikis/' . 
$host . '.php' );
foreach( $result['$CORECONFIG'] as $coreconfig ) {
-   if( filemtime( $this->configDir . '/' . 
$coreconfig ) > $myfreshness ) {
+   if( !is_file( $this->configDir . '/' . 
$coreconfig ) ||
+   filemtime( $this->configDir . '/' . 
$coreconfig ) > $myfreshness ) {
$fresh = false;
break;
}
@@ -723,8 +724,14 @@
unset( $result['$CORECONFIG'] );
$this->variables = $result;
return;
-   } elseif( is_file( $this->cacheDir . '/LocalSettings/' 
. $host . '.php' ) ) {
-   unlink( $this->cacheDir . '/LocalSettings/' . 
$host . '.php' );
+   } else {
+   unlink( $this->cacheDir . '/wikis/' . $host . 
'.php' );
+   if( is_file( $this->cacheDir . 
'/LocalSettings/' . $host . '.php' ) ) {
+   unlink( $this->cacheDir . 
'/LocalSettings/' . $host . '.php' );
+   }
+   if( is_file( $this->cacheDir . '/composer/' . 
$host . '.php' ) ) {
+   unlink( $this->cacheDir . '/composer/' 
. $host . '.php' );
+   }
}
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I487ffdc8b806f807ecd2a8d9010bee8ba05821db
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add a timeout in wfShellExec

2017-04-10 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/347417 )

Change subject: Add a timeout in wfShellExec
..

Add a timeout in wfShellExec

In wfShellExec the function stream_select waits indefinitely until some
data comes; in some race cases it really hangs indefinitely the normal
execution of MediaWiki. One such race case is when more than 1024 files
are opened simultaneously and when PHP is compiled with FD_SETSIZE=1024;
it can be the case in some shared webservers or with PHPDBG during unit
tests.

This patch adds a timeout of 10 seconds (something like “very long” but
anyway bounded) and a condition to loop without reading the file
descriptors if no one is changed (which occurs when the timeout is
reached).

Bug: T72357
Change-Id: I506bfef7cd10ae137c33907fd056caa15000a51f
---
M includes/GlobalFunctions.php
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/17/347417/1

diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 3747c23..182d920 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -2429,7 +2429,7 @@
$eintrMessage = "stream_select(): unable to select [$eintr]";
 
$running = true;
-   $timeout = null;
+   $timeout = 10;
$numReadyPipes = 0;
 
while ( $running === true || $numReadyPipes !== 0 ) {
@@ -2459,6 +2459,9 @@
$logMsg = $error['message'];
break;
}
+   } elseif ( $numReadyPipes === 0 ) {
+   // Timeout for now, continue until some data arrives
+   continue;
}
foreach ( $readyPipes as $fd => $pipe ) {
$block = fread( $pipe, 65536 );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I506bfef7cd10ae137c33907fd056caa15000a51f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Prevent PHPDBG from issuing notices in unit tests

2017-04-10 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/347355 )

Change subject: Prevent PHPDBG from issuing notices in unit tests
..

Prevent PHPDBG from issuing notices in unit tests

Although issuing PHP notices in unit tests is only a nice-to-have, the cause
is PHPDBG has no special treatment in JobQueueGroup at the contrary of the
PHP SAPI 'cli', and it may be desirable both 'command line SAPIs' have the
same behaviour.

This is the most apparent difference between cli and phpdbg but there could
be a dozen of other occurrences (see bug), potentially creating differences
in unit tests depending on the SAPI.

Bug: T162591
Change-Id: Idf9c14db72f1f768c5a17b49ed689a05922c57d3
---
M includes/jobqueue/JobQueueGroup.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/347355/1

diff --git a/includes/jobqueue/JobQueueGroup.php 
b/includes/jobqueue/JobQueueGroup.php
index 71d68d9..9f78404 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -170,7 +170,7 @@
 * @since 1.26
 */
public function lazyPush( $jobs ) {
-   if ( PHP_SAPI === 'cli' ) {
+   if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
$this->push( $jobs );
return;
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf9c14db72f1f768c5a17b49ed689a05922c57d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Execute mwcomposer just like composer

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

Change subject: Execute mwcomposer just like composer
..

Execute mwcomposer just like composer

Previously mwcomposer selected the directory according to a configured wiki,
but it introduces a chicken-and-egg problem when you want to upgrade: you
create a new MediaWiki installation in another directory, change some wiki
to this new version even if no Composer was run (and MediaWiki publicly
complains on the Web), you run mwcomposer with this wiki, and then it works,
and you can run update.php for each wiki.

The trick could be to use a junk wiki, but this is now solved: now you
prepare your new MediaWiki version, run mwcomposer just like you would have
run composer, and then switch each wiki to this new version and run update.php
for each wiki.

By the way, wrote some documentation in docs/scripts.rst.

Change-Id: I150e805bc32f7329784a501e75d7faf218e389e4
---
M docs/scripts.rst
M src/MediaWikiFarmComposerScript.php
M tests/phpunit/MediaWikiFarmComposerScriptTest.php
3 files changed, 57 insertions(+), 135 deletions(-)


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

diff --git a/docs/scripts.rst b/docs/scripts.rst
index 66e5ff9..5af70b0 100644
--- a/docs/scripts.rst
+++ b/docs/scripts.rst
@@ -4,6 +4,7 @@
 
 Here are detailled the scripts provided with MediaWikiFarm:
 * :command:`mwscript` to execute a MediaWiki maintenance script in the context 
of a farm
+* :command:`mwcomposer` to install Composer dependencies and give the 
opportunity to activate per-wiki a Composer-managed MediaWiki extension
 * :command:`validate-schema` to validate the main config file
 
 mwscript
@@ -16,4 +17,17 @@
 
 For your convenience, you can add it as an alias in your ~/.bashrc. The exact 
command is given when you run :command:`php mwscript.php --help`. With this 
alias, the command becomes :command:`mwscript update --wiki=mywiki.example.org`.
 
+mwcomposer
+==
 
+:command:`mwcomposer` is very similar to :command:`composer` (and this one 
must be installed and is called) but creates a modified `vendor` directory 
(with multiple Composer autoloaders, a modified file `autoload.php`, and a 
added file `MediaWikiExtensions.php`) to activate per-wiki Composer-managed 
MediaWiki extensions. If you directly run :command:`composer` instead of 
:command:`mwcomposer` it will also "work", but all Composer-managed MediaWiki 
extensions will be activated on all wikis using this MediaWiki version 
(possibly some extensions have custom mechanisms to prevent themselves from 
being activated without specific parameters).
+
+To run this script, you must add in your `composer.json` or 
`composer.local.json` your Composer-managed MediaWiki extensions (and skins), 
then run this script in the MediaWiki directory just like you would have run 
Composer.
+
+Internally this script:
+* run Composer with the original composer.json, so that if there are 
incompatibilities between some Composer-managed MediaWiki extensions, you are 
warned;
+* run Composer one time per extension (so N Composer runs) by crafting the 
composer.json as if only the extension was the only one activated extension;
+* run Composer without any extension;
+* install MediaWiki extensions and skins in their standard directories;
+* create a `vendor` directory with all Composer libraries, N Composer 
autoloader per MediaWiki extension, 1 Composer autoloader without any MediaWiki 
extension, a specific autoloader in place of `autoload.php`, and one 
`MediaWikiExtensions.php`.
+Note that each Composer run is done in a temporary directory to avoid issues 
with the real MediaWiki directory. At runtime, the `autoload.php` file requests 
MediaWikiFarm to known what Composer-managed MediaWiki extensions are enabled 
and loads their autoloaders. The file `MediaWikiExtensions.php` is used by 
MediaWikiFarm during configuration compilation (to create the 
`LocalSettings.php` files) to know the dependency graph between 
Composer-managed MediaWiki extensions (given Composer computes and respects the 
dependencies, MediaWikiFarm should be aware of these dependencies).
diff --git a/src/MediaWikiFarmComposerScript.php 
b/src/MediaWikiFarmComposerScript.php
index 54da9bd..cb48d07 100644
--- a/src/MediaWikiFarmComposerScript.php
+++ b/src/MediaWikiFarmComposerScript.php
@@ -36,11 +36,11 @@
parent::__construct( $argc, $argv );
 
$this->shortUsage = "
-Usage: php {$this->argv[0]} --wiki=hostname …
+Usage: php {$this->argv[0]} …
 
-Parameters:
+You must be inside a Composer-managed MediaWiki directory.
 
-  - hostname: hostname of the wiki, e.g. \"mywiki.example.org\"
+Parameters: regular Composer parameters
 ";
 
$fullPath = realpath( $this->argv[0] );
@@ -50,7 +50,6 @@
 |
 | Return codes:
 | 0 = 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: [WIP] Support for farms given by subdirectories in addition ...

2017-03-26 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344881 )

Change subject: [WIP] Support for farms given by subdirectories in addition of 
subdomains
..

[WIP] Support for farms given by subdirectories in addition of subdomains

In the config file farms.yml one can now use subdirectories; subdirectories 
should
be caught in a variable to retrieve the wiki name exactly as in subdomains;
possibly the server regex can mix subdomains and subdirectories.

Bug: T161413
Change-Id: Ic906b84315150abc8fff90e6db23d47b27707902
---
M docs/configuration.rst
M docs/farms-schema.json
M docs/versions-schema.json
M src/MediaWikiFarm.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/LoggingTest.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
M tests/phpunit/data/config/farms.php
12 files changed, 312 insertions(+), 48 deletions(-)


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

diff --git a/docs/configuration.rst b/docs/configuration.rst
index 2b34109..3974618 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -59,7 +59,7 @@
 Server
 --
 
-The most important subkey is 'server': it is a regular expression of the 
server name/domain name. There should be only one regex, which matchs a given 
server name. It is recommanded to use named patterns in the regex to capture 
parts of the server name to construct the wikiID and suffix.
+The most important subkey is 'server': it is a regular expression of the 
server name/domain name and possibly of the subdirectory (or even multiple 
subdirectories). There should be only one regex, which matchs a given server 
name. It is recommanded to use named patterns in the regex to capture parts of 
the server name to construct the wikiID and suffix.
 
 Redirect
 
diff --git a/docs/farms-schema.json b/docs/farms-schema.json
index ab0882f..1967196 100644
--- a/docs/farms-schema.json
+++ b/docs/farms-schema.json
@@ -19,8 +19,8 @@
"properties": {
"server": {
"type": "string",
-   "description": "Regular 
expression of the server names.",
-   "pattern": 
"^[a-zA-Z0-9\\[\\]\\(\\)<>.*?+_|-]+$"
+   "description": "Regular 
expression of the server name and subdirectory.",
+   "pattern": 
"^[a-zA-Z0-9\\[\\]\\(\\)/<>.*?+_|-]+$"
},
"variables": {
"type": "array",
@@ -119,8 +119,8 @@
"properties": {
"server": {
"type": "string",
-   "description": "Regular 
expression of the server name.",
-   "pattern": 
"^[a-zA-Z0-9\\[\\]\\(\\)<>.*?+_|-]+$"
+   "description": "Regular 
expression of the server name and subdirectory.",
+   "pattern": 
"^[a-zA-Z0-9\\[\\]\\(\\)/<>.*?+_|-]+$"
},
"redirect": {
"type": "string",
diff --git a/docs/versions-schema.json b/docs/versions-schema.json
index 0c382d5..d0d7d52 100644
--- a/docs/versions-schema.json
+++ b/docs/versions-schema.json
@@ -21,7 +21,7 @@
"$SERVER": {
"type": "string",
"description": "Server 
host (must be the same as the first key in the hierarchy).",
-   "pattern": 
"^[a-zA-Z0-9\\._-]+$"
+   "pattern": 
"^[a-zA-Z0-9\\./_-]+$"
},
"$SUFFIX": {
"type": "string",
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 58a1723..731f70e 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -234,18 +234,19 @@
 *
 * @param string $entryPoint Name of the entry 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Wrong PHP version for phpDocumentor2

2017-03-26 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344831 )

Change subject: Wrong PHP version for phpDocumentor2
..

Wrong PHP version for phpDocumentor2

Obviously I carefully crafted the previous commit and forgot a minor thing…

Change-Id: Id10fc4fd6b8ac4572463896867958ad42c06b67b
---
M composer.json
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/composer.json b/composer.json
index f55954c..4c82176 100644
--- a/composer.json
+++ b/composer.json
@@ -41,7 +41,7 @@
"unit": "phpunit --no-coverage",
"phpunit": "which phpdbg && phpdbg -qrr `which phpunit` 
--strict-coverage || phpunit --strict-coverage",
"phpcs": "phpcs -p -s",
-   "phpdoc": "[ \"`which phpdoc`\" = \"\" ] || php7.1 `which 
phpdoc` --target=./docs/code --cache-folder=./docs/code/cache --directory=. 
--ignore='vendor/*,docs/*,tests/phpunit/data/*' --title=MediaWikiFarm 
--defaultpackagename='\\' --template=responsive-twig --parseprivate",
+   "phpdoc": "[ \"`which phpdoc`\" = \"\" ] || php `which phpdoc` 
--target=./docs/code --cache-folder=./docs/code/cache --directory=. 
--ignore='vendor/*,docs/*,tests/phpunit/data/*' --title=MediaWikiFarm 
--defaultpackagename='\\' --template=responsive-twig --parseprivate",
"test": [
"composer lint",
"composer unit",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id10fc4fd6b8ac4572463896867958ad42c06b67b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Documentation and heavy testing

2017-03-26 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344830 )

Change subject: Documentation and heavy testing
..

Documentation and heavy testing

Documentation:
* Configured phpDocumentor2 to report issue in all directories, notably /tests
* Fixed all phpDocumentor2 errors
* Added @api or @internal on runtime methods
* Added @package on all classes and functions
* Added PHPDoc on placeholder functions (attributed them @package MediaWiki)
* The first line of PHPDoc is always a single line ending with a period or a 
question mark
* Added some metadata in composer.json and extension.json
* The file PHPDoc is always only the classes and functions contained in the 
file, no more description

Code:
* Removed a duplicate function (rmdirr as function and public static method)
* Registered the config parameter $wgMediaWikiFarmSyslog in extension.json

Testing:
* Tested with PHP 7.2.0-dev (php+phpdbg) with PHPUnit 4.8.35, 5.7.17, 6.0.10, 
6.1-dev
* Tested with PHP 7.1.0 (php+phpdbg) with PHPUnit 4.8.35, 5.7.17, 6.0.10, 
6.1-dev
* Tested with PHP 7.0.16 (php+phpdbg) with PHPUnit 4.8.35, 5.7.17, 6.0.10, 
6.1-dev
* Tested with PHP 5.6.30 (php+phpdbg) with PHPUnit 4.8.35, 5.7.17
* Tested with PHP 5.2.17 (php) with PHPUnit 3.4.15
* Strict code coverage always passes with 100%
* Wrote a doc in docs/tests.rst about PHP 5.2 since I do not let some PHP 5.2 
oddities in tests
* Fixed a failed test with PHP 5.2 because PHPUnit 3.4 does not restore working 
directory between tests
* Changed assertEmpty to assertEquals( array(), … ) to make PHPUnit 3.4 happy
* When standalone PHPUnit is executed, MediaWikiFarmTestCase is either a 
subclass of
  PHPUnit_Framework_TestCase (PHPUnit < 6.0) or PHPUnit\Framework\TestCase 
(PHPUnit ≥ 6.0)
* Added scripts in composer.json for system PHP 5 (probably 5.6) and PHP 5.2 to 
facilitate
  tests for these versions

Change-Id: Icbce6af7a518acbc06c76b537252cb73a702beb6
---
M composer.json
M docs/index.rst
A docs/tests.rst
M extension.json
M src/AbstractMediaWikiFarmScript.php
M src/Hooks.php
M src/MediaWikiFarm.php
M src/MediaWikiFarmComposerScript.php
M src/MediaWikiFarmScript.php
M src/Yaml.php
M tests/perfs/MediaWikiFarmTestPerfs.php
M tests/perfs/index.php
M tests/perfs/perfs.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/FunctionsTest.php
M tests/phpunit/HooksTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/LoggingTest.php
M tests/phpunit/MediaWikiFarmComposerScriptTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
25 files changed, 379 insertions(+), 68 deletions(-)


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

diff --git a/composer.json b/composer.json
index 61956c2..f55954c 100644
--- a/composer.json
+++ b/composer.json
@@ -1,42 +1,69 @@
 {
"name": "mediawiki-extensions/media-wiki-farm",
"description": "Configuration management for MediaWiki farms.",
+   "version": "0.4.0",
"keywords": ["mediawiki"],
-   "homepage": "https://www.seb35.fr;,
+   "homepage": "https://www.mediawiki.org/wiki/Extension:MediaWikiFarm;,
+   "license": "GPL-3.0+",
"authors": [
{
"name": "Sébastien Beyou",
"homepage": "https://www.seb35.fr;
}
],
-   "license": "GPL-3.0+",
+   "support": {
+   "issues": 
"https://phabricator.wikimedia.org/tag/mediawiki-extensions-mediawikifarm;,
+   "wiki": 
"https://www.mediawiki.org/wiki/Extension:MediaWikiFarm;,
+   "source": "https://phabricator.wikimedia.org/diffusion/EMWF;
+   },
+
+
"require": {
"php": ">=5.2",
"symfony/yaml": "^2.0 || ^3.0"
},
"require-dev": {
"justinrainbow/json-schema": "~3.0",
-   "phpunit/phpunit": "~4.8",
+   "phpunit/phpunit": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"jakub-onderka/php-parallel-lint": "*",
"phpmd/phpmd": "*",
"mediawiki/mediawiki-codesniffer": "*"
},
"suggest": {
-   "phpdocumentor/phpdocumentor": "*"
+   "phpdocumentor/phpdocumentor": "phpDocumentor2 (^2.8) is 
supported for code documentation; you should install it as PHAR because of 
version contraints."
},
+
+
"scripts": {
"validate-schema": "php ./bin/validate-schema.php",
+
"lint": "parallel-lint --exclude vendor .",
-   "phpcs": "phpcs -p -s",
-   "phpdoc": "[ \"`which phpdoc`\" = \"\" ] || phpdoc -d bin,src 
-t ./docs/code",
-   "phpunit": "which 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Exclude .git in phpcs.xml instead of command line argument

2017-03-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344797 )

Change subject: Exclude .git in phpcs.xml instead of command line argument
..

Exclude .git in phpcs.xml instead of command line argument

In order to benefit of it in other PHP_CodeSniffer tools.
Thanks to Legoktm for this tip!

Change-Id: I6d8e2a4242f0b5ec4536da72a44a4fb2f9b9e2f2
---
M composer.json
M phpcs.xml
2 files changed, 2 insertions(+), 1 deletion(-)


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

diff --git a/composer.json b/composer.json
index 4ff65bd..61956c2 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,7 @@
"scripts": {
"validate-schema": "php ./bin/validate-schema.php",
"lint": "parallel-lint --exclude vendor .",
-   "phpcs": "phpcs -p -s --ignore=.git",
+   "phpcs": "phpcs -p -s",
"phpdoc": "[ \"`which phpdoc`\" = \"\" ] || phpdoc -d bin,src 
-t ./docs/code",
"phpunit": "which phpdbg && phpdbg -qrr `which phpunit` 
--strict-coverage || phpunit --strict-coverage",
"unit": "phpunit --no-coverage",
diff --git a/phpcs.xml b/phpcs.xml
index 6224889..9a172ae 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -32,4 +32,5 @@

tests/perfs/results
vendor
+   .git
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d8e2a4242f0b5ec4536da72a44a4fb2f9b9e2f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Restore 100% code coverage

2017-03-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344784 )

Change subject: Restore 100% code coverage
..

Restore 100% code coverage

Change-Id: I0adbef2d9113679b4793b41beb7a92621db198cc
---
M src/MediaWikiFarmComposerScript.php
M tests/phpunit/data/mediawiki/vstub/composer.json
2 files changed, 4 insertions(+), 1 deletion(-)


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

diff --git a/src/MediaWikiFarmComposerScript.php 
b/src/MediaWikiFarmComposerScript.php
index 42fd69e..93caaab 100644
--- a/src/MediaWikiFarmComposerScript.php
+++ b/src/MediaWikiFarmComposerScript.php
@@ -149,7 +149,7 @@
unset( 
$baseComposerJson['require'][$package['name']] );
}
if( array_key_exists( 'require-dev', 
$baseComposerJson ) && array_key_exists( $package['name'], 
$baseComposerJson['require-dev'] ) ) {
-   unset( 
$baseComposerJson['require-dev'][$package['name']] ); // @codeCoverageIgnore
+   unset( 
$baseComposerJson['require-dev'][$package['name']] );
}
$dependencies[$extensions[$package['name']]] = 
array_key_exists( 'require', $package ) ? array_keys( $package['require'] ) : 
array();
}
diff --git a/tests/phpunit/data/mediawiki/vstub/composer.json 
b/tests/phpunit/data/mediawiki/vstub/composer.json
index c3746c3..2b88fcb 100644
--- a/tests/phpunit/data/mediawiki/vstub/composer.json
+++ b/tests/phpunit/data/mediawiki/vstub/composer.json
@@ -4,5 +4,8 @@
"mediawiki/page-forms": "*",
"mediawiki/semantic-forms-select": "*",
"mediawiki/chameleon-skin": "*"
+   },
+   "require-dev": {
+   "mediawiki/page-forms": "*"
}
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0adbef2d9113679b4793b41beb7a92621db198cc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Fix bug when a mwcomposer was used but no Composer-managed e...

2017-03-25 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/344781 )

Change subject: Fix bug when a mwcomposer was used but no Composer-managed 
extension is activated
..


Fix bug when a mwcomposer was used but no Composer-managed extension is 
activated

When mwcomposer was used (hence a special vendor/autoload.php is installed) and
when no Composer-managed extension is activated, no Composer libraries is loaded
and MediaWiki is obviously complaining because there is no PSR-3 library.

The fix is simply to check if there are Composer-managed extensions activated
and else use the minimal Composer autoloader.

Change-Id: I3cf5e2826a92c0f27226621ca0259901299c65e3
---
M src/MediaWikiFarmComposerAutoloader.php
1 file changed, 8 insertions(+), 5 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/src/MediaWikiFarmComposerAutoloader.php 
b/src/MediaWikiFarmComposerAutoloader.php
index a6edfda..a279da5 100644
--- a/src/MediaWikiFarmComposerAutoloader.php
+++ b/src/MediaWikiFarmComposerAutoloader.php
@@ -6,14 +6,17 @@
 // @codeCoverageIgnoreStart
 if( array_key_exists( 'wgMediaWikiFarm', $GLOBALS ) ) {
$extensions = $GLOBALS['wgMediaWikiFarm']->getConfiguration( 'composer' 
);
-   foreach( $extensions as $extension ) {
+   if( count( $extensions ) > 0 ) {
+   foreach( $extensions as $extension ) {
 
-   require_once __DIR__ . '/composer' . substr( md5( $extension ), 
0, 8 ) . '/autoload_real.php';
-   call_user_func( array( 'ComposerAutoloaderInit' . substr( md5( 
$extension ), 0, 8 ), 'getLoader' ) );
+   require_once __DIR__ . '/composer' . substr( md5( 
$extension ), 0, 8 ) . '/autoload_real.php';
+   call_user_func( array( 'ComposerAutoloaderInit' . 
substr( md5( $extension ), 0, 8 ), 'getLoader' ) );
+   }
+   unset( $extensions );
+   unset( $extension );
+   return;
}
unset( $extensions );
-   unset( $extension );
-   return;
 }
 
 require_once __DIR__ . '/composer' . '/autoload_real.php';

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3cf5e2826a92c0f27226621ca0259901299c65e3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Hashar 
Gerrit-Reviewer: Seb35 
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...MediaWikiFarm[master]: Fix bug when a mwcomposer was used but no Composer-managed e...

2017-03-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344781 )

Change subject: Fix bug when a mwcomposer was used but no Composer-managed 
extension is activated
..

Fix bug when a mwcomposer was used but no Composer-managed extension is 
activated

When mwcomposer was used (hence a special vendor/autoload.php is installed) and
when no Composer-managed extension is activated, no Composer libraries is loaded
and MediaWiki is obviously complaining because there is no PSR-3 library.

The fix is simply to check if there are Composer-managed extensions activated
and else use the minimal Composer autoloader.

Change-Id: I3cf5e2826a92c0f27226621ca0259901299c65e3
---
M src/MediaWikiFarmComposerAutoloader.php
1 file changed, 8 insertions(+), 5 deletions(-)


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

diff --git a/src/MediaWikiFarmComposerAutoloader.php 
b/src/MediaWikiFarmComposerAutoloader.php
index a6edfda..a279da5 100644
--- a/src/MediaWikiFarmComposerAutoloader.php
+++ b/src/MediaWikiFarmComposerAutoloader.php
@@ -6,14 +6,17 @@
 // @codeCoverageIgnoreStart
 if( array_key_exists( 'wgMediaWikiFarm', $GLOBALS ) ) {
$extensions = $GLOBALS['wgMediaWikiFarm']->getConfiguration( 'composer' 
);
-   foreach( $extensions as $extension ) {
+   if( count( $extensions ) > 0 ) {
+   foreach( $extensions as $extension ) {
 
-   require_once __DIR__ . '/composer' . substr( md5( $extension ), 
0, 8 ) . '/autoload_real.php';
-   call_user_func( array( 'ComposerAutoloaderInit' . substr( md5( 
$extension ), 0, 8 ), 'getLoader' ) );
+   require_once __DIR__ . '/composer' . substr( md5( 
$extension ), 0, 8 ) . '/autoload_real.php';
+   call_user_func( array( 'ComposerAutoloaderInit' . 
substr( md5( $extension ), 0, 8 ), 'getLoader' ) );
+   }
+   unset( $extensions );
+   unset( $extension );
+   return;
}
unset( $extensions );
-   unset( $extension );
-   return;
 }
 
 require_once __DIR__ . '/composer' . '/autoload_real.php';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3cf5e2826a92c0f27226621ca0259901299c65e3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Fix bug about empty lists/objects in composer.json

2017-03-25 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344766 )

Change subject: Fix bug about empty lists/objects in composer.json
..

Fix bug about empty lists/objects in composer.json

During installation of Composer-managed MediaWiki extensions, the composer.json
is changed and sometimes the 'require' section becomes empty; this was
previously solved by adding the option JSON_FORCE_OBJECT in json_encode, but
this option transforms all lists to objects, which conflicts with standard
MediaWiki composer.json which contains real listes (e.g. 'authors') and Composer
stops because of schema error.

The solution implemented here is to remove the option JSON_FORCE_OBJECT and
remove the sections 'require-dev' and 'require' when they are empty to avoid
they are changed to an empty list. Added a list in the test composer.json to
avoid further regressions about this.

Change-Id: Id4b4017f69fd611b8b0e84b7b0b27ce3d326e624
---
M src/MediaWikiFarmComposerScript.php
M tests/phpunit/data/mediawiki/vstub/composer.json
2 files changed, 12 insertions(+), 2 deletions(-)


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

diff --git a/src/MediaWikiFarmComposerScript.php 
b/src/MediaWikiFarmComposerScript.php
index f46e232..42fd69e 100644
--- a/src/MediaWikiFarmComposerScript.php
+++ b/src/MediaWikiFarmComposerScript.php
@@ -154,6 +154,12 @@
$dependencies[$extensions[$package['name']]] = 
array_key_exists( 'require', $package ) ? array_keys( $package['require'] ) : 
array();
}
}
+
+   # Remove if empty, else it would create an empty JSON list but 
the schema expects it is an object (PHP has no
+   # such distinction); the option JSON_FORCE_OBJECT is not 
appropriate because it always transforms lists to objects
+   if( array_key_exists( 'require-dev', $baseComposerJson ) && 
count( $baseComposerJson['require-dev'] ) == 0 ) {
+   unset( $baseComposerJson['require-dev'] );
+   }
asort( $extensions );
ksort( $dependencies );
if( !$quiet ) {
@@ -196,7 +202,7 @@
}
 
self::rmdirr( 'vendor/autoload.php' );
-   file_put_contents( 'composer.json', json_encode( 
$thisInstallation, JSON_FORCE_OBJECT ) );
+   file_put_contents( 'composer.json', json_encode( 
$thisInstallation ) );
system( 'composer update ' . implode( ' ', $this->argv 
), $return );
if( $return ) {
// @codeCoverageIgnoreStart
@@ -216,13 +222,16 @@
# Finally the Composer set without any extension/skin
$thisInstallation = $baseComposerJson;
$thisInstallation['config']['autoloader-suffix'] = 'DEFAULT';
+   if( array_key_exists( 'require', $baseComposerJson ) && count( 
$baseComposerJson['require'] ) == 0 ) {
+   unset( $thisInstallation['require'] );
+   }
 
if( !$quiet ) {
echo "$icounter. Composer with empty extensions/skins 
set:\n"; // @codeCoverageIgnore
}
 
self::rmdirr( 'vendor/autoload.php' );
-   file_put_contents( 'composer.json', json_encode( 
$thisInstallation, JSON_FORCE_OBJECT ) );
+   file_put_contents( 'composer.json', json_encode( 
$thisInstallation ) );
system( 'composer update ' . implode( ' ', $this->argv ), 
$return );
if( $return ) {
// @codeCoverageIgnoreStart
diff --git a/tests/phpunit/data/mediawiki/vstub/composer.json 
b/tests/phpunit/data/mediawiki/vstub/composer.json
index 937df07..c3746c3 100644
--- a/tests/phpunit/data/mediawiki/vstub/composer.json
+++ b/tests/phpunit/data/mediawiki/vstub/composer.json
@@ -1,4 +1,5 @@
 {
+   "keywords": [],
"require": {
"mediawiki/page-forms": "*",
"mediawiki/semantic-forms-select": "*",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id4b4017f69fd611b8b0e84b7b0b27ce3d326e624
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Ignore directory .git in PHP_CodeSniffer

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

Change subject: Ignore directory .git in PHP_CodeSniffer
..

Ignore directory .git in PHP_CodeSniffer

Unfortunately I have a local branch ending with .php and phpcs is
checking it (and obviously is trigerring errors)

Change-Id: I11f121802c6bfce1723e71a65853335e8312f627
---
M composer.json
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/composer.json b/composer.json
index 61956c2..4ff65bd 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,7 @@
"scripts": {
"validate-schema": "php ./bin/validate-schema.php",
"lint": "parallel-lint --exclude vendor .",
-   "phpcs": "phpcs -p -s",
+   "phpcs": "phpcs -p -s --ignore=.git",
"phpdoc": "[ \"`which phpdoc`\" = \"\" ] || phpdoc -d bin,src 
-t ./docs/code",
"phpunit": "which phpdbg && phpdbg -qrr `which phpunit` 
--strict-coverage || phpunit --strict-coverage",
"unit": "phpunit --no-coverage",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I11f121802c6bfce1723e71a65853335e8312f627
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Move the hook onUnitTestsList on a separate file

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

Change subject: Move the hook onUnitTestsList on a separate file
..

Move the hook onUnitTestsList on a separate file

It is not useful it stays in the main class, so separation
of concerns.

Change-Id: If08160ace6e4ed46a80203597b4b9d43efe9e60f
---
A src/Hooks.php
M src/MediaWikiFarm.php
M tests/phpunit/FunctionsTest.php
A tests/phpunit/HooksTest.php
4 files changed, 76 insertions(+), 42 deletions(-)


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

diff --git a/src/Hooks.php b/src/Hooks.php
new file mode 100644
index 000..7c2fd12
--- /dev/null
+++ b/src/Hooks.php
@@ -0,0 +1,48 @@
+
+ * @license GPL-3.0+ GNU General Public License v3.0, or (at your option) any 
later version.
+ * @license AGPL-3.0+ GNU Affero General Public License v3.0, or (at your 
option) any later version.
+ */
+
+/**
+ * MediaWiki hooks.
+ *
+ * @package MediaWikiFarm
+ */
+class MediaWikiFarmHooks {
+
+   /**
+* Add files for unit testing.
+*
+* Only useful for MediaWiki 1.27- since MediaWiki 1.28+ autodiscovers 
these files.
+* Given this hook is never useful at runtime, it should be moved to a 
separate file
+* if MediaWiki runtime hooks are added in this file.
+*
+* @api
+*
+* @param string[] $files The test files.
+* @return true
+*/
+   public static function onUnitTestsList( array &$files ) {
+
+   $dir = dirname( dirname( __FILE__ ) ) . '/tests/phpunit/';
+
+   $files[] = $dir . 'ConfigurationTest.php';
+   $files[] = $dir . 'ConstructionTest.php';
+   $files[] = $dir . 'FunctionsTest.php';
+   $files[] = $dir . 'HooksTest.php';
+   $files[] = $dir . 'InstallationIndependantTest.php';
+   $files[] = $dir . 'LoadingTest.php';
+   $files[] = $dir . 'LoggingTest.php';
+   $files[] = $dir . 'MediaWikiFarmComposerScriptTest.php';
+   $files[] = $dir . 'MediaWikiFarmScriptTest.php';
+   $files[] = $dir . 'MonoversionInstallationTest.php';
+   $files[] = $dir . 'MultiversionInstallationTest.php';
+
+   return true;
+   }
+}
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5339e58..b70ad71 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1636,33 +1636,6 @@
throw new InvalidArgumentException( 'Argument of 
MediaWikiFarm->replaceVariables() must be a string or an array.' );
}
 
-   /**
-* Add files for unit testing.
-*
-* @mediawikifarm-const
-* @mediawikifarm-idempotent
-*
-* @param string[] $files The test files.
-* @return true
-*/
-   static function onUnitTestsList( array &$files ) {
-
-   $dir = dirname( dirname( __FILE__ ) ) . '/tests/phpunit/';
-
-   $files[] = $dir . 'ConfigurationTest.php';
-   $files[] = $dir . 'ConstructionTest.php';
-   $files[] = $dir . 'FunctionsTest.php';
-   $files[] = $dir . 'InstallationIndependantTest.php';
-   $files[] = $dir . 'LoadingTest.php';
-   $files[] = $dir . 'LoggingTest.php';
-   $files[] = $dir . 'MediaWikiFarmComposerScriptTest.php';
-   $files[] = $dir . 'MediaWikiFarmScriptTest.php';
-   $files[] = $dir . 'MonoversionInstallationTest.php';
-   $files[] = $dir . 'MultiversionInstallationTest.php';
-
-   return true;
-   }
-
 
 
/*
diff --git a/tests/phpunit/FunctionsTest.php b/tests/phpunit/FunctionsTest.php
index ebf41b2..24d99de 100644
--- a/tests/phpunit/FunctionsTest.php
+++ b/tests/phpunit/FunctionsTest.php
@@ -85,21 +85,6 @@
}
 
/**
-* Test onUnitTestsList hook
-*
-* @covers MediaWikiFarm::onUnitTestsList
-*/
-   function testOnUnitTestsListHook() {
-
-   $testFiles = glob( dirname( __FILE__ ) . '/*Test.php' );
-
-   $array = array();
-   MediaWikiFarm::onUnitTestsList( $array );
-
-   $this->assertEquals( $testFiles, $array );
-   }
-
-   /**
 * Test arrayMerge
 *
 * @covers MediaWikiFarm::arrayMerge
diff --git a/tests/phpunit/HooksTest.php b/tests/phpunit/HooksTest.php
new file mode 100644
index 000..a3be7d7
--- /dev/null
+++ b/tests/phpunit/HooksTest.php
@@ -0,0 +1,28 @@
+assertEquals( $testFiles, $array );
+   }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If08160ace6e4ed46a80203597b4b9d43efe9e60f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Documentation

2017-03-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/342762 )

Change subject: Documentation
..

Documentation

Fix phpDoc errors

Change-Id: I2142530d4c811b28156f2f331c94a21cf1c1149e
---
M bin/mwcomposer.php
M bin/mwscript.php
M bin/validate-schema.php
M src/AbstractMediaWikiFarmScript.php
M src/MediaWikiFarm.php
M src/MediaWikiFarmComposerAutoloader.php
M src/MediaWikiFarmComposerScript.php
M src/MediaWikiFarmScript.php
M src/Yaml.php
M src/main.php
M www/api.php
M www/img_auth.php
M www/index.php
M www/load.php
M www/opensearch_desc.php
15 files changed, 29 insertions(+), 2 deletions(-)


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

diff --git a/bin/mwcomposer.php b/bin/mwcomposer.php
index 97dbeca..c1372fc 100644
--- a/bin/mwcomposer.php
+++ b/bin/mwcomposer.php
@@ -2,6 +2,7 @@
 /**
  * Wrapper around Composer to create as many autoloaders as MediaWiki 
extensions.
  *
+ * @package MediaWikiFarm
  * @author Sébastien Beyou ~ Seb35 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
diff --git a/bin/mwscript.php b/bin/mwscript.php
index 14751bf..1767d71 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -2,6 +2,7 @@
 /**
  * Entry point for CLI scripts in the context of a MediaWiki farm.
  *
+ * @package MediaWikiFarm
  * @author Sébastien Beyou ~ Seb35 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
diff --git a/bin/validate-schema.php b/bin/validate-schema.php
index 758b5a6..b4aa8cc 100644
--- a/bin/validate-schema.php
+++ b/bin/validate-schema.php
@@ -3,6 +3,8 @@
  * Validate the files 'config/farms.[yml|json|php]' against 
'docs/farms-schema.json'.
  *
  * This files is mostly inspired from the README 
https://github.com/justinrainbow/json-schema
+ *
+ * @package MediaWikiFarm
  */
 // @codeCoverageIgnoreStart
 
diff --git a/src/AbstractMediaWikiFarmScript.php 
b/src/AbstractMediaWikiFarmScript.php
index ea407a4..8ef2bf7 100644
--- a/src/AbstractMediaWikiFarmScript.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -2,6 +2,7 @@
 /**
  * Script class.
  *
+ * @package MediaWikiFarm
  * @author Sébastien Beyou ~ Seb35 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 89e60aa..5339e58 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -2,6 +2,7 @@
 /**
  * Class MediaWikiFarm.
  *
+ * @package MediaWikiFarm
  * @author Sébastien Beyou ~ Seb35 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
@@ -186,6 +187,7 @@
 * @mediawikifarm-const
 *
 * @param string|null $key Key of the wanted section or null for the 
whole array.
+* @param string|null $key2 Subkey (specific to each entry) or null for 
the whole entry.
 * @return array MediaWiki configuration, either entire, either a part 
depending on the parameter.
 */
function getConfiguration( $key = null, $key2 = null ) {
@@ -219,6 +221,7 @@
 * @param string $entryPoint Name of the entry point, e.g. 'index.php', 
'load.php'…
 * @param string|null $host Host name (string) or null to use the 
global variables HTTP_HOST or SERVER_NAME.
 * @param array $state Parameters, see object property $state.
+* @param array $environment Environment which determines a given 
configuration.
 * @return string $entryPoint Identical entry point as passed in input.
 */
static function load( $entryPoint = '', $host = null, $state = array(), 
$environment = array() ) {
diff --git a/src/MediaWikiFarmComposerAutoloader.php 
b/src/MediaWikiFarmComposerAutoloader.php
index 41a8752..a6edfda 100644
--- a/src/MediaWikiFarmComposerAutoloader.php
+++ b/src/MediaWikiFarmComposerAutoloader.php
@@ -1,8 +1,9 @@
 getConfiguration( 'composer' 
);
foreach( $extensions as $extension ) {
diff --git a/src/MediaWikiFarmComposerScript.php 
b/src/MediaWikiFarmComposerScript.php
index ae3c9d9..f46e232 100644
--- a/src/MediaWikiFarmComposerScript.php
+++ b/src/MediaWikiFarmComposerScript.php
@@ -2,6 +2,7 @@
 /**
  * Wrapper around Composer to create as many autoloaders as MediaWiki 
extensions.
  *
+ * @package MediaWikiFarm
  * @author Sébastien Beyou ~ Seb35 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
@@ -264,6 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: A log was a false positive

2017-03-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/342674 )

Change subject: A log was a false positive
..

A log was a false positive

This log message says an extension is requested but missing; in the case
the config says not to install this extension, not to trigger this log
message.

Change-Id: I49025006500a012e72caf58e3c0a365d89d87269
---
M src/MediaWikiFarm.php
1 file changed, 3 insertions(+), 1 deletion(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 00cc059..89e60aa 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1338,9 +1338,11 @@
} elseif( $value !== false && ( $status = 
$this->detectLoadingMechanism( $type, $name ) ) ) {
$value = true;
} elseif( $key != 'ExtensionMediaWikiFarm' ) {
+   if( $value ) {
+   $this->log[] = "Requested but missing 
$type $name for wiki {$this->variables['$WIKIID']} in version 
{$this->variables['$VERSION']}";
+   }
$value = false;
unset( $this->configuration['extensions'][$key] 
);
-   $this->log[] = "Requested but missing $type 
$name for wiki {$this->variables['$WIKIID']} in version 
{$this->variables['$VERSION']}";
} else {
$status = $ExtensionRegistry ? 
'wfLoadExtension' : 'require_once';
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I49025006500a012e72caf58e3c0a365d89d87269
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Forgot default value for the new config parameter

2017-03-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/342628 )

Change subject: Forgot default value for the new config parameter
..

Forgot default value for the new config parameter

Change-Id: I4f8f36872248cd550204594ef8f8d66e3448fb2f
---
M www/api.php
M www/img_auth.php
M www/index.php
M www/load.php
M www/opensearch_desc.php
5 files changed, 5 insertions(+), 0 deletions(-)


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

diff --git a/www/api.php b/www/api.php
index 20a2f4e..5370c46 100644
--- a/www/api.php
+++ b/www/api.php
@@ -12,6 +12,7 @@
 $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) );
 $wgMediaWikiFarmConfigDir = '/etc/mediawiki';
 $wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
+$wgMediaWikiFarmSyslog = 'mediawikifarm';
 
 # Check the entry point is installed in a multiversion MediaWiki farm or in 
the classical MediaWiki extensions directory
 if( is_file( dirname( $wgMediaWikiFarmCodeDir ) . 
'/includes/DefaultSettings.php' ) ) {
diff --git a/www/img_auth.php b/www/img_auth.php
index a2a8dbd..1de2142 100644
--- a/www/img_auth.php
+++ b/www/img_auth.php
@@ -12,6 +12,7 @@
 $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) );
 $wgMediaWikiFarmConfigDir = '/etc/mediawiki';
 $wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
+$wgMediaWikiFarmSyslog = 'mediawikifarm';
 
 # Check the entry point is installed in a multiversion MediaWiki farm or in 
the classical MediaWiki extensions directory
 if( is_file( dirname( $wgMediaWikiFarmCodeDir ) . 
'/includes/DefaultSettings.php' ) ) {
diff --git a/www/index.php b/www/index.php
index ac7131b..71e11fa 100644
--- a/www/index.php
+++ b/www/index.php
@@ -12,6 +12,7 @@
 $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) );
 $wgMediaWikiFarmConfigDir = '/etc/mediawiki';
 $wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
+$wgMediaWikiFarmSyslog = 'mediawikifarm';
 
 # Check the entry point is installed in a multiversion MediaWiki farm or in 
the classical MediaWiki extensions directory
 if( is_file( dirname( $wgMediaWikiFarmCodeDir ) . 
'/includes/DefaultSettings.php' ) ) {
diff --git a/www/load.php b/www/load.php
index fc68ca7..f865696 100644
--- a/www/load.php
+++ b/www/load.php
@@ -12,6 +12,7 @@
 $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) );
 $wgMediaWikiFarmConfigDir = '/etc/mediawiki';
 $wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
+$wgMediaWikiFarmSyslog = 'mediawikifarm';
 
 # Check the entry point is installed in a multiversion MediaWiki farm or in 
the classical MediaWiki extensions directory
 if( is_file( dirname( $wgMediaWikiFarmCodeDir ) . 
'/includes/DefaultSettings.php' ) ) {
diff --git a/www/opensearch_desc.php b/www/opensearch_desc.php
index 0f14227..b156d4b 100644
--- a/www/opensearch_desc.php
+++ b/www/opensearch_desc.php
@@ -12,6 +12,7 @@
 $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) );
 $wgMediaWikiFarmConfigDir = '/etc/mediawiki';
 $wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
+$wgMediaWikiFarmSyslog = 'mediawikifarm';
 
 # Check the entry point is installed in a multiversion MediaWiki farm or in 
the classical MediaWiki extensions directory
 if( is_file( dirname( $wgMediaWikiFarmCodeDir ) . 
'/includes/DefaultSettings.php' ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f8f36872248cd550204594ef8f8d66e3448fb2f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Add a logging infrastructure

2017-03-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/342620 )

Change subject: Add a logging infrastructure
..

Add a logging infrastructure

Some errors and exceptions were already collected but not logged; now all these 
errors
are logged with syslog with a syslog tag to be defined (by default logging is
activated with the tag 'mediawikifarm').

The logging code is splitted in two methods for testing purposes since the 
second is
harly testable. I chose not to use PSR-3 infrastructure to keep code as small 
as possible
and avoid dependencies; and syslog messages can be redirected to a specific 
destination
with appropriate system syslog configuration.

Improved some messages with some additionnal informations and added two 
messages.

“Errors” (e.g. unreadable files) are registered in the same internal variable, 
but possibly
a specific internal variable will be created in the future.

Change-Id: I30601fba0eb9ba11433f59a58b947a57c59b581b
---
M docs/config/MediaWikiFarmDirectories.php
M extension.json
M src/MediaWikiFarm.php
M src/Yaml.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
A tests/phpunit/LoggingTest.php
M tests/phpunit/MediaWikiFarmComposerScriptTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
10 files changed, 237 insertions(+), 16 deletions(-)


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

diff --git a/docs/config/MediaWikiFarmDirectories.php 
b/docs/config/MediaWikiFarmDirectories.php
index 506fd43..77b28a1 100644
--- a/docs/config/MediaWikiFarmDirectories.php
+++ b/docs/config/MediaWikiFarmDirectories.php
@@ -64,3 +64,14 @@
  */
 $wgMediaWikiFarmCacheDir = '/tmp/mw-cache';
 
+
+/**
+ * Syslog tag.
+ *
+ * Type: string|false.
+ *
+ * If false, no logging will be issued at all. If string, syslog is used and 
casual log messages
+ * will be issued in the facility 'USER', with the criticity level 'ERROR', 
and the tag defined
+ * by this configuration parameter.
+ */
+$wgMediaWikiFarmSyslog = 'mediawikifarm';
diff --git a/extension.json b/extension.json
index c3c85c8..3304cf7 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
"name": "MediaWikiFarm",
-   "version": "0.3.0",
+   "version": "0.4.0",
"author": [
"[https://www.mediawiki.org/wiki/User:Seb35 Seb35]"
],
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 6b9def9..00cc059 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -83,8 +83,8 @@
'composer' => array(),
);
 
-   /** @var array Errors */
-   protected $errors = array();
+   /** @var array Logs. */
+   public $log = array();
 
 
 
@@ -223,7 +223,8 @@
 */
static function load( $entryPoint = '', $host = null, $state = array(), 
$environment = array() ) {
 
-   global $wgMediaWikiFarm, $wgMediaWikiFarmConfigDir, 
$wgMediaWikiFarmCodeDir, $wgMediaWikiFarmCacheDir;
+   global $wgMediaWikiFarm;
+   global $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir, 
$wgMediaWikiFarmCacheDir, $wgMediaWikiFarmSyslog;
 
try {
# Initialise object
@@ -239,12 +240,14 @@
# Compile configuration
$wgMediaWikiFarm->compileConfiguration();
}
-   catch( Exception $e ) {
+   catch( Exception $exception ) {
 
if( !headers_sent() ) {
$httpProto = array_key_exists( 
'SERVER_PROTOCOL', $_SERVER ) && $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' ? 
'HTTP/1.1' : 'HTTP/1.0'; // @codeCoverageIgnore
header( "$httpProto 500 Internal Server Error" 
); // @codeCoverageIgnore
}
+
+   self::issueLog( self::prepareLog( 
$wgMediaWikiFarmSyslog, $wgMediaWikiFarm, $exception ) );
return 500;
}
 
@@ -261,6 +264,8 @@
include $file404;
}
}
+
+   self::issueLog( self::prepareLog( 
$wgMediaWikiFarmSyslog, $wgMediaWikiFarm ) );
return 404;
}
 
@@ -280,6 +285,7 @@
# Define we are now inside MediaWiki
$wgMediaWikiFarm->state['InnerMediaWiki'] = true;
 
+   self::issueLog( self::prepareLog( $wgMediaWikiFarmSyslog, 
$wgMediaWikiFarm ) );
return 200;
}
 
@@ -363,7 +369,7 @@
$this->activateExtensions();
 
# Save Composer key if available
-   if( $this->cacheDir && !count( $this->errors ) ) {
+   if( $this->cacheDir && 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Fix bug when autoloading Composer without MediaWikiFarm

2017-02-03 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/335789 )

Change subject: Fix bug when autoloading Composer without MediaWikiFarm
..

Fix bug when autoloading Composer without MediaWikiFarm

Sometimes MediaWiki loads Composer’s autoloader but MediaWikiFarm is
not called through, e.g. when one directly call /mw-config/index.php
(although there could be a MediaWikiFarm wrapper, to be decided); in
these cases the object MediaWikiFarm does not exist and Composer’s
autoloader is crashing, so check if MediaWikiFarm object exists.

Change-Id: I8713c896e0255480a564932bb225ef2506eab0c1
---
M src/MediaWikiFarmComposerAutoloader.php
1 file changed, 2 insertions(+), 4 deletions(-)


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

diff --git a/src/MediaWikiFarmComposerAutoloader.php 
b/src/MediaWikiFarmComposerAutoloader.php
index cd58e20..41a8752 100644
--- a/src/MediaWikiFarmComposerAutoloader.php
+++ b/src/MediaWikiFarmComposerAutoloader.php
@@ -3,9 +3,8 @@
 // autoload.php @generated by MediaWikiFarm
 // @codeCoverageIgnoreStart
 
-$extensions = $GLOBALS['wgMediaWikiFarm']->getConfiguration( 'composer' );
-
-if( count( $extensions ) ) {
+if( array_key_exists( 'wgMediaWikiFarm', $GLOBALS ) ) {
+   $extensions = $GLOBALS['wgMediaWikiFarm']->getConfiguration( 'composer' 
);
foreach( $extensions as $extension ) {
 
require_once __DIR__ . '/composer' . substr( md5( $extension ), 
0, 8 ) . '/autoload_real.php';
@@ -15,7 +14,6 @@
unset( $extension );
return;
 }
-unset( $extensions );
 
 require_once __DIR__ . '/composer' . '/autoload_real.php';
 ComposerAutoloaderInitDEFAULT::getLoader();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8713c896e0255480a564932bb225ef2506eab0c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Fix timestamp format in maintenance/manageJobs.php

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

Change subject: Fix timestamp format in maintenance/manageJobs.php
..

Fix timestamp format in maintenance/manageJobs.php

Follow-up of Ib56cf57e56f03ce6f1c4b52e3e36f228413c1056,
Job::getQueuedTimestamp() returns a UNIX timestamp, so use
the same here for comparison.

Change-Id: I595f962b71337fc9021963c55ee7dd2443149a46
---
M maintenance/manageJobs.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/36/335636/1

diff --git a/maintenance/manageJobs.php b/maintenance/manageJobs.php
index 9585ed8..bbedf0c 100644
--- a/maintenance/manageJobs.php
+++ b/maintenance/manageJobs.php
@@ -75,7 +75,7 @@
$skipped = 0;
foreach ( $queue->getAllAbandonedJobs() as $job ) {
/** @var Job $job */
-   if ( $job->getQueuedTimestamp() < $lastRepushTime ) {
+   if ( $job->getQueuedTimestamp() < wfTimestamp( TS_UNIX, 
$lastRepushTime ) ) {
++$skipped;
continue; // already re-pushed in prior round
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I595f962b71337fc9021963c55ee7dd2443149a46
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: l10n: Tamil namespaces

2017-01-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332065 )

Change subject: l10n: Tamil namespaces
..

l10n: Tamil namespaces

Bug: T142287
Change-Id: Ib46d530b301516b44976b65996a51a2b2fc9a6d1
---
M ProofreadPage.namespaces.php
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/65/332065/1

diff --git a/ProofreadPage.namespaces.php b/ProofreadPage.namespaces.php
index 51e7f8e..fc4f832 100644
--- a/ProofreadPage.namespaces.php
+++ b/ProofreadPage.namespaces.php
@@ -353,6 +353,14 @@
'index_talk' => 'Indexdiskussion'
 ];
 
+/** Tamil (தமிழ்) */
+$proofreadPageNamespacesNames['ta'] = [
+   'page' => 'பக்கம்',
+   'page_talk' => 'பக்கம்_பேச்சு',
+   'index' => 'அட்டவணை',
+   'index_talk' => 'அட்டவணை_பேச்சு'
+];
+
 /** Telugu (తెలుగు) */
 $proofreadPageNamespacesNames['te'] = [
'page' => 'పుట',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib46d530b301516b44976b65996a51a2b2fc9a6d1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: i18n: Add some messages

2017-01-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332052 )

Change subject: i18n: Add some messages
..

i18n: Add some messages

The messages for translating the tab were missing, better is to declare
them to make them translatable in Translatewiki.

Bug: T142287
Change-Id: Id151e5091a0eaba11235149adcfb51e7c9e55f6a
---
M i18n/en.json
M i18n/qqq.json
2 files changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/52/332052/1

diff --git a/i18n/en.json b/i18n/en.json
index 07219b9..e3da5bf 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -2,6 +2,10 @@
"@metadata": {
"authors": []
},
+   "nstab-page": "Page",
+   "nstab-index": "Index",
+   "tooltip-ca-nstab-page": "View the book page",
+   "tooltip-ca-nstab-index": "View the book index",
"indexpages": "List of index pages",
"pageswithoutscans": "Pages without scans",
"proofreadpage_desc": "Allow easy comparison of text to the original 
scan",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 5394a8f..4d7a408 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -27,6 +27,10 @@
"Pikne"
]
},
+   "nstab-page": "Text on the tab of book pages in the \"Page\" namespace 
on Wikisource",
+   "nstab-index": "Text on the tab of book indexes in the \"Index\" 
namespace on Wikisource",
+   "tooltip-ca-nstab-page": "Used as tooltip for tab of Page 
namespace.\n\nSee also:\n* {{msg-mw|Nstab-page}}",
+   "tooltip-ca-nstab-index": "Used as tooltip for tab of Index 
namespace.\n\nSee also:\n* {{msg-mw|Nstab-index}}",
"indexpages": "{{doc-special|IndexPages}}",
"pageswithoutscans": "{{doc-special|PagesWithoutScans}}\nThe special 
page lists texts without scans; that is, the texts that have not been 
transcluded into any other page.",
"proofreadpage_desc": "{{desc|name=Proofread 
Page|url=https://www.mediawiki.org/wiki/Extension:Proofread_Page}};,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id151e5091a0eaba11235149adcfb51e7c9e55f6a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...WikiLexicalData[master]: Use getter instead of property

2017-01-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332043 )

Change subject: Use getter instead of property
..

Use getter instead of property

TextContent has the dedicated getter getNativeData() to access to the
object property mText, so let’s use it. I proposed to change the visibility
of the object property, so this extension would be broken if/when the
visibility is changed, but anyway it’s better to access through the getter.

Bug: T155298
Change-Id: I97a7c69a770844949bb4cf3de74b43dd85d4aaf6
---
M includes/api/owAddAnnotation.php
M includes/api/owAddDefinition.php
M includes/api/owAddSyntrans.php
M includes/api/owAddToCollection.php
4 files changed, 8 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiLexicalData 
refs/changes/43/332043/1

diff --git a/includes/api/owAddAnnotation.php b/includes/api/owAddAnnotation.php
index c354e1b..b32c8a3 100644
--- a/includes/api/owAddAnnotation.php
+++ b/includes/api/owAddAnnotation.php
@@ -478,7 +478,7 @@
);
}
 
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
 
// Check if the page is redirected,
// then adjust accordingly.
@@ -488,7 +488,7 @@
$csvWikiPageTitle = Title::newFromText( $redirectedText 
);
$csvWikiPage = new WikiPage ( $csvWikiPageTitle );
$wikiText = $csvWikiPage->getContent( Revision::RAW );
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
}
 
$process = array (
diff --git a/includes/api/owAddDefinition.php b/includes/api/owAddDefinition.php
index 90979b4..ce6f6d7 100644
--- a/includes/api/owAddDefinition.php
+++ b/includes/api/owAddDefinition.php
@@ -149,7 +149,7 @@
) )
);
 
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
 
// Check if the page is redirected,
// then adjust accordingly.
@@ -159,7 +159,7 @@
$csvWikiPageTitle = Title::newFromText( $redirectedText 
);
$csvWikiPage = new WikiPage ( $csvWikiPageTitle );
$wikiText = $csvWikiPage->getContent( Revision::RAW );
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
}
 
$this->getResult()->addValue( null, $this->getModuleName(),
diff --git a/includes/api/owAddSyntrans.php b/includes/api/owAddSyntrans.php
index 8deae41..365ebe7 100644
--- a/includes/api/owAddSyntrans.php
+++ b/includes/api/owAddSyntrans.php
@@ -192,7 +192,7 @@
) )
);
 
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
 
// Check if the page is redirected,
// then adjust accordingly.
@@ -202,7 +202,7 @@
$csvWikiPageTitle = Title::newFromText( $redirectedText 
);
$csvWikiPage = new WikiPage ( $csvWikiPageTitle );
$wikiText = $csvWikiPage->getContent( Revision::RAW );
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
}
 
$this->getResult()->addValue( null, $this->getModuleName(),
diff --git a/includes/api/owAddToCollection.php 
b/includes/api/owAddToCollection.php
index 477de84..8c6e69f 100644
--- a/includes/api/owAddToCollection.php
+++ b/includes/api/owAddToCollection.php
@@ -155,7 +155,7 @@
) )
);
 
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
 
// Check if the page is redirected,
// then adjust accordingly.
@@ -165,7 +165,7 @@
$csvWikiPageTitle = Title::newFromText( $redirectedText 
);
$csvWikiPage = new WikiPage ( $csvWikiPageTitle );
$wikiText = $csvWikiPage->getContent( Revision::RAW );
-   $text = $wikiText->mText;
+   $text = $wikiText->getNativeData();
}
 
$this->getResult()->addValue( null, $this->getModuleName(),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97a7c69a770844949bb4cf3de74b43dd85d4aaf6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiLexicalData
Gerrit-Branch: master
Gerrit-Owner: Seb35 

___
MediaWiki-commits mailing list

[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: Fix the ProofreadPage’s VisualEditor

2017-01-11 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/331800 )

Change subject: Fix the ProofreadPage’s VisualEditor
..

Fix the ProofreadPage’s VisualEditor

The ProofreadPage’s VisualEditor was broken because of the commit
Ic8ea89a42ad6d873 (cb081bc3c8c3115).

Thanks to Tim’s help. In some cases, like during the API call for
the VisualEditor, the 'parser clone' clones a StubObject because
the real Parser is not already initialised; with unstub() it
becomes initialised.

Change-Id: Iac9f14815dab092bb06e5743a793abfd4aa2b0f5
---
M includes/index/ProofreadIndexPage.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/00/331800/1

diff --git a/includes/index/ProofreadIndexPage.php 
b/includes/index/ProofreadIndexPage.php
index e73716b..0554b4b 100644
--- a/includes/index/ProofreadIndexPage.php
+++ b/includes/index/ProofreadIndexPage.php
@@ -413,6 +413,7 @@
static $parser = null;
 
if ( $parser === null ) {
+   StubObject::unstub( $wgParser );
$parser = clone $wgParser;
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac9f14815dab092bb06e5743a793abfd4aa2b0f5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: [WIP] Use the parser to get each template parameter in the I...

2017-01-11 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/331643 )

Change subject: [WIP] Use the parser to get each template parameter in the 
Index: namespace
..

[WIP] Use the parser to get each template parameter in the Index: namespace

This should be more robust than the current regexes, and should avoid bugs
like T119330, which is fixed.

In the current state, this commit is not usable since it is not idempotent for
each syntaxes (e.g.  is transformed to 
'"`UNIQ--pagelist--QINU`").
Although it correctly render the syntax in bug T119330.

Bug: T119330
Change-Id: Ie6322c40d1143e068ded259b420d2fee325de0dc
---
M includes/index/ProofreadIndexPage.php
1 file changed, 16 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/43/331643/1

diff --git a/includes/index/ProofreadIndexPage.php 
b/includes/index/ProofreadIndexPage.php
index fd6f63d..17f9155 100644
--- a/includes/index/ProofreadIndexPage.php
+++ b/includes/index/ProofreadIndexPage.php
@@ -235,14 +235,27 @@
 * @return array of ProofreadIndexEntry
 */
public function getIndexEntries() {
+   global $wgUser, $wgContLang, $wgParser;
if ( $this->entries === null ) {
$text = $this->getText();
$values = [];
+
+   $parser = $wgParser;
+   $options = new ParserOptions( $wgUser, $wgContLang );
+   $parser->startExternalParse( $this->title, $options, 
Parser::OT_PLAIN, true );
+
+   $dom = $parser->preprocessToDom( $text );
+   $frame = $parser->getPreprocessor()->newFrame();
+   $dom = $dom->getFirstChild();
+   $childframe = $frame->newChild( 
$dom->getChildrenOfType( 'part' ) );
+
foreach ( $this->config as $varName => $property ) {
-   $tagPattern = "/\n\|" . preg_quote( $varName, 
'/' ) . "=(.*?)\n(\||\}\})/is";
-   if ( preg_match( $tagPattern, $text, $matches ) 
) {
-   $values[$varName] = $matches[1];
+   if ( !array_key_exists( $varName, 
$childframe->namedArgs ) ) {
+   continue;
}
+   $values[$varName] = 
$parser->getPreprocessor()->newFrame()->expand(
+   $childframe->namedArgs[$varName], 
PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES
+   );
}
$this->entries = 
$this->getIndexEntriesFromIndexContent( $values );
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6322c40d1143e068ded259b420d2fee325de0dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Replace mocks of DatabaseMysql by DatabaseMysqli

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

Change subject: Replace mocks of DatabaseMysql by DatabaseMysqli
..

Replace mocks of DatabaseMysql by DatabaseMysqli

The class DatabaseMysql corresponds to the PHP extension 'mysql' which is
deprecated since PHP 5.5, and the class DatabaseMysqli corresponds to the
PHP extension 'mysqli' which is the current MySQL driver. Given the class
DatabaseMysql is likely to be removed in the future, this change is a
first step towards this.

Bug: T120333
Change-Id: I7b8363838449cae09b360221d8f50ace3a008f11
---
M tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
M tests/phpunit/includes/db/LBFactoryTest.php
M tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php
M tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php
M tests/phpunit/includes/utils/BatchRowUpdateTest.php
5 files changed, 7 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/64/329764/1

diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php 
b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
index dbb126f..81b75de 100644
--- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
+++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
@@ -170,7 +170,7 @@
}
 
function getMockForViews() {
-   $db = $this->getMockBuilder( 'DatabaseMysql' )
+   $db = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->setMethods( [ 'fetchRow', 'query' ] )
->getMock();
@@ -314,7 +314,7 @@
 * @dataProvider provideLagAmounts
 */
function testPtHeartbeat( $lag ) {
-   $db = $this->getMockBuilder( 'DatabaseMysql' )
+   $db = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->setMethods( [
'getLagDetectionMethod', 'getHeartbeatData', 
'getMasterServerInfo' ] )
diff --git a/tests/phpunit/includes/db/LBFactoryTest.php 
b/tests/phpunit/includes/db/LBFactoryTest.php
index d8773f8..573b395 100644
--- a/tests/phpunit/includes/db/LBFactoryTest.php
+++ b/tests/phpunit/includes/db/LBFactoryTest.php
@@ -29,7 +29,7 @@
 * @dataProvider getLBFactoryClassProvider
 */
public function testGetLBFactoryClass( $expected, $deprecated ) {
-   $mockDB = $this->getMockBuilder( 'DatabaseMysql' )
+   $mockDB = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->getMock();
 
@@ -178,7 +178,7 @@
$mPos = new MySQLMasterPos( 'db1034-bin.000976', '843431247' );
 
$now = microtime( true );
-   $mockDB = $this->getMockBuilder( 'DatabaseMysql' )
+   $mockDB = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->getMock();
$mockDB->method( 'writesOrCallbacksPending' )->willReturn( true 
);
diff --git a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php 
b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php
index 8366541..410d2df 100644
--- a/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php
+++ b/tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php
@@ -112,7 +112,7 @@
}
 
protected function getMocks() {
-   $dbMock = $this->getMockBuilder( 'DatabaseMysql' )
+   $dbMock = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->getMock();
 
diff --git a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php 
b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php
index 92a54fa..d3f9374 100644
--- a/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php
+++ b/tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php
@@ -25,7 +25,7 @@
]
] );
 
-   $dbMock = $this->getMockBuilder( 'DatabaseMysql' )
+   $dbMock = $this->getMockBuilder( 'DatabaseMysqli' )
->disableOriginalConstructor()
->getMock();
 
diff --git a/tests/phpunit/includes/utils/BatchRowUpdateTest.php 
b/tests/phpunit/includes/utils/BatchRowUpdateTest.php
index cb1b3d2..6506d58 100644
--- a/tests/phpunit/includes/utils/BatchRowUpdateTest.php
+++ b/tests/phpunit/includes/utils/BatchRowUpdateTest.php
@@ -237,7 +237,7 @@
protected function mockDb() {
// @TODO: mock from Database
// FIXME: the constructor normally sets mAtomicLevels and 
mSrvCache
-   $databaseMysql = $this->getMockBuilder( 'DatabaseMysql' )
+   

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Soft deprecation of DatabaseMysql

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

Change subject: Soft deprecation of DatabaseMysql
..

Soft deprecation of DatabaseMysql

This class is the driver for MySQL databases corresponding to the PHP
extension 'mysql'. This PHP extension was deprecated in PHP 5.5 and
removed in PHP 7.0. It was replaced by the PHP extension 'mysqli',
which is supported and the default MySQL driver since MediaWiki 1.22.

Bug: T120333
Change-Id: Id1478f73e348cdd1ad1f560b1d8ddefe56c52767
---
M RELEASE-NOTES-1.29
M includes/libs/rdbms/database/Database.php
M includes/libs/rdbms/database/DatabaseMysql.php
3 files changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/82/329682/1

diff --git a/RELEASE-NOTES-1.29 b/RELEASE-NOTES-1.29
index 774254c..c8a809a 100644
--- a/RELEASE-NOTES-1.29
+++ b/RELEASE-NOTES-1.29
@@ -147,6 +147,9 @@
 * User::getTemporaryPassword() (deprecated in 1.27) was removed.
 * User::isPasswordReminderThrottled() (deprecated in 1.27) was removed.
 * FSRepo (deprecated in 1.19) was removed.
+* (T120333) Soft-deprecated the use of PHP extension 'mysql' in favor of 
'mysqli'
+  (this PHP extension was deprecated in PHP 5.5 and removed in PHP 7.0;
+  MediaWiki auto-selects the 'mysqli' driver since MediaWiki 1.22).
 
 == Compatibility ==
 
diff --git a/includes/libs/rdbms/database/Database.php 
b/includes/libs/rdbms/database/Database.php
index 69cf1ac..6b47178 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -1975,7 +1975,7 @@
 * Quotes an identifier using `backticks` or "double quotes" depending 
on the database type.
 * MySQL uses `backticks` while basically everything else uses double 
quotes.
 * Since MySQL is the odd one out here the double quotes are our generic
-* and we implement backticks in DatabaseMysql.
+* and we implement backticks in DatabaseMysqlBase.
 *
 * @param string $s
 * @return string
diff --git a/includes/libs/rdbms/database/DatabaseMysql.php 
b/includes/libs/rdbms/database/DatabaseMysql.php
index 9ab7c64..2d70227 100644
--- a/includes/libs/rdbms/database/DatabaseMysql.php
+++ b/includes/libs/rdbms/database/DatabaseMysql.php
@@ -24,6 +24,7 @@
 /**
  * Database abstraction object for PHP extension mysql.
  *
+ * @deprecated 1.29:1.31 The PHP extension 'mysql' was deprecated in PHP 5.5 
and removed in PHP 7.0, it is replaced by the PHP extension 'mysqli'.
  * @ingroup Database
  * @see Database
  */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1478f73e348cdd1ad1f560b1d8ddefe56c52767
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Bug in the previous commit in multiversion mode

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

Change subject: Bug in the previous commit in multiversion mode
..

Bug in the previous commit in multiversion mode

Bugs:
* When running farm in multiversion mode, the wfLoadExtension
  for MediaWikiFarm (only) was not pointing to the right
  directory path (standard instead of dedicated).

Change-Id: I2df646dd0fa7d2ad75ccc5ee008af2a9506a86bd
---
M src/MediaWikiFarm.php
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 7c544b5..c243c78 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1297,7 +1297,7 @@
foreach( $configuration['extensions'] as $extension ) {
if( $extension[2] == 'require_once' ) {
$extensions[$extension[1]]['require_once'] .= 
"require_once \"\$IP/{$extension[1]}s/{$extension[0]}/{$extension[0]}.php\";\n";
-   } elseif( $extension == array( 'MediaWikiFarm', 
'extension', 'wfLoadExtension' ) && $this->codeDir ) {
+   } elseif( $extension[0] == 'MediaWikiFarm' && 
$extension[1] == 'extension' && $extension[2] == 'wfLoadExtension' && 
$this->codeDir ) {
$extensions['extension']['wfLoadExtension'] .= 
"wfLoadExtension( 'MediaWikiFarm', " . var_export( $this->farmDir . 
'/extension.json', true ) . " );\n";
} elseif( $extension[2] == 'wfLoad' . ucfirst( 
$extension[1] ) ) {
$extensions[$extension[1]]['wfLoad' . ucfirst( 
$extension[1] )] .= 'wfLoad' . ucfirst( $extension[1] ) . '( ' . var_export( 
$extension[0], true ) . " );\n";

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2df646dd0fa7d2ad75ccc5ee008af2a9506a86bd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[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 ) {
-
-   

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: [WIP] Activate Composer extensions in the same way than othe...

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

Change subject: [WIP] Activate Composer extensions in the same way than other 
extensions are activated
..

[WIP] Activate Composer extensions in the same way than other extensions are 
activated

This proof-of-concept is not meant to be merged, I prepare a
better-architectured version.

Basically the strategy is to create /vendor/composerKEY with KEY representing 
the
content of the autoloaders (typically a specific hash of its content). All these
directories are created beforehand (2^n directories with n = number of 
Composer-managed
extensions and skins) and the right directory – depending on the wiki – is 
loaded
by the indirection-like /vendor/autoload.php. I didn’t observed side effects 
apart
the minor detail that MediaWiki only display, in Special:Version, Composer 
libraries
it reads in /vendor/composer/installed.json (only a matter of display there).

With this architecture, extensions and skins are simply activated in the 
configuration
by setting wgUseExtensionMyWonderfulExt to true. Obviously there could be higher
level operations to do like update.php, create directories, setting 
extension-specific
parameters, etc. A detail to be improved is to better manage dependencies 
between
extensions: Composer is aware of dependencies, so some composerKEY directories 
are
the same (e.g. SemanticFormsSelect (SFS) also autoloads SemanticMediaWiki (SMW) 
and
PageForms (PF)); here the activation is independant from Composer and it would 
be great
to synchronise the two mechanism in some way (e.g. activating SFS should not 
only select
the right composerKEY but also activate SMW and PF, currently it selects the
right composerKEY but SFS trigger a fatal error since PF 4.0 is not activated).

Architecture:
* the configuration compilation is moved in the bootstraping stage for the most
  part, but given we don’t know at this stage if the MediaWiki version is
  ExtensionRegistry-aware, this small part remains in the LS.php stage.
* the composer key is written in a dedicated cache file: it cannot be in LS.php
  since this file is loaded after the composer key is needed, and it should not
  be in the existence file since it will change as soon as a config file change.

Code:
* added a CLI script mwcomposer.php
* added MediaWikiFarmComposerScript containing the logic of mwcomposer.php
* splitted the configuration part in two parts:
  * major part during the bootstraping stage
  * extension loading mechanism after MediaWiki is loaded

Change-Id: I027251fabb32d6543d4bff7c610935316b639802
---
A bin/mwcomposer.php
M extension.json
M src/MediaWikiFarm.php
A src/MediaWikiFarmComposerScript.php
M src/main.php
5 files changed, 473 insertions(+), 33 deletions(-)


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

diff --git a/bin/mwcomposer.php b/bin/mwcomposer.php
new file mode 100644
index 000..97dbeca
--- /dev/null
+++ b/bin/mwcomposer.php
@@ -0,0 +1,29 @@
+
+ * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
+ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
+ */
+// @codeCoverageIgnoreStart
+
+# Protect against web entry
+if( PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg' ) {
+   exit;
+}
+
+# Load classes
+require_once dirname( dirname( __FILE__ ) ) . 
'/src/MediaWikiFarmComposerScript.php';
+
+# Prepare environment
+$wgMediaWikiFarmComposerScript = new MediaWikiFarmComposerScript( $argc, $argv 
);
+
+$wgMediaWikiFarmComposerScript->load();
+
+$wgMediaWikiFarmComposerScript->main();
+
+if( $wgMediaWikiFarmComposerScript->status != 200 ) {
+   exit( $wgMediaWikiFarmComposerScript->status );
+}
+// @codeCoverageIgnoreEnd
diff --git a/extension.json b/extension.json
index 8a2d26f..b49fe04 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
"name": "MediaWikiFarm",
-   "version": "0.2.0",
+   "version": "0.3.0-dev",
"author": [
"Seb35"
],
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5f5c309..3da02c4 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -317,6 +317,26 @@
return true;
}
 
+   function compileConfig() {
+
+   $this->getMediaWikiConfig();
+
+   $composer = array();
+   foreach( $this->configuration['extensions'] as $name => 
$loading ) {
+   if( $loading == 'composer' ) {
+   $composer[] = 'Extension' . $name;
+   }
+   }
+   foreach( $this->configuration['skins'] as $name => $loading ) {
+   if( $loading == 'composer' ) {
+   $composer[] = 'Skin' . $name;
+   }
+   }
+   

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Bug monoversion installation, maintenance

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

Change subject: Bug monoversion installation, maintenance
..

Bug monoversion installation, maintenance

Bugs:
* Monoversion installation was broken because
  architecture was modified (and it was out-of-tests)

Loading:
* Document it works with MW >= 1.3 instead of >= 1.6
* Added two classes, even if loaded independently

Code:
* Simplify registration of this extension

Change-Id: I906e3b3626077b5af582bb122b52ed9edc60a77f
---
M MediaWikiFarm.php
M extension.json
M src/MediaWikiFarm.php
3 files changed, 17 insertions(+), 20 deletions(-)


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

diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php
index f1c27a4..99e9575 100644
--- a/MediaWikiFarm.php
+++ b/MediaWikiFarm.php
@@ -27,6 +27,6 @@
MediaWikiFarm::load();
 
# Load MediaWiki configuration
-   require_once MediaWikiFarm::getInstance()->getConfigFile();
+   require_once $wgMediaWikiFarm->getConfigFile();
 }
 // @codeCoverageIgnoreEnd
diff --git a/extension.json b/extension.json
index 1ad7552..8a2d26f 100644
--- a/extension.json
+++ b/extension.json
@@ -9,7 +9,7 @@
"url": "https://www.mediawiki.org/wiki/Extension:MediaWikiFarm;,
"type": "other",
"requires": {
-   "MediaWiki": ">= 1.6.0"
+   "MediaWiki": ">= 1.3.0"
},
"config": {
"MediaWikiFarmConfigDir": "/etc/mediawiki",
@@ -28,6 +28,8 @@
},
"AutoloadClasses": {
"MediaWikiFarm": "src/MediaWikiFarm.php",
+   "AbstractMediaWikiFarmScript": 
"src/AbstractMediaWikiFarmScript.php",
+   "MediaWikiFarmScript": "src/MediaWikiFarmScript.php",
"MWFConfigurationException": "src/MediaWikiFarm.php"
},
"manifest_version": 1
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 18e871a..7bdd23c 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -369,11 +369,17 @@
}
}
 
-   # Register this extension MediaWikiFarm to appear in 
Special:Version
-   if( $this->parameters['ExtensionRegistry'] ) {
-   wfLoadExtension( 'MediaWikiFarm', $this->codeDir ? 
$this->farmDir . '/extension.json' : null );
+   # Load extensions with the wfLoadExtension mechanism
+   foreach( $this->configuration['extensions'] as $extension => 
$value ) {
+
+   if( $value == 'wfLoadExtension' ) {
+
+   wfLoadExtension( $extension );
+   }
}
-   else {
+
+   # Register this extension MediaWikiFarm to appear in 
Special:Version
+   if( !$this->parameters['ExtensionRegistry'] ) {
$GLOBALS['wgExtensionCredits']['other'][] = array(
'path' => $this->farmDir . '/MediaWikiFarm.php',
'name' => 'MediaWikiFarm',
@@ -385,18 +391,11 @@
);
 
$GLOBALS['wgAutoloadClasses']['MediaWikiFarm'] = 
'src/MediaWikiFarm.php';
+   
$GLOBALS['wgAutoloadClasses']['AbstractMediaWikiFarmScript'] = 
'src/AbstractMediaWikiFarmScript.php';
+   $GLOBALS['wgAutoloadClasses']['MediaWikiFarmScript'] = 
'src/MediaWikiFarmScript.php';

$GLOBALS['wgAutoloadClasses']['MWFConfigurationException'] = 
'src/MediaWikiFarm.php';
$GLOBALS['wgMessagesDirs']['MediaWikiFarm'] = array( 
'i18n' );
$GLOBALS['wgHooks']['UnitTestsList'][] = array( 
'MediaWikiFarm::onUnitTestsList' );
-   }
-
-   # Load extensions with the wfLoadExtension mechanism
-   foreach( $this->configuration['extensions'] as $extension => 
$value ) {
-
-   if( $value == 'wfLoadExtension' && $extension != 
'MediaWikiFarm' ) {
-
-   wfLoadExtension( $extension );
-   }
}
}
 
@@ -1304,11 +1303,7 @@
$localSettings .= "\n# Extensions\n";
foreach( $configuration['extensions'] as $extension => $loading 
) {
if( $loading == 'wfLoadExtension' ) {
-   if( $extension == 'MediaWikiFarm' ) {
-   $localSettings .= "wfLoadExtension( 
'MediaWikiFarm'" . ( $this->codeDir ? ', ' . var_export( $this->farmDir . 
'/extension.json', true ) : '' ) ." );\n";
-   } else {
-   $localSettings .= "wfLoadExtension( 
'$extension' );\n";
-   }
+   $localSettings .= 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: The automatic test in MediaWikiTestCase was marked as risky

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

Change subject: The automatic test in MediaWikiTestCase was marked as risky
..

The automatic test in MediaWikiTestCase was marked as risky

MediaWikiTestCase::testMediaWikiTestCaseParentSetupCalled is
marked as risky when strict code coverage is activated in
PHPUnit (--coverage-html ../../docs/code-coverage
--strict-coverage --debug -v).

This patch adds the annotation @coversNothing to disable
code coverage on this test. As an automatically-added test,
it must adapt to a number of different environments, so it
is not feasible to add the exhaustive list of @uses classes.

Bug: T152923
Change-Id: Ic670ff2d89f1c5df500c0d10b153d4efd013d7f4
---
M tests/phpunit/MediaWikiTestCase.php
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/63/326363/1

diff --git a/tests/phpunit/MediaWikiTestCase.php 
b/tests/phpunit/MediaWikiTestCase.php
index db1df5c..9745f5b 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -582,6 +582,10 @@
/**
 * Make sure MediaWikiTestCase extending classes have called their
 * parent setUp method
+*
+* With strict coverage activated in PHP_CodeCoverage, this test would 
be
+* marked as risky without the following annotation (T152923).
+* @coversNothing
 */
final public function testMediaWikiTestCaseParentSetupCalled() {
$this->assertArrayHasKey( 'setUp', $this->called,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic670ff2d89f1c5df500c0d10b153d4efd013d7f4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Refactoring of the cache data architecture

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

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

Change subject: Refactoring of the cache data architecture
..

Refactoring of the cache data architecture

Architecture:
* At the beginning cache was only for config files, then it was added the 
LocalSettings,
  then it was added an 'existence' cache file. The cache data architecture is 
here
  refactored to (expectedly):
1a/ boost the case where the requested wiki is existant and has a cached
configuration (LS.php)
1b/ while always be sure of the freshness of the origin files,
  and with second objectives:
2/ not harm too much the performance of nonexistant wiki or nonfresh cached 
files,
3/ reasonably distribute the write operation on cached files to prefer 
long-lived
   small cached files over a short-lived big cached file.
* Given these objectives, the just-previously-introduced [cache]/versions.php, 
which
  answers globally to objective 1a (avoid recomputing the farm config to 
directly get
  the version and test the freshness of the origin files), is split in 
one-per-wiki
  cached files with almost the same content (objective 3). This file is 
self-consistent
  (objective 1b) to self-check its freshness for the existence operation 
('coreconfig'
  parameter containing the origin files for this file) and is self-sufficient to
  regenerate the cached config (LS.php) in case this one is not fresh (in this 
case
  only LS.php is regenerated, objectives 1b and 2).
* I considered the following alternatives:
  * A global existence cache file similar to [cache]/versions.php, but 
restricted to
the version of each wiki and the origin files for the existence and config
operations. This was not further considered because of objectives 2 (any 
change in
existence or config origin files implies recomputing the whole farm 
configuration)
and 3 (any change in existence or config origin files implies rewriting this
cache file).
  * An existence file like it is here implemented (one-per-wiki existence cache 
file),
but only with the wiki version and the existence origin files, with other 
variables
stored in the beginning of LS.php (wikiID, suffix, data, config files), in 
order to
directly define this cached LS.php without further evaluation during 
existence
operation. But, when the cached config becomes nonfresh (it would be itself 
aware
of it because it know its origin files), it should recompute the new config 
and
write it in its own file. The PHP engine would currently correctly behave, 
but HHVM
will not (bug #4797 on GitHub), and anyway this operation is quite risky. 
Anyway
this would only move some instructions from the existence to the config 
operation
and there is no performance gain; with the adoption solution, all farm 
variables
are consistently stored in the existence cache file.
* The cache directory is slightly reorganised by namespaces:
  * 'config': directly corresponding to origin config files,
  * 'wikis': per-wiki existence/coreconfig files,
  * 'LocalSettings': per-wiki config files.
* Note that, with the current way of computing the variables (it was not 
explicitely
  constructed but it is finally quite good), the only data sources for the 
variables
  are in the host regex and the version, nothing else. When a variable is 
defined from
  another variable, it could be equivalently expanded with the variables from 
the host
  regex and, for $DATA, $VERSION, $CODE, and config files and keys, the version 
and
  version directory. E.g. if $SUFFIX='$family' and $WIKIID='$lang$SUFFIX', the 
second
  could have been written $WIKIID='$lang$family'. Saying this, intermediary 
variables
  are useful to shorten definition and improve their understanding.

Code:
* Removed the farm variable '$HTTP404' coming from farm config 'HTTP404'; it is 
now
  only computed when required (when a wiki is “soft-missing” = existing farm,
  nonexistant wiki) to avoid pollute the variables (reduce a bit the existence 
cache
  file explained just above) and I don’t think it would be required for any 
other variable.
* Removed the old subarray MediaWikiFarm::$config['general'] unused since some 
time
  (replaced by the two subarrays 'settings' and 'arrays').
* Removed execution of execFiles in MediaWikiFarm::loadMediaWikiConfig to avoid
  execution in a restricted scope, and it is already executed in LS.php or 
src/main.php.
* Sanitised host in MediaWikiFarm::__construct: now it is checked if the host 
has some
  corresponding file on the file system, so avoid any surprise (previously it 
was
  checked against a finite list of existing hosts).
* Cached LS.php now has only the host name as cache key, no more version: I 
don’t see
  any advantage in keeping the version, and on the long term it would pollute a 
bit
  the cache directory.
* In the cache directory, if some parent 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Cleaning

2016-12-03 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Cleaning
..


Cleaning

Remove unused code, replaced by dedicated code since some time.

Change-Id: Ida232cfde250c7f4bcc98dfea89bd8f5e40756c7
---
M src/MediaWikiFarm.php
M tests/phpunit/ConfigurationTest.php
2 files changed, 0 insertions(+), 165 deletions(-)

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



diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index d7a3315..7d47050 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -308,11 +308,6 @@
# Set other variables of the wiki
$this->setOtherVariables();
 
-   # Set available suffixes and wikis
-   # This is not useful since nobody else use available suffixes 
and wikis
-   # For now, remove loading of one config file to improve a bit 
performance
-   // $this->setWgConf();
-
# Cache the result
if( $this->cacheDir ) {
$variables = $this->variables;
@@ -863,25 +858,6 @@
}
 
/**
-* Set available suffixes and wikis.
-*
-* @todo Still hacky: before setting parameters in store in farms.yml, 
various configurations should be reviewed
-*   to select accordingly the rights management modelisation
-*
-* @return void
-*/
-   /*function setWgConf() {
-
-   global $wgConf;
-
-   $wgConf->suffixes = array( $this->variables['$SUFFIX'] );
-   $wikiIDs = $this->readFile( $this->variables['$SUFFIX'] . 
'/wikis.yml', $this->configDir );
-   foreach( array_keys( $wikiIDs ) as $wiki ) {
-   $wgConf->wikis[] = $wiki . '-' . 
$this->variables['$SUFFIX'];
-   }
-   }*/
-
-   /**
 * Is the cache configuration file LocalSettings.php for the requested 
wiki fresh?
 *
 * @mediawikifarm-const
@@ -943,13 +919,6 @@
 */
function getMediaWikiConfig( $force = false ) {
 
-   // global $wgConf;
-
-   # In MediaWiki 1.16, $wgConf is not created by default
-   // if( is_null( $wgConf ) ) {
-   //  $wgConf = new SiteConfiguration();
-   // }
-
if( !$force && $this->isLocalSettingsFresh() ) {
return;
}
@@ -969,22 +938,6 @@
return;
}
 
-   # Populate wgConf
-   // $this->populatewgConf();
-
-   # Get specific configuration for this wiki
-   # Do not use SiteConfiguration::extractAllGlobals or the 
configuration caching would become
-   # ineffective and there would be inconsistencies in this process
-   // $this->configuration['general'] = $wgConf->getAll( $myWiki, 
$mySuffix, array() );
-
-   # For the permissions array, fix a small strangeness: when an 
existing default permission
-   # is true, it is not possible to make it false in the specific 
configuration
-   // if( array_key_exists( '+wgGroupPermissions', 
$wgConf->settings ) ) {
-   //  $this->configuration['general']['wgGroupPermissions'] = 
self::arrayMerge( $this->configuration['general']['wgGroupPermissions'],
-   //  $wgConf->get( '+wgGroupPermissions', $myWiki, 
$mySuffix )
-   //  );
-   // }
-
# Get specific configuration for this wiki
$this->populateSettings();
 
@@ -998,93 +951,6 @@
rename( $localSettingsFile . '.tmp', 
$localSettingsFile );
}
}
-
-   // $wgConf->siteParamsCallback = array( $this, 
'SiteConfigurationSiteParamsCallback' );
-   }
-
-   /**
-* Popuplate wgConf from config files.
-*
-* @SuppressWarnings(PHPMD.ElseExpression)
-* @SuppressWarnings(PHPMD.CyclomaticComplexity)
-* @codeCoverageIgnore
-*
-* @return bool Success.
-*/
-   function populatewgConf() {
-
-   global $wgConf;
-
-   foreach( $this->farmConfig['config'] as $configFile ) {
-
-   if( !is_array( $configFile ) ) {
-   continue;
-   }
-
-   # Replace variables
-   $configFile = $this->replaceVariables( $configFile );
-
-   # Executable config files
-   if( array_key_exists( 'executable', $configFile ) && 
$configFile['executable'] ) {
-
-   $this->configuration['execFiles'][] = 
$this->configDir . '/' . $configFile['file'];
-   continue;
-   }
-
-  

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Cleaning

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

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

Change subject: Cleaning
..

Cleaning

Remove unused code, replaced by dedicated code since some time.

Change-Id: Ida232cfde250c7f4bcc98dfea89bd8f5e40756c7
---
M src/MediaWikiFarm.php
1 file changed, 0 insertions(+), 156 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index d7a3315..421362f 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -863,25 +863,6 @@
}
 
/**
-* Set available suffixes and wikis.
-*
-* @todo Still hacky: before setting parameters in store in farms.yml, 
various configurations should be reviewed
-*   to select accordingly the rights management modelisation
-*
-* @return void
-*/
-   /*function setWgConf() {
-
-   global $wgConf;
-
-   $wgConf->suffixes = array( $this->variables['$SUFFIX'] );
-   $wikiIDs = $this->readFile( $this->variables['$SUFFIX'] . 
'/wikis.yml', $this->configDir );
-   foreach( array_keys( $wikiIDs ) as $wiki ) {
-   $wgConf->wikis[] = $wiki . '-' . 
$this->variables['$SUFFIX'];
-   }
-   }*/
-
-   /**
 * Is the cache configuration file LocalSettings.php for the requested 
wiki fresh?
 *
 * @mediawikifarm-const
@@ -943,13 +924,6 @@
 */
function getMediaWikiConfig( $force = false ) {
 
-   // global $wgConf;
-
-   # In MediaWiki 1.16, $wgConf is not created by default
-   // if( is_null( $wgConf ) ) {
-   //  $wgConf = new SiteConfiguration();
-   // }
-
if( !$force && $this->isLocalSettingsFresh() ) {
return;
}
@@ -969,22 +943,6 @@
return;
}
 
-   # Populate wgConf
-   // $this->populatewgConf();
-
-   # Get specific configuration for this wiki
-   # Do not use SiteConfiguration::extractAllGlobals or the 
configuration caching would become
-   # ineffective and there would be inconsistencies in this process
-   // $this->configuration['general'] = $wgConf->getAll( $myWiki, 
$mySuffix, array() );
-
-   # For the permissions array, fix a small strangeness: when an 
existing default permission
-   # is true, it is not possible to make it false in the specific 
configuration
-   // if( array_key_exists( '+wgGroupPermissions', 
$wgConf->settings ) ) {
-   //  $this->configuration['general']['wgGroupPermissions'] = 
self::arrayMerge( $this->configuration['general']['wgGroupPermissions'],
-   //  $wgConf->get( '+wgGroupPermissions', $myWiki, 
$mySuffix )
-   //  );
-   // }
-
# Get specific configuration for this wiki
$this->populateSettings();
 
@@ -998,93 +956,6 @@
rename( $localSettingsFile . '.tmp', 
$localSettingsFile );
}
}
-
-   // $wgConf->siteParamsCallback = array( $this, 
'SiteConfigurationSiteParamsCallback' );
-   }
-
-   /**
-* Popuplate wgConf from config files.
-*
-* @SuppressWarnings(PHPMD.ElseExpression)
-* @SuppressWarnings(PHPMD.CyclomaticComplexity)
-* @codeCoverageIgnore
-*
-* @return bool Success.
-*/
-   function populatewgConf() {
-
-   global $wgConf;
-
-   foreach( $this->farmConfig['config'] as $configFile ) {
-
-   if( !is_array( $configFile ) ) {
-   continue;
-   }
-
-   # Replace variables
-   $configFile = $this->replaceVariables( $configFile );
-
-   # Executable config files
-   if( array_key_exists( 'executable', $configFile ) && 
$configFile['executable'] ) {
-
-   $this->configuration['execFiles'][] = 
$this->configDir . '/' . $configFile['file'];
-   continue;
-   }
-
-   $theseSettings = $this->readFile( $configFile['file'], 
$this->configDir );
-   if( $theseSettings === false ) {
-   # If a file is unavailable, skip it
-   continue;
-   }
-
-   # Key 'default' => no choice of the wiki
-   if( $configFile['key'] == 'default' ) {
-
-   foreach( $theseSettings as $setting => $value ) 
{
-

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Special config case

2016-12-03 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Special config case
..


Special config case

In the special case where the config key is a single wiki, the config file
does not have a 'parameter-wiki-value' structure but only 'parameter-value'

Change-Id: I892d1151a0b4b540fc85802966ff3c2538300671
---
M src/MediaWikiFarm.php
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index be28e78..d7a3315 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1149,7 +1149,7 @@
}
 
# Key 'default' => no choice of the wiki
-   if( $configFile['key'] == 'default' ) {
+   if( $configFile['key'] == 'default' || ( strpos( 
$configFile['key'], '*' ) === false && $this->variables['$WIKIID'] == 
$configFile['key'] ) ) {
 
foreach( $theseSettings as $setting => $value ) 
{
 
@@ -1168,7 +1168,7 @@
}
 
# Other key
-   else {
+   elseif( strpos( $configFile['key'], '*' ) !== false ) {
 
// $tags = array(); # @todo data sources not 
implemented, but code to selection parameters from a tag is below
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I892d1151a0b4b540fc85802966ff3c2538300671
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Seb35 
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...MediaWikiFarm[master]: Special config case

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

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

Change subject: Special config case
..

Special config case

In the special case where the config key is a single wiki, the config file
does not have a 'parameter-wiki-value' structure but only 'parameter-value'

Change-Id: I892d1151a0b4b540fc85802966ff3c2538300671
---
M src/MediaWikiFarm.php
1 file changed, 2 insertions(+), 2 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index be28e78..d7a3315 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1149,7 +1149,7 @@
}
 
# Key 'default' => no choice of the wiki
-   if( $configFile['key'] == 'default' ) {
+   if( $configFile['key'] == 'default' || ( strpos( 
$configFile['key'], '*' ) === false && $this->variables['$WIKIID'] == 
$configFile['key'] ) ) {
 
foreach( $theseSettings as $setting => $value ) 
{
 
@@ -1168,7 +1168,7 @@
}
 
# Other key
-   else {
+   elseif( strpos( $configFile['key'], '*' ) !== false ) {
 
// $tags = array(); # @todo data sources not 
implemented, but code to selection parameters from a tag is below
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I892d1151a0b4b540fc85802966ff3c2538300671
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improve testing

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

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

Change subject: Improve testing
..

Improve testing

* Instead of a hacky 'sed -i' in composer.json, dynamically declare the class
  MediaWikiTestCase if missing (when PHPUnit is called directly).
* Check if phpdbg is installed, else use php

Bug: T151879
Change-Id: I17604c11e773f74f2c8b7ccb6aa7919cb729d552
---
M composer.json
M tests/phpunit/MediaWikiFarmTestCase.php
2 files changed, 7 insertions(+), 10 deletions(-)


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

diff --git a/composer.json b/composer.json
index 7a94498..ad08cc8 100644
--- a/composer.json
+++ b/composer.json
@@ -27,16 +27,8 @@
"lint": "parallel-lint --exclude vendor .",
"phpcs": "phpcs -p -s",
"phpdoc": "phpdoc -d bin,src -t ./docs/code",
-   "phpunit": [
-   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
-   "phpdbg -qrr `which phpunit` --strict-coverage",
-   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
-   ],
-   "unit": [
-   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
-   "phpunit --no-coverage",
-   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
-   ],
+   "phpunit": "which phpdbg && phpdbg -qrr `which phpunit` 
--strict-coverage || phpunit --strict-coverage",
+   "unit": "phpunit --no-coverage",
"test": [
"composer lint",
"composer unit",
diff --git a/tests/phpunit/MediaWikiFarmTestCase.php 
b/tests/phpunit/MediaWikiFarmTestCase.php
index 9b5e037..832dd72 100644
--- a/tests/phpunit/MediaWikiFarmTestCase.php
+++ b/tests/phpunit/MediaWikiFarmTestCase.php
@@ -9,6 +9,11 @@
 
 require_once dirname( dirname( dirname( __FILE__ ) ) ) . 
'/src/AbstractMediaWikiFarmScript.php';
 
+# When executing PHPUnit alone, this class does not exist
+if( !class_exists( 'MediaWikiTestCase' ) ) {
+
+   class MediaWikiTestCase extends PHPUnit_Framework_TestCase {}
+}
 
 abstract class MediaWikiFarmTestCase extends MediaWikiTestCase {
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I17604c11e773f74f2c8b7ccb6aa7919cb729d552
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Add phpunit/phpunit 4.8.x to require-dev

2016-12-01 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Add phpunit/phpunit 4.8.x to require-dev
..


Add phpunit/phpunit 4.8.x to require-dev

Lets one use composer install && composer unit when PHPUnit is not
globally installed.

Bug: T151879
Change-Id: I4a028bbc4a0246c538e4210b3a45c1e55046c0bc
---
M composer.json
1 file changed, 1 insertion(+), 0 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/composer.json b/composer.json
index 00903f4..7a94498 100644
--- a/composer.json
+++ b/composer.json
@@ -17,6 +17,7 @@
"require-dev": {
"justinrainbow/json-schema": "~3.0",
"phpdocumentor/phpdocumentor": "*",
+   "phpunit/phpunit": "~4.8",
"jakub-onderka/php-parallel-lint": "*",
"phpmd/phpmd": "*",
"mediawiki/mediawiki-codesniffer": "*"

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4a028bbc4a0246c538e4210b3a45c1e55046c0bc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Hashar 
Gerrit-Reviewer: Hashar 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...ConfirmAccount[master]: Fix PHP notice 'Only variables should be assigned by reference'

2016-11-30 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Fix PHP notice 'Only variables should be assigned by reference'
..

Fix PHP notice 'Only variables should be assigned by reference'

Tested and working. It is standard in MediaWiki to use this
syntax without reference-assignment.

Bug: T152020
Change-Id: I15b576ff7df6c42b7a48cf7e40b2fea58737ed5d
---
M backend/ConfirmAccount.class.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmAccount 
refs/changes/15/324515/1

diff --git a/backend/ConfirmAccount.class.php b/backend/ConfirmAccount.class.php
index aacc3ac..1a04f24 100644
--- a/backend/ConfirmAccount.class.php
+++ b/backend/ConfirmAccount.class.php
@@ -214,7 +214,7 @@
public static function verifyAttachment( $tmpfile, $extension ) {
global $wgVerifyMimeType, $wgMimeTypeBlacklist;
 
-   $magic =& MimeMagic::singleton(); // magically determine mime 
type
+   $magic = MimeMagic::singleton(); // magically determine mime 
type
$mime = $magic->guessMimeType( $tmpfile, false );
# check mime type, if desired
if ( $wgVerifyMimeType ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I15b576ff7df6c42b7a48cf7e40b2fea58737ed5d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ConfirmAccount
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...ConfirmAccount[REL1_26]: Fix permission denied

2016-11-27 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Fix permission denied
..

Fix permission denied

Related to talk page https://www.mediawiki.org/wiki/Topic:Sf6zgc7plebtit4v

Bug: T121119
Change-Id: Ib5964951982474779077909b3c1305422b4b1d73
(cherry picked from commit 213beeec5241a93f859022e2aa4f7788583cc347)
---
M ConfirmAccount.config.php
M ConfirmAccount.php
2 files changed, 16 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmAccount 
refs/changes/88/323688/1

diff --git a/ConfirmAccount.config.php b/ConfirmAccount.config.php
index 350b766..86b51e2 100644
--- a/ConfirmAccount.config.php
+++ b/ConfirmAccount.config.php
@@ -81,8 +81,9 @@
 $wgConfirmAccountFSRepos = array(
'accountreqs' => array( # Location of attached files for pending 
requests
'name'   => 'accountreqs',
-   'directory'  => isset( $wgFileStore['accountreqs'] ) ?
-   $wgFileStore['accountreqs']['directory'] : 
$wgUploadDirectory . "/accountreqs",
+   'directory'  => isset( $wgFileStore['accountreqs'] )
+   ? $wgFileStore['accountreqs']['directory']
+   : false,
'url'=> isset( $wgFileStore['accountreqs'] ) ?
$wgFileStore['accountreqs']['url'] : null,
'hashLevels' => isset( $wgFileStore['accountreqs'] ) ?
@@ -90,8 +91,9 @@
),
'accountcreds' => array( # Location of credential files
'name'   => 'accountcreds',
-   'directory'  => isset( $wgFileStore['accountcreds'] ) ?
-   $wgFileStore['accountcreds']['directory'] : 
$wgUploadDirectory . "/accountcreds",
+   'directory'  => isset( $wgFileStore['accountcreds'] )
+   ? $wgFileStore['accountcreds']['directory']
+   : false,
'url'=> isset( $wgFileStore['accountcreds'] ) ?
$wgFileStore['accountcreds']['url'] : null,
'hashLevels' => isset( $wgFileStore['accountcreds'] ) ?
diff --git a/ConfirmAccount.php b/ConfirmAccount.php
index 803570b..5687e57 100644
--- a/ConfirmAccount.php
+++ b/ConfirmAccount.php
@@ -71,11 +71,20 @@
  * @return void
  */
 function efLoadConfirmAccount() {
-   global $wgEnableEmail;
+   global $wgEnableEmail, $wgConfirmAccountFSRepos, $wgUploadDirectory;
# This extension needs email enabled!
# Otherwise users can't get their passwords...
if ( !$wgEnableEmail ) {
echo "ConfirmAccount extension requires \$wgEnableEmail set to 
true.\n";
exit( 1 ) ;
}
+
+   if ( $wgConfirmAccountFSRepos['accountreqs']['directory'] === false ) {
+   $wgConfirmAccountFSRepos['accountreqs']['directory'] =
+   $wgUploadDirectory . "/accountreqs";
+   }
+   if ( $wgConfirmAccountFSRepos['accountcreds']['directory'] === false ) {
+   $wgConfirmAccountFSRepos['accountcreds']['directory'] =
+   $wgUploadDirectory . "/accountcreds";
+   }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5964951982474779077909b3c1305422b4b1d73
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ConfirmAccount
Gerrit-Branch: REL1_26
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Paladox 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Fix bug introduced in the previous commit, optimisations

2016-11-20 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Fix bug introduced in the previous commit, optimisations
..

Fix bug introduced in the previous commit, optimisations

Bugs:
* when the server name is cached in a file versions.php, only the filenames
  used for the configuration were written in this file, but this is not
  sufficient to re-create LS.php if origin config files were changed, so
  re-introduced the complete information in the cache file

Code:
* micro-optimisation: when checking presence of LS.php, directly answer no
  if there is no LS.php instead of answering no after checking origin config
  files
* do not invalidate LS.php when an executable PHP file is changed: given this
  one is always executed, there is no need of invalidating the cached LS.php

Change-Id: I54f17a0b94bb39fd9054475258a96e1cdfe402fb
---
M src/MediaWikiFarm.php
1 file changed, 8 insertions(+), 8 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 52de18a..be28e78 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -317,12 +317,7 @@
if( $this->cacheDir ) {
$variables = $this->variables;
$variables['$CORECONFIG'] = 
$this->farmConfig['coreconfig'];
-   $variables['$CONFIG'] = array();
-   foreach( $this->farmConfig['config'] as $file ) {
-   if( is_array( $file ) && ! ( array_key_exists( 
'executable', $file ) && $file['executable'] ) ) {
-   $variables['$CONFIG'][] = $file['file'];
-   }
-   }
+   $variables['$CONFIG'] = $this->farmConfig['config'];
$versions = $this->readFile( 'versions.php', dirname( 
$this->cacheDir ), false );
if( !is_array( $versions ) ) {
$versions = array();
@@ -905,10 +900,15 @@
$localSettingsFile = $this->cacheDir . '/' . 
$this->replaceVariables( 'LocalSettings-$SUFFIX-$WIKIID.php' );
}
 
+   # Check there is a LocalSettings.php file
+   if( !is_file( $localSettingsFile ) ) {
+   return false;
+   }
+
# Check modification time of original config files
$oldness = 0;
foreach( $this->farmConfig['config'] as $configFile ) {
-   if( !is_array( $configFile ) || !is_string( 
$configFile['file'] ) ) {
+   if( !is_array( $configFile ) || !is_string( 
$configFile['file'] ) || ( array_key_exists( 'executable', $configFile ) && 
$configFile['executable'] ) ) {
continue;
}
$file = $this->configDir . '/' . 
$this->replaceVariables( $configFile['file'] );
@@ -918,7 +918,7 @@
$oldness = max( $oldness, filemtime( $file ) );
}
 
-   return is_file( $localSettingsFile ) && ( filemtime( 
$localSettingsFile ) >= $oldness );
+   return filemtime( $localSettingsFile ) >= $oldness;
}
 
/**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I54f17a0b94bb39fd9054475258a96e1cdfe402fb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Added a mechanism to cache server name in the first step (se...

2016-11-19 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Added a mechanism to cache server name in the first step 
(server recognition)
..


Added a mechanism to cache server name in the first step (server recognition)

The second step was already cached (a per-wiki LocalSettings.php is created
according to its origin files), but the first step (server recognition) was not.
This is now the case: when a wiki is requested, its core variables (identifier,
version, code path, etc.) are computed and stored in a "cache file"; next times,
the host is recognised and its data are loaded. Note the origin files can be
different from a host to another due to the dynamic hierarchical loading, so 
these
origin files are themselves stored and validation is done after the loading
(if it is a cache miss, we have loaded these data for nothing but it is however
better to check cache freshness afterwards than never).

Also:
* added a JSON schema for the array stored in this new cache file
* added a parameter in MWF::readFile to avoid cache a file after reading
  (needed for this new feature)
* origin files used to create a decision for the existence of a certain host
  are registered in order to put them in the cache file and self-check the
  cache freshness ('coreconfig' in the code)
* added a system variable $FARM storing the farm name (needed for this new
  feature)

Schema change:
* renamed the property 'exec' to 'executable', more understandable

Bugs:
* fixed a bug in PHP 5.6 leading to a wrong extension loading mechanism due to
  a race condition: in these case we explicitely indicate the loading mechanism
  (introduced some days ago) with a parameter wgUseMyExtension, another 
mechanism
  could be used, because in a foreach loop where new keys are added, PHP 5 also
  evaluate these new keys (at the contrary of PHP 7 probably)
* AbstractMediaWikiFarmScript::copyr was not static although it should

Change-Id: I20f56c034975ed1c39da99dfc2f4f5c8bac2a8b8
---
M docs/config/farms.json
M docs/config/farms.php
M docs/config/farms.yml
M docs/configuration.rst
M docs/farms-schema.json
A docs/versions-schema.json
M src/AbstractMediaWikiFarmScript.php
M src/MediaWikiFarm.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
M tests/phpunit/data/config/farms.php
13 files changed, 158 insertions(+), 41 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/docs/config/farms.json b/docs/config/farms.json
index fdd911b..5ccb24c 100644
--- a/docs/config/farms.json
+++ b/docs/config/farms.json
@@ -6,7 +6,7 @@
"config": [
{
"file": "LocalSettings.php",
-   "exec": true
+   "executable": true
}
]
}
diff --git a/docs/config/farms.php b/docs/config/farms.php
index 91e998a..317d726 100644
--- a/docs/config/farms.php
+++ b/docs/config/farms.php
@@ -10,7 +10,7 @@
'wikiID' => 'mywiki',
'config' => array(
array( 'file' => 'LocalSettings.php',
-  'exec' => true,
+  'executable' => true,
),
),
),
@@ -48,7 +48,7 @@
   'key' => '*',
),
array( 'file' => 'org/ExecSettings.php',
-  'exec' => true,
+  'executable' => true,
),
),
),
@@ -81,7 +81,7 @@
   'key' => '*',
),
array( 'file' => 'com/example/ExecSettings.php',
-  'exec' => true,
+  'executable' => true,
),
),
),
diff --git a/docs/config/farms.yml b/docs/config/farms.yml
index f2ba1ba..82f4e2f 100644
--- a/docs/config/farms.yml
+++ b/docs/config/farms.yml
@@ -6,7 +6,7 @@
 wikiID: 'mywiki'
 config:
   - file: 'LocalSettings.php'
-exec: true
+executable: true
 
 
 ## Configuration similar to the Wikimedia farm
diff --git a/docs/configuration.rst b/docs/configuration.rst
index b8f38e1..2b34109 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -45,7 +45,7 @@
   - file: 'PrivateSettings.yml'
 key: '*'
   - file: 'ExecSettings.php'
-exec: true
+executable: true
 
 # Internally redirect .com to .org (obviously it can also be done on the 
HTTP level)
 '(?[a-z]+)\.(?[a-z]+)\.com':
@@ -110,7 +110,7 @@
 
 * If there is a subkey 'key' with another value containing '*' (mandatory 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Added special configuration to force a loading mechanism

2016-11-13 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Added special configuration to force a loading mechanism
..

Added special configuration to force a loading mechanism

Sometimes it is mandatory to use require_once, particularly when an extension is
required by a second extension is require_once-only. I recently encounter the 
case for:
* Translate (require_once-only) and UniversalLanguageSelector (bi-loading, but 
required by Translate)
* BlueSpiceFoundation (bi-loading but required by BlueSpiceExtensions 
(require_once-only)
Obviously this will change in the future and this feature will become unuseful, 
but for now
it is really needed.

Change-Id: Ib7dde20a0b780d9e80a788e4000916971e3a08b3
---
M src/MediaWikiFarm.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/data/config/extensionssettings.php
M tests/phpunit/data/config/testextensionsfarmversions.php
5 files changed, 54 insertions(+), 12 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 77dbdcd..2bb6be9 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1296,31 +1296,43 @@
 
# Search for skin and extension activation
foreach( $settings as $setting => $value ) {
-   if( preg_match( '/^wgUse(Extension|Skin)(.+)$/', 
$setting, $matches ) && $value === true ) {
+   if( preg_match( '/^wgUse(Extension|Skin)(.+)$/', 
$setting, $matches ) && ( $value === true || $value == 'require_once' || $value 
== 'composer' ) ) {
 
$type = strtolower( $matches[1] );
$name = $matches[2];
$loadingMechanism = 
$this->detectLoadingMechanism( $type, $name );
+   if( $value !== true ) {
+   $loadingMechanism = $value;
+   }
 
if( is_null( $loadingMechanism ) ) {
$settings[$setting] = false;
} else {
$this->configuration[$type.'s'][$name] 
= $loadingMechanism;
+   $settings[preg_replace( 
'/[^a-zA-Z0-9_\x7f\xff]/', '', $setting )] = true;
}
}
-   elseif( preg_match( '/^wgUse(.+)$/', $setting, $matches 
) && $value === true ) {
+   elseif( preg_match( '/^wgUse(.+)$/', $setting, $matches 
) && ( $value === true || $value == 'require_once' || $value == 'composer' ) ) {
 
$name = $matches[1];
 
$loadingMechanism = 
$this->detectLoadingMechanism( 'extension', $name );
if( !is_null( $loadingMechanism ) ) {
+   if( $value !== true ) {
+   $loadingMechanism = $value;
+   }

$this->configuration['extensions'][$name] = $loadingMechanism;

$settings['wgUseExtension'.preg_replace( '/[^a-zA-Z0-9_\x7f\xff]/', '', $name 
)] = true;
+   unset( $settings[$setting] );
} else {
$loadingMechanism = 
$this->detectLoadingMechanism( 'skin', $name );
if( !is_null( $loadingMechanism ) ) {
+   if( $value !== true ) {
+   $loadingMechanism = 
$value;
+   }

$this->configuration['skins'][$name] = $loadingMechanism;

$settings['wgUseSkin'.preg_replace( '/[^a-zA-Z0-9_\x7f\xff]/', '', $name )] = 
true;
+   unset( $settings[$setting] );
}
}
}
diff --git a/tests/phpunit/ConfigurationTest.php 
b/tests/phpunit/ConfigurationTest.php
index 7bd539f..c9cd346 100644
--- a/tests/phpunit/ConfigurationTest.php
+++ b/tests/phpunit/ConfigurationTest.php
@@ -158,6 +158,39 @@
$this->assertEquals( 'wfLoadExtension', 
$extensions['TestExtensionBiLoading'] );
$this->assertEquals( 'wfLoadExtension', 
$extensions['TestExtensionWfLoadExtension'] );
$this->assertEquals( 'wfLoadExtension', 
$extensions['MediaWikiFarm'] );
+
+   # Now with 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Bug: there was no more update of the cache when the origin f...

2016-11-13 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Bug: there was no more update of the cache when the origin file 
changed
..


Bug: there was no more update of the cache when the origin file changed

This worked in the first place, but was lost at some time

Change-Id: Ideddbf3eaaafa1cfde822ccce413fda7afaf4408
---
M src/MediaWikiFarm.php
M src/main.php
2 files changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index f6e8885..77dbdcd 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -918,7 +918,7 @@
}
 
# Populate from cache
-   if( $this->cacheDir && is_file( $this->cacheDir . '/' . 
$cacheFile ) ) {
+   if( !$force && $this->cacheDir && is_file( $this->cacheDir . 
'/' . $cacheFile ) ) {
$this->configuration = $this->readFile( $cacheFile, 
$this->cacheDir );
return;
}
diff --git a/src/main.php b/src/main.php
index b3588b8..e1a0eea 100644
--- a/src/main.php
+++ b/src/main.php
@@ -24,7 +24,7 @@
 }
 
 # Compile MediaWiki configuration
-$wgMediaWikiFarm->getMediaWikiConfig();
+$wgMediaWikiFarm->getMediaWikiConfig( true );
 
 # Load skins with the require_once mechanism
 foreach( $wgMediaWikiFarm->getConfiguration( 'skins' ) as $skin => $value ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ideddbf3eaaafa1cfde822ccce413fda7afaf4408
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Bug: there was no more update of the cache when the origin f...

2016-11-13 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Bug: there was no more update of the cache when the origin file 
changed
..

Bug: there was no more update of the cache when the origin file changed

This worked in the first place, but was lost at some time

Change-Id: Ideddbf3eaaafa1cfde822ccce413fda7afaf4408
---
M src/MediaWikiFarm.php
M src/main.php
2 files changed, 2 insertions(+), 2 deletions(-)


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

diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index f6e8885..77dbdcd 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -918,7 +918,7 @@
}
 
# Populate from cache
-   if( $this->cacheDir && is_file( $this->cacheDir . '/' . 
$cacheFile ) ) {
+   if( !$force && $this->cacheDir && is_file( $this->cacheDir . 
'/' . $cacheFile ) ) {
$this->configuration = $this->readFile( $cacheFile, 
$this->cacheDir );
return;
}
diff --git a/src/main.php b/src/main.php
index b3588b8..e1a0eea 100644
--- a/src/main.php
+++ b/src/main.php
@@ -24,7 +24,7 @@
 }
 
 # Compile MediaWiki configuration
-$wgMediaWikiFarm->getMediaWikiConfig();
+$wgMediaWikiFarm->getMediaWikiConfig( true );
 
 # Load skins with the require_once mechanism
 foreach( $wgMediaWikiFarm->getConfiguration( 'skins' ) as $skin => $value ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ideddbf3eaaafa1cfde822ccce413fda7afaf4408
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Fix bug in auto-detecting server name

2016-10-05 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Fix bug in auto-detecting server name
..


Fix bug in auto-detecting server name

CLI scripts don’t have $_SERVER['HTTP_HOST'] and hence MediaWiki’s
WebStart::detectServer doesn’t correctly guess the server name. Added
this global variable in CLI interface to fix it.

Change-Id: I207e9ed4953f947350e9569f2727ce2fd04724df
---
M src/MediaWikiFarmScript.php
1 file changed, 1 insertion(+), 0 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/src/MediaWikiFarmScript.php b/src/MediaWikiFarmScript.php
index bc88ed9..b7f8bdf 100644
--- a/src/MediaWikiFarmScript.php
+++ b/src/MediaWikiFarmScript.php
@@ -130,6 +130,7 @@
 
# Export symbols
$this->exportArguments();
+   $GLOBALS['_SERVER']['HTTP_HOST'] = $this->host;
 
return true;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I207e9ed4953f947350e9569f2727ce2fd04724df
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Add standalone PHPUnit and make some tests more robust

2016-09-26 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Add standalone PHPUnit and make some tests more robust
..


Add standalone PHPUnit and make some tests more robust

Code:
* Replaced the previous parameter $entryPoint in constructor
  by an array $parameters with EntryPoint (string) and
  ExtensionRegistry (bool) keys; the second allow to test
  a specific environment
* By default, the parameter ExtensionRegistry is computed
  just before its use, i.e. in the heuristic about the
  extension loading mechanism

Tests:
* Add some tests with a fixed ExtensionRegistry parameter to
  avoid relying on the underlying MediaWiki
* Changed the default environment from the underlying MediaWiki
  to a mocked MediaWiki installation

Testing:
* PHPUnit can still be called as a standard MediaWiki script
  `mwscript --wiki mywiki.org tests/phpunit/phpunit.php` and
  can also be called with a standalone PHPUnit; in this case
  it is easier to call `composer phpunit` or `composer unit`
  because a light change must be done on the testing code,
  automatically done with the Composer command
  NB: there is a bit less tests with standalone PHPUnit because
  some tests are automatically added in MW framework and the
  ExtensionRegistry class is missing
* Tested with processIsolation; adapted a bit to get successes
  in MultiversionInstallationTest
* Tested with PHP 7.1RC1 (cli and phpdbg) 7.0.10 (cli+Xdebug
  and phpdbg), and PHP 5.6 (cli): 100% line code coverage in
  PHP 7 but two lines wrongly missing in PHP 5.6.
* Approximative duration:
  * Standalone PHPUnit: 200ms for tests alone with PHP 7,
1.7s with code coverage
  * MediaWiki PHPUnit: 11s with PHP 7, 15s with code coverage,
30s with PHP 5.6

Change-Id: I55a468292bb37b4fc89934f1b6f32e4139581f7e
---
M .gitignore
M composer.json
A phpunit.xml
M src/MediaWikiFarm.php
M src/MediaWikiFarmScript.php
M tests/perfs/MediaWikiFarmTestPerfs.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/FunctionsTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
A tests/phpunit/data/config/varwikiversions.php
A tests/phpunit/data/config/versions.php
A tests/phpunit/data/mediawiki/vstub/maintenance/showJobs.php
A tests/phpunit/data/mediawiki/vstub2/maintenance/showJobs.php
19 files changed, 451 insertions(+), 171 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/.gitignore b/.gitignore
index fa4674d..9a307b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,11 +12,10 @@
 /vendor
 
 # Tests
-/tests/phpunit/data/config/versions.php
-/tests/phpunit/data/config/varwikiversions.php
 /tests/phpunit/data/config/deployments.php
 /tests/phpunit/data/config/testdeploymentsfarmversions.php
 /tests/perfs/results
 
 # Compiled code documentation
 /docs/code
+/docs/coverage
diff --git a/composer.json b/composer.json
index 7eb1384..00903f4 100644
--- a/composer.json
+++ b/composer.json
@@ -26,8 +26,20 @@
"lint": "parallel-lint --exclude vendor .",
"phpcs": "phpcs -p -s",
"phpdoc": "phpdoc -d bin,src -t ./docs/code",
+   "phpunit": [
+   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
+   "phpdbg -qrr `which phpunit` --strict-coverage",
+   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
+   ],
+   "unit": [
+   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
+   "phpunit --no-coverage",
+   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
+   ],
"test": [
"composer lint",
+   "composer unit",
+   "composer phpunit",
"composer phpcs",
"composer phpdoc"
]
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 000..aeeb9e1
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,35 @@
+http://www.w3.org/2001/XMLSchema-instance;
+ 
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd;
+ backupGlobals="false"
+ backupStaticAttributes="false"
+ cacheTokens="false"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ forceCoversAnnotation="true"
+ 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Add standalone PHPUnit and make some tests more robust

2016-09-26 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Add standalone PHPUnit and make some tests more robust
..

Add standalone PHPUnit and make some tests more robust

Code:
* Replaced the previous parameter $entryPoint in constructor
  by an array $parameters with EntryPoint (string) and
  ExtensionRegistry (bool) keys; the second allow to test
  a specific environment
* By default, the parameter ExtensionRegistry is computed
  just before its use, i.e. in the heuristic about the
  extension loading mechanism

Tests:
* Add some tests with a fixed ExtensionRegistry parameter to
  avoid relying on the underlying MediaWiki
* Changed the default environment from the underlying MediaWiki
  to a mocked MediaWiki installation

Testing:
* PHPUnit can still be called as a standard MediaWiki script
  `mwscript --wiki mywiki.org tests/phpunit/phpunit.php` and
  can also be called with a standalone PHPUnit; in this case
  it is easier to call `composer phpunit` or `composer unit`
  because a light change must be done on the testing code,
  automatically done with the Composer command
  NB: there is a bit less tests with standalone PHPUnit because
  some tests are automatically added in MW framework and the
  ExtensionRegistry class is missing
* Tested with processIsolation; adapted a bit to get successes
  in MultiversionInstallationTest
* Tested with PHP 7.1RC1 (cli and phpdbg) 7.0.10 (cli+Xdebug
  and phpdbg), and PHP 5.6 (cli): 100% line code coverage in
  PHP 7 but two lines wrongly missing in PHP 5.6.
* Approximative duration:
  * Standalone PHPUnit: 200ms for tests alone with PHP 7,
1.7s with code coverage
  * MediaWiki PHPUnit: 11s with PHP 7, 15s with code coverage,
30s with PHP 5.6

Change-Id: I55a468292bb37b4fc89934f1b6f32e4139581f7e
---
M .gitignore
M composer.json
A phpunit.xml
M src/MediaWikiFarm.php
M src/MediaWikiFarmScript.php
M tests/perfs/MediaWikiFarmTestPerfs.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/ConstructionTest.php
M tests/phpunit/FunctionsTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MonoversionInstallationTest.php
M tests/phpunit/MultiversionInstallationTest.php
A tests/phpunit/data/config/varwikiversions.php
A tests/phpunit/data/config/versions.php
A tests/phpunit/data/mediawiki/vstub/maintenance/showJobs.php
A tests/phpunit/data/mediawiki/vstub2/maintenance/showJobs.php
19 files changed, 451 insertions(+), 171 deletions(-)


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

diff --git a/.gitignore b/.gitignore
index fa4674d..9a307b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,11 +12,10 @@
 /vendor
 
 # Tests
-/tests/phpunit/data/config/versions.php
-/tests/phpunit/data/config/varwikiversions.php
 /tests/phpunit/data/config/deployments.php
 /tests/phpunit/data/config/testdeploymentsfarmversions.php
 /tests/perfs/results
 
 # Compiled code documentation
 /docs/code
+/docs/coverage
diff --git a/composer.json b/composer.json
index 7eb1384..00903f4 100644
--- a/composer.json
+++ b/composer.json
@@ -26,8 +26,20 @@
"lint": "parallel-lint --exclude vendor .",
"phpcs": "phpcs -p -s",
"phpdoc": "phpdoc -d bin,src -t ./docs/code",
+   "phpunit": [
+   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
+   "phpdbg -qrr `which phpunit` --strict-coverage",
+   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
+   ],
+   "unit": [
+   "sed -i 's/extends MediaWikiTestCase/extends 
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
+   "phpunit --no-coverage",
+   "sed -i 's/extends PHPUnit_Framework_TestCase/extends 
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
+   ],
"test": [
"composer lint",
+   "composer unit",
+   "composer phpunit",
"composer phpcs",
"composer phpdoc"
]
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 000..aeeb9e1
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,35 @@
+http://www.w3.org/2001/XMLSchema-instance;
+ 
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd;
+ backupGlobals="false"
+ backupStaticAttributes="false"
+ cacheTokens="false"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improvement of CLI scripts

2016-09-19 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Improvement of CLI scripts
..


Improvement of CLI scripts

Code:
* In case of error, exit codes in CLI were wrongly the same as
  HTTP return codes, but exit codes in CLI can only be between 0
  and 255, so documented some standard codes and implemented it
  (0=success, 1=missing wiki, 4=user error, 5=internal error)
* Deleted the method AbstractMediaWikiFarmScript::postmain which
  was not really useful
* Now AbstractMediaWikiFarmScript::premain and ::main return a
  boolean about success (and detailled error is in status property)
* Added methods AbstractMediaWikiFarmScript::rmdirr and ::copyr to
  recursively delete and copy directories, it will be useful to
  manage extensions with Composer
* Removed the use of "new static", which is not PHP 5.2 compatible,
  this temporarily break the performance test

Bugs:
* When a global array does not exist and we add some elements, a
  warning was trigerred in MediaWikiFarm::loadMediaWikiConfig
* Be sure wg* variables are syntactically correct for PHP, it was
  not the case for "wgUseExtensionConfirmEdit/QuestyCaptcha" but
  slash must be here in wfLoadExtension('ConfirmEdit/QuestyCaptcha')
  so remove the slash and any incorrect character after detecting
  extension loading mechanism

Change-Id: I02db05b939b968fca4b63fe57ea1bd8804c25b78
---
M .gitignore
M bin/mwscript.php
M src/AbstractMediaWikiFarmScript.php
M src/MediaWikiFarm.php
M src/MediaWikiFarmScript.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/data/config/extensionssettings.php
M tests/phpunit/data/config/settings.php
12 files changed, 298 insertions(+), 63 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/.gitignore b/.gitignore
index 49fc920..fa4674d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@
 .swp
 .*.swp
 *~
+.DS_Store
+*.kate-swp
 
 # Composer & npm
 /composer.lock
diff --git a/bin/mwscript.php b/bin/mwscript.php
index 0cc21ee..14751bf 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -21,9 +21,7 @@
 
 $wgMediaWikiFarmScript->load();
 
-$wgMediaWikiFarmScript->main();
-
-if( $wgMediaWikiFarmScript->status == 200 ) {
+if( $wgMediaWikiFarmScript->main() ) {
 
# Execute the script
require $wgMediaWikiFarmScript->argv[0];
diff --git a/src/AbstractMediaWikiFarmScript.php 
b/src/AbstractMediaWikiFarmScript.php
index 1c0e972..328930b 100644
--- a/src/AbstractMediaWikiFarmScript.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -16,6 +16,13 @@
  * Using a class instead of a raw script it better for testability purposes 
and to use
  * less global variables (in fact none; the only global variable written are 
for
  * compatibility purposes, e.g. PHPUnit expects $_SERVER['argv']).
+ *
+ * It is recommended to use the following values for status (in CLI, it must 
be a number
+ * between 0 and 255) and explain it in long help:
+ *   - 0 = success
+ *   - 1 = missing wiki (similar to HTTP 404)
+ *   - 4 = user error, like a missing parameter (similar to HTTP 400)
+ *   - 5 = internal error in farm configuration (similar to HTTP 500)
  */
 abstract class AbstractMediaWikiFarmScript {
 
@@ -152,9 +159,7 @@
@include_once dirname( dirname( __FILE__ ) ) . 
'/config/MediaWikiFarmDirectories.php';
 
# Load MediaWikiFarm class symbol
-   // @codingStandardsIgnoreStart 
MediaWiki.Usage.DirUsage.FunctionFound
require_once dirname( dirname( __FILE__ ) ) . 
'/src/MediaWikiFarm.php';
-   // @codingStandardsIgnoreEnd
}
 
/**
@@ -162,7 +167,7 @@
 *
 * NB: although it can be seen as superfluous, this is required in some 
cases to wipe off
 * the presence of MediaWikiFarm. The MediaWiki script 
'tests/phpunit/phpunit.php' and PHPUnit
-* need it (precisely $_SERVER['argv']; the other are for consistency).
+* need it (precisely $_SERVER['argv']; the others are for consistency).
 * Perhaps in the future some other globals will be changed, like in 
$_SERVER: PWD, PHP_SELF,
 * SCRIPT_NAME, SCRIPT_FILENAME, PATH_TRANSLATED, if it is needed.
 *
@@ -182,42 +187,28 @@
/**
 * Main program for the script, preliminary part.
 *
-* Although it returns void, the 'status' property can say if there was 
an error or not,
-* and if it becomes different than 0, the main program will (should) 
return.
-*
-* @return void.
+* @return bool If false, the main program should return.
 */
function premain() {
 
# Return usage
if( $this->argc == 2 && ( $this->argv[1] == '-h' || 
$this->argv[1] == '--help' ) ) {
 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Improvement of CLI scripts

2016-09-19 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Improvement of CLI scripts
..

Improvement of CLI scripts

Code:
* In case of error, exit codes in CLI were wrongly the same as
  HTTP return codes, but exit codes in CLI can only be between 0
  and 255, so documented some standard codes and implemented it
  (0=success, 1=missing wiki, 4=user error, 5=internal error)
* Deleted the method AbstractMediaWikiFarmScript::postmain which
  was not really useful
* Now AbstractMediaWikiFarmScript::premain and ::main return a
  boolean about success (and detailled error is in status property)
* Added methods AbstractMediaWikiFarmScript::rmdirr and ::copyr to
  recursively delete and copy directories, it will be useful to
  manage extensions with Composer
* Removed the use of "new static", which is not PHP 5.2 compatible,
  this temporarily break the performance test

Bugs:
* When a global array does not exist and we add some elements, a
  warning was trigerred in MediaWikiFarm::loadMediaWikiConfig
* Be sure wg* variables are syntactically correct for PHP, it was
  not the case for "wgUseExtensionConfirmEdit/QuestyCaptcha" but
  slash must be here in wfLoadExtension('ConfirmEdit/QuestyCaptcha')
  so remove the slash and any incorrect character after detecting
  extension loading mechanism

Change-Id: I02db05b939b968fca4b63fe57ea1bd8804c25b78
---
M .gitignore
M bin/mwscript.php
M src/AbstractMediaWikiFarmScript.php
M src/MediaWikiFarm.php
M src/MediaWikiFarmScript.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/InstallationIndependantTest.php
M tests/phpunit/LoadingTest.php
M tests/phpunit/MediaWikiFarmScriptTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/data/config/extensionssettings.php
M tests/phpunit/data/config/settings.php
12 files changed, 298 insertions(+), 63 deletions(-)


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

diff --git a/.gitignore b/.gitignore
index 49fc920..fa4674d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@
 .swp
 .*.swp
 *~
+.DS_Store
+*.kate-swp
 
 # Composer & npm
 /composer.lock
diff --git a/bin/mwscript.php b/bin/mwscript.php
index 0cc21ee..14751bf 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -21,9 +21,7 @@
 
 $wgMediaWikiFarmScript->load();
 
-$wgMediaWikiFarmScript->main();
-
-if( $wgMediaWikiFarmScript->status == 200 ) {
+if( $wgMediaWikiFarmScript->main() ) {
 
# Execute the script
require $wgMediaWikiFarmScript->argv[0];
diff --git a/src/AbstractMediaWikiFarmScript.php 
b/src/AbstractMediaWikiFarmScript.php
index 1c0e972..328930b 100644
--- a/src/AbstractMediaWikiFarmScript.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -16,6 +16,13 @@
  * Using a class instead of a raw script it better for testability purposes 
and to use
  * less global variables (in fact none; the only global variable written are 
for
  * compatibility purposes, e.g. PHPUnit expects $_SERVER['argv']).
+ *
+ * It is recommended to use the following values for status (in CLI, it must 
be a number
+ * between 0 and 255) and explain it in long help:
+ *   - 0 = success
+ *   - 1 = missing wiki (similar to HTTP 404)
+ *   - 4 = user error, like a missing parameter (similar to HTTP 400)
+ *   - 5 = internal error in farm configuration (similar to HTTP 500)
  */
 abstract class AbstractMediaWikiFarmScript {
 
@@ -152,9 +159,7 @@
@include_once dirname( dirname( __FILE__ ) ) . 
'/config/MediaWikiFarmDirectories.php';
 
# Load MediaWikiFarm class symbol
-   // @codingStandardsIgnoreStart 
MediaWiki.Usage.DirUsage.FunctionFound
require_once dirname( dirname( __FILE__ ) ) . 
'/src/MediaWikiFarm.php';
-   // @codingStandardsIgnoreEnd
}
 
/**
@@ -162,7 +167,7 @@
 *
 * NB: although it can be seen as superfluous, this is required in some 
cases to wipe off
 * the presence of MediaWikiFarm. The MediaWiki script 
'tests/phpunit/phpunit.php' and PHPUnit
-* need it (precisely $_SERVER['argv']; the other are for consistency).
+* need it (precisely $_SERVER['argv']; the others are for consistency).
 * Perhaps in the future some other globals will be changed, like in 
$_SERVER: PWD, PHP_SELF,
 * SCRIPT_NAME, SCRIPT_FILENAME, PATH_TRANSLATED, if it is needed.
 *
@@ -182,42 +187,28 @@
/**
 * Main program for the script, preliminary part.
 *
-* Although it returns void, the 'status' property can say if there was 
an error or not,
-* and if it becomes different than 0, the main program will (should) 
return.
-*
-* @return void.
+* @return bool If false, the main program should return.
 */
function premain() {
 
# Return usage
if( 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Minor refactoring of CLI part

2016-09-16 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Minor refactoring of CLI part
..


Minor refactoring of CLI part

Code:
* Create an abstract class AbstractMediaWikiFarmScript containing 
general-purpose
  methods and a real class MediaWikiFarmScript directly used by 
'bin/mwscript.php';
  the abstract class will be useful for another script in development about 
handling
  Composer-installed extensions

Bugs:
* Scripts in composer.json was in wrong (old) directory 'scripts'

Change-Id: I50e475b249a74b976b226215e652ab6552742244
---
M bin/mwscript.php
M composer.json
M phpcs.xml
R src/AbstractMediaWikiFarmScript.php
A src/MediaWikiFarmScript.php
R tests/phpunit/MediaWikiFarmScriptTest.php
6 files changed, 240 insertions(+), 117 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/bin/mwscript.php b/bin/mwscript.php
index c1952f3..0cc21ee 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -1,6 +1,6 @@
 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
@@ -14,7 +14,7 @@
 }
 
 # Load classes
-require_once dirname( dirname( __FILE__ ) ) . '/src/Script.php';
+require_once dirname( dirname( __FILE__ ) ) . '/src/MediaWikiFarmScript.php';
 
 # Prepare environment
 $wgMediaWikiFarmScript = new MediaWikiFarmScript( $argc, $argv );
diff --git a/composer.json b/composer.json
index 8feeb8e..7eb1384 100644
--- a/composer.json
+++ b/composer.json
@@ -22,9 +22,14 @@
"mediawiki/mediawiki-codesniffer": "*"
},
"scripts": {
-   "validate-schema": "php ./scripts/validate-schema.php",
-   "phpdoc": "./vendor/bin/phpdoc -d src,scripts -e php,php.txt -t 
./docs/code",
-   "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor 
.",
-   "phpcs": "phpcs -p -s"
+   "validate-schema": "php ./bin/validate-schema.php",
+   "lint": "parallel-lint --exclude vendor .",
+   "phpcs": "phpcs -p -s",
+   "phpdoc": "phpdoc -d bin,src -t ./docs/code",
+   "test": [
+   "composer lint",
+   "composer phpcs",
+   "composer phpdoc"
+   ]
}
 }
diff --git a/phpcs.xml b/phpcs.xml
index c52652f..6224889 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -23,6 +23,11 @@



+   
+   
+   
+   
+   


tests/perfs/results
diff --git a/src/Script.php b/src/AbstractMediaWikiFarmScript.php
similarity index 61%
rename from src/Script.php
rename to src/AbstractMediaWikiFarmScript.php
index 17774c5..1c0e972 100644
--- a/src/Script.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -7,13 +7,17 @@
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
  */
 
+// @codeCoverageIgnoreStart
+require_once dirname( __FILE__ ) . '/MediaWikiFarm.php';
+// @codeCoverageIgnoreEnd
+
 /**
  * This class contains the major part of the script utility, mainly in the 
main() method.
  * Using a class instead of a raw script it better for testability purposes 
and to use
  * less global variables (in fact none; the only global variable written are 
for
  * compatibility purposes, e.g. PHPUnit expects $_SERVER['argv']).
  */
-class MediaWikiFarmScript {
+abstract class AbstractMediaWikiFarmScript {
 
/** @var int Number of input arguments. */
public $argc = 0;
@@ -21,11 +25,14 @@
/** @var string[] Input arguments. */
public $argv = array();
 
+   /** @var string Short usage, displayed on request or error. */
+   public $shortUsage = '';
+
+   /** @var string Long usage, displayed on request. */
+   public $longUsage = '';
+
/** @var string Host name. */
public $host = '';
-
-   /** @var string Script name. */
-   public $script = '';
 
/** @var int Status. */
public $status = 0;
@@ -35,7 +42,7 @@
 *
 * @param int $argc Number of input arguments.
 * @param string[] $argv Input arguments.
-* @return MediaWikiFarmScript
+* @return AbstractMediaWikiFarmScript
 */
function __construct( $argc, $argv ) {
 
@@ -97,47 +104,26 @@
}
 
/**
-* Display help and return success or error.
+* Display help.
 *
-* @mediawikifarm-const
-* @mediawikifarm-idempotent
-*
-* @param bool $error Return an error code?
-* @return void
+* @param bool $long Show extended usage.
+* @return void.
 */
-   function usage( $error = true ) {
-
-   $fullPath = realpath( $this->argv[0] );
+   function usage( $long = false ) {
 
# Minimal help, be it an error or not
-   echo <

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Minor refactoring of CLI part

2016-09-16 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Minor refactoring of CLI part
..

Minor refactoring of CLI part

Code:
* Create an abstract class AbstractMediaWikiFarmScript containing 
general-purpose
  methods and a real class MediaWikiFarmScript directly used by 
'bin/mwscript.php';
  the abstract class will be useful for another script in development about 
handling
  Composer-installed extensions

Bugs:
* Scripts in composer.json was in wrong (old) directory 'scripts'

Change-Id: I50e475b249a74b976b226215e652ab6552742244
---
M bin/mwscript.php
M composer.json
M phpcs.xml
R src/AbstractMediaWikiFarmScript.php
A src/MediaWikiFarmScript.php
R tests/phpunit/MediaWikiFarmScriptTest.php
6 files changed, 240 insertions(+), 117 deletions(-)


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

diff --git a/bin/mwscript.php b/bin/mwscript.php
index c1952f3..0cc21ee 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -1,6 +1,6 @@
 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
@@ -14,7 +14,7 @@
 }
 
 # Load classes
-require_once dirname( dirname( __FILE__ ) ) . '/src/Script.php';
+require_once dirname( dirname( __FILE__ ) ) . '/src/MediaWikiFarmScript.php';
 
 # Prepare environment
 $wgMediaWikiFarmScript = new MediaWikiFarmScript( $argc, $argv );
diff --git a/composer.json b/composer.json
index 8feeb8e..7eb1384 100644
--- a/composer.json
+++ b/composer.json
@@ -22,9 +22,14 @@
"mediawiki/mediawiki-codesniffer": "*"
},
"scripts": {
-   "validate-schema": "php ./scripts/validate-schema.php",
-   "phpdoc": "./vendor/bin/phpdoc -d src,scripts -e php,php.txt -t 
./docs/code",
-   "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor 
.",
-   "phpcs": "phpcs -p -s"
+   "validate-schema": "php ./bin/validate-schema.php",
+   "lint": "parallel-lint --exclude vendor .",
+   "phpcs": "phpcs -p -s",
+   "phpdoc": "phpdoc -d bin,src -t ./docs/code",
+   "test": [
+   "composer lint",
+   "composer phpcs",
+   "composer phpdoc"
+   ]
}
 }
diff --git a/phpcs.xml b/phpcs.xml
index c52652f..6224889 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -23,6 +23,11 @@



+   
+   
+   
+   
+   


tests/perfs/results
diff --git a/src/Script.php b/src/AbstractMediaWikiFarmScript.php
similarity index 61%
rename from src/Script.php
rename to src/AbstractMediaWikiFarmScript.php
index 17774c5..1c0e972 100644
--- a/src/Script.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -7,13 +7,17 @@
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
  */
 
+// @codeCoverageIgnoreStart
+require_once dirname( __FILE__ ) . '/MediaWikiFarm.php';
+// @codeCoverageIgnoreEnd
+
 /**
  * This class contains the major part of the script utility, mainly in the 
main() method.
  * Using a class instead of a raw script it better for testability purposes 
and to use
  * less global variables (in fact none; the only global variable written are 
for
  * compatibility purposes, e.g. PHPUnit expects $_SERVER['argv']).
  */
-class MediaWikiFarmScript {
+abstract class AbstractMediaWikiFarmScript {
 
/** @var int Number of input arguments. */
public $argc = 0;
@@ -21,11 +25,14 @@
/** @var string[] Input arguments. */
public $argv = array();
 
+   /** @var string Short usage, displayed on request or error. */
+   public $shortUsage = '';
+
+   /** @var string Long usage, displayed on request. */
+   public $longUsage = '';
+
/** @var string Host name. */
public $host = '';
-
-   /** @var string Script name. */
-   public $script = '';
 
/** @var int Status. */
public $status = 0;
@@ -35,7 +42,7 @@
 *
 * @param int $argc Number of input arguments.
 * @param string[] $argv Input arguments.
-* @return MediaWikiFarmScript
+* @return AbstractMediaWikiFarmScript
 */
function __construct( $argc, $argv ) {
 
@@ -97,47 +104,26 @@
}
 
/**
-* Display help and return success or error.
+* Display help.
 *
-* @mediawikifarm-const
-* @mediawikifarm-idempotent
-*
-* @param bool $error Return an error code?
-* @return void
+* @param bool $long Show extended usage.
+* @return void.
 */
-   function usage( $error = true ) {
-
-   $fullPath = realpath( $this->argv[0] );
+   function usage( $long = false ) {
 
# Minimal help, be it 

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Minor maintenance

2016-09-15 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Minor maintenance
..


Minor maintenance

Code:
* An inherited method did not have the same signature.

Code doc:
* Fixed the some doc issues.

Change-Id: Iaf6589f166678387e8fa7567d73083540a1d0ac9
---
M .gitignore
M src/MediaWikiFarm.php
M tests/perfs/MediaWikiFarmTestPerfs.php
3 files changed, 9 insertions(+), 10 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/.gitignore b/.gitignore
index 67b3c9f..49fc920 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,15 +9,12 @@
 /node_modules
 /vendor
 
-# Web access for multiversion farms
-# You can put e.g. dedicated 404 error pages in addition of entry points
-# If you want to version-control this subdirectory with git, you can – in this 
case
-# add /index.php and others in its .gitignore to avoid double version-control.)
-/www
-
 # Tests
 /tests/phpunit/data/config/versions.php
 /tests/phpunit/data/config/varwikiversions.php
 /tests/phpunit/data/config/deployments.php
 /tests/phpunit/data/config/testdeploymentsfarmversions.php
 /tests/perfs/results
+
+# Compiled code documentation
+/docs/code
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5a5ae9e..0b24d82 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1255,7 +1255,7 @@
 * @codeCoverageIgnore
 *
 * @param SiteConfiguration $wgConf SiteConfiguration object.
-* @param string $dbName Database name.
+* @param string $wikiID Database name.
 * @return array
 */
function SiteConfigurationSiteParamsCallback( $wgConf, $wikiID ) {
@@ -1439,7 +1439,7 @@
 * Set a wiki property and replace placeholders (property name version).
 *
 * @param string $name Name of the property.
-* @param bool This variable is mandatory.
+* @param bool $mandatory This variable is mandatory.
 * @return void
 * @throws MWFConfigurationException When the variable is mandatory and 
missing.
 * @throws InvalidArgumentException
@@ -1714,6 +1714,7 @@
 * @mediawikifarm-idempotent
 * @SuppressWarning(PHPMD.StaticAccess)
 *
+* @param array $array1 First array.
 * @return array
 */
static function arrayMerge( $array1 /* ... */ ) {
diff --git a/tests/perfs/MediaWikiFarmTestPerfs.php 
b/tests/perfs/MediaWikiFarmTestPerfs.php
index 23f2f0a..a2b48da 100644
--- a/tests/perfs/MediaWikiFarmTestPerfs.php
+++ b/tests/perfs/MediaWikiFarmTestPerfs.php
@@ -162,13 +162,14 @@
 *
 * This function is very similar to its parent but is performance-spied.
 *
+* @param bool $force Whether to force loading in $this->configuration 
even if there is a LocalSettings.php
 * @return void.
 */
-   function getMediaWikiConfig() {
+   function getMediaWikiConfig( $force = false ) {
 
MediaWikiFarmTestPerfs::startCounter( 'compilation' );
 
-   parent::getMediaWikiConfig();
+   parent::getMediaWikiConfig( $force );
 
MediaWikiFarmTestPerfs::stopCounter( 'compilation' );
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iaf6589f166678387e8fa7567d73083540a1d0ac9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Seb35 

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


[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Minor maintenance

2016-09-15 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

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

Change subject: Minor maintenance
..

Minor maintenance

Code:
* An inherited method did not have the same signature.

Code doc:
* Fixed the some doc issues.

Change-Id: Iaf6589f166678387e8fa7567d73083540a1d0ac9
---
M .gitignore
M src/MediaWikiFarm.php
M tests/perfs/MediaWikiFarmTestPerfs.php
3 files changed, 9 insertions(+), 10 deletions(-)


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

diff --git a/.gitignore b/.gitignore
index 67b3c9f..49fc920 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,15 +9,12 @@
 /node_modules
 /vendor
 
-# Web access for multiversion farms
-# You can put e.g. dedicated 404 error pages in addition of entry points
-# If you want to version-control this subdirectory with git, you can – in this 
case
-# add /index.php and others in its .gitignore to avoid double version-control.)
-/www
-
 # Tests
 /tests/phpunit/data/config/versions.php
 /tests/phpunit/data/config/varwikiversions.php
 /tests/phpunit/data/config/deployments.php
 /tests/phpunit/data/config/testdeploymentsfarmversions.php
 /tests/perfs/results
+
+# Compiled code documentation
+/docs/code
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 5a5ae9e..0b24d82 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -1255,7 +1255,7 @@
 * @codeCoverageIgnore
 *
 * @param SiteConfiguration $wgConf SiteConfiguration object.
-* @param string $dbName Database name.
+* @param string $wikiID Database name.
 * @return array
 */
function SiteConfigurationSiteParamsCallback( $wgConf, $wikiID ) {
@@ -1439,7 +1439,7 @@
 * Set a wiki property and replace placeholders (property name version).
 *
 * @param string $name Name of the property.
-* @param bool This variable is mandatory.
+* @param bool $mandatory This variable is mandatory.
 * @return void
 * @throws MWFConfigurationException When the variable is mandatory and 
missing.
 * @throws InvalidArgumentException
@@ -1714,6 +1714,7 @@
 * @mediawikifarm-idempotent
 * @SuppressWarning(PHPMD.StaticAccess)
 *
+* @param array $array1 First array.
 * @return array
 */
static function arrayMerge( $array1 /* ... */ ) {
diff --git a/tests/perfs/MediaWikiFarmTestPerfs.php 
b/tests/perfs/MediaWikiFarmTestPerfs.php
index 23f2f0a..a2b48da 100644
--- a/tests/perfs/MediaWikiFarmTestPerfs.php
+++ b/tests/perfs/MediaWikiFarmTestPerfs.php
@@ -162,13 +162,14 @@
 *
 * This function is very similar to its parent but is performance-spied.
 *
+* @param bool $force Whether to force loading in $this->configuration 
even if there is a LocalSettings.php
 * @return void.
 */
-   function getMediaWikiConfig() {
+   function getMediaWikiConfig( $force = false ) {
 
MediaWikiFarmTestPerfs::startCounter( 'compilation' );
 
-   parent::getMediaWikiConfig();
+   parent::getMediaWikiConfig( $force );
 
MediaWikiFarmTestPerfs::stopCounter( 'compilation' );
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf6589f166678387e8fa7567d73083540a1d0ac9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MediaWikiFarm
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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


  1   2   3   >