[MediaWiki-commits] [Gerrit] Avoid accessing private $filters field - change (mediawiki...ContentTranslation)
Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/299438 Change subject: Avoid accessing private $filters field .. Avoid accessing private $filters field Use getFilter() instead. Bug: T139657 Change-Id: Ibb8600fe68fd7d08bba498509aefbb57330769ab --- M includes/AbuseFilterCheck.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/38/299438/1 diff --git a/includes/AbuseFilterCheck.php b/includes/AbuseFilterCheck.php index 21626d9..3b351b7 100644 --- a/includes/AbuseFilterCheck.php +++ b/includes/AbuseFilterCheck.php @@ -118,7 +118,7 @@ $results = []; foreach ( $actions as $key => $val ) { - $rulename = \AbuseFilter::$filters[$key]->af_public_comments; + $rulename = \AbuseFilter::getFilter( $key )->af_public_comments; // No point alerting the user about non-serious actions. T136596 $actionsForRule = array_keys( $val ); -- To view, visit https://gerrit.wikimedia.org/r/299438 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibb8600fe68fd7d08bba498509aefbb57330769ab Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Aaron Schulz ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] When a config file is missing, do not more exit but skip - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299433 Change subject: When a config file is missing, do not more exit but skip .. When a config file is missing, do not more exit but skip --- M src/MediaWikiFarm.php 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/33/299433/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 8117c69..45f509d 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -769,8 +769,11 @@ $theseSettings = $this->readFile( $configFile['file'], $this->configDir ); if( $theseSettings === false ) { - $this->unusable = true; - return false; + # If a file is unavailable, skip it + continue; + # Exiting is fatal and, in case of mistake, is worse than some parameters missing + #$this->unusable = true; + #return false; } # Key 'default' => no choice of the wiki -- To view, visit https://gerrit.wikimedia.org/r/299433 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7485123f9240c44ff7828af5874493aac99a2963 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] Merge .gitreview with existing history - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299437 Change subject: Merge .gitreview with existing history .. Merge .gitreview with existing history Change-Id: Ia6bb3ed6caff533076df4086d94bfdb53a6dc043 --- 0 files changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/37/299437/1 -- To view, visit https://gerrit.wikimedia.org/r/299437 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia6bb3ed6caff533076df4086d94bfdb53a6dc043 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] Added documentation i18n file - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299432 Change subject: Added documentation i18n file .. Added documentation i18n file --- M .gitignore A i18n/qqq.json 2 files changed, 10 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/32/299432/1 diff --git a/.gitignore b/.gitignore index 4f1842a..0cae6cb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ *.swp *~ -# Composer +# Composer & npm +/node_modules /vendor # Installation diff --git a/i18n/qqq.json b/i18n/qqq.json new file mode 100644 index 000..bb43c01 --- /dev/null +++ b/i18n/qqq.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "Seb35" + ] + }, + "mediawikifarm-desc": "{{desc|name=MediaWikiFarm|url=https://www.mediawiki.org/wiki/Extension:MediaWikiFarm}}"; +} -- To view, visit https://gerrit.wikimedia.org/r/299432 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1b18ac86bed5a5452cbbcf230b24857904b33122 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] Added CodeSniffer as dev dependency - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299435 Change subject: Added CodeSniffer as dev dependency .. Added CodeSniffer as dev dependency --- M composer.json 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/35/299435/1 diff --git a/composer.json b/composer.json index 185a3a2..0cbf2f2 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,13 @@ "justinrainbow/json-schema": "*", "phpdocumentor/phpdocumentor": "*", "jakub-onderka/php-parallel-lint": "*", - "phpmd/phpmd" : "*" + "phpmd/phpmd": "*", + "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 ." + "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor .", + "phpcs": "phpcs -p -s" } } -- To view, visit https://gerrit.wikimedia.org/r/299435 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I96ad343b2433231dafe1c035abdf46c4d48db182 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] Added a possibility to customise the 'nonexistant wiki' page... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299434 Change subject: Added a possibility to customise the 'nonexistant wiki' page (HTTP 404) .. Added a possibility to customise the 'nonexistant wiki' page (HTTP 404) It can be either an HTML or PHP page, and is defined per-farm. This is not display in CLI (return code 1), nor when entry points are not index.php (e.g. load.php) to avoid waste resources displaying an entire HTML page. --- M docs/farms-schema.json M src/MediaWikiFarm.php 2 files changed, 12 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/34/299434/1 diff --git a/docs/farms-schema.json b/docs/farms-schema.json index b3d0689..6b1d865 100644 --- a/docs/farms-schema.json +++ b/docs/farms-schema.json @@ -58,6 +58,10 @@ "type": "string", "description": "File containing an array where each key is a wikiID and each value is the corresponding MediaWiki version." }, + "nonexistant": { + "type": "string", + "description": "PHP or HTML file displayed in case of a nonexistant wiki." + }, "data": { "type": "string", "description": "Data directory where files of the wiki are stored." diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 45f509d..113bd48 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -69,10 +69,15 @@ # Check existence if( !$wgMediaWikiFarm->checkExistence() ) { + if( PHP_SAPI == 'cli' ) + exit( 1 ); + + # Display an informational page when the requested wiki doesn’t exist, only when a page was requested, but not a resource, to avoid waste resources $version = $_SERVER['SERVER_PROTOCOL'] && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.0' ? '1.0' : '1.1'; - if( PHP_SAPI != 'cli' ) header( "HTTP/$version 404 Not Found" ); - echo "Error: unknown wiki.\n"; - exit( 1 ); + header( "HTTP/$version 404 Not Found" ); + if( $entryPoint == 'index.php' && array_key_exists( 'nonexistant', $wgMediaWikiFarm->params ) && is_file( $wgMediaWikiFarm->params['nonexistant'] ) ) + include $wgMediaWikiFarm->params['nonexistant']; + exit; } # Go to version directory -- To view, visit https://gerrit.wikimedia.org/r/299434 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5dd626f36b8fa94c493149bf98d55b55671042a0 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] Added a mechanism to always use the same version until maint... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299430 Change subject: Added a mechanism to always use the same version until maintenance/update.php is run .. Added a mechanism to always use the same version until maintenance/update.php is run This allows a better consistency: the inventory file can be updated with the new version (nothing change for now), then update.php is run (nothing change until the end of the script), and then the new version is used. This is also a micro-caching mechanism: a small piece of logic is avoided, although this only minor. --- M scripts/mwscript.php M src/MediaWikiFarm.php 2 files changed, 77 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/30/299430/1 diff --git a/scripts/mwscript.php b/scripts/mwscript.php index 7b392ae..08b4fa5 100644 --- a/scripts/mwscript.php +++ b/scripts/mwscript.php @@ -170,3 +170,6 @@ } require $argv[0]; +# Update version after maintenance/update.php (the only case where another version is given before execution) +MediaWikiFarm::getInstance()->updateVersionAfterMaintenance(); + diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 3ed0bfb..7563cc0 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -253,6 +253,19 @@ } /** +* Synchronise the version in the 'expected version' and deployment files. +* +* @return void +*/ + function updateVersionAfterMaintenance() { + + if( !array_key_exists( 'version', $this->params ) ) + return; + + $this->updateVersion( $this->params['version'] ); + } + + /** * Return the file where is loaded the configuration. * * This function is important to avoid the two parts of the extension (checking of @@ -511,17 +524,39 @@ */ private function setVersion( $version = null ) { - global $IP; + global $IP, $mwfScript; - # Replace variables in the file name containing all versions, if existing - $this->setWikiProperty( 'versions' ); + # Special case for the update: new (uncached) version must be used + $force = false; + if( is_string( $mwfScript ) && $mwfScript == 'maintenance/update.php' ) + $force = true; + + # Read cache file + $deployments = array(); + $this->setWikiProperty( 'deployments' ); + if( array_key_exists( 'deployments', $this->params ) && !$force ) { + if( strrchr( $this->params['deployments'], '.' ) != '.php' ) $this->params['deployments'] .= '.php'; + $deployments = $this->readFile( $this->params['deployments'], $this->configDir ); + if( $deployments === false ) $deployments = array(); + } + if( array_key_exists( $this->params['wikiID'], $deployments ) ) + $this->params['code'] = $this->codeDir . '/' . $deployments[$this->params['wikiID']]; # In the case multiversion is configured and version is already known - if( is_string( $this->codeDir ) && is_string( $version ) ) + elseif( is_string( $this->codeDir ) && is_string( $version ) ) { + + # Cache the version + if( !$force ) + $this->updateVersion( $version ); + $this->params['code'] = $this->codeDir . '/' . $version; + } # In the case multiversion is configured, but version is not known as of now elseif( is_string( $this->codeDir ) && is_null( $version ) ) { + + # Replace variables in the file name containing all versions, if existing + $this->setWikiProperty( 'versions' ); $versions = $this->readFile( $this->params['versions'], $this->configDir ); @@ -540,6 +575,10 @@ $version = $versions['default']; else return false; + + # Cache the version + if( !$force ) + $this->updateVersion( $version ); $this->params['code'] = $this->codeDir . '/' . $version; } @@ -560,6 +599,30 @@ $this->params['version'] = $version; retu
[MediaWiki-commits] [Gerrit] Fix bug when there are no extensions enabled (or skins) - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299426 Change subject: Fix bug when there are no extensions enabled (or skins) .. Fix bug when there are no extensions enabled (or skins) --- M src/MediaWikiFarm.php 1 file changed, 9 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/26/299426/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 51dc4ef..3b1808e 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -767,35 +767,35 @@ } # Extract skin and extension configuration from the general configuration - $regexSkins = '/^wg(' . implode( '|', + $regexSkins = count( $globals['skins'] ) ? '/^wg(' . implode( '|', array_map( function( $a ) { return preg_quote( $a, '/' ); }, array_keys( $globals['skins'] ) ) - ) . ')/'; - $regexExtensions = '/^wg(' . implode( '|', + ) . ')/' : false; + $regexExtensions = count( $globals['extensions'] ) ? '/^wg(' . implode( '|', array_map( function( $a ) { return preg_quote( $a, '/' ); }, array_keys( $globals['extensions'] ) ) - ) . ')/'; - $regexUnsetPrefixes = '/^wg(' . implode( '|', + ) . ')/' : false; + $regexUnsetPrefixes = count( $unsetPrefixes ) ? '/^wg(' . implode( '|', array_map( function( $a ) { return preg_quote( $a, '/' ); }, $unsetPrefixes ) - ) . ')/'; + ) . ')/' : false; foreach( $globals['general'] as $setting => $value ) { - if( preg_match( $regexSkins, $setting, $matches ) ) { + if( $regexSkins && preg_match( $regexSkins, $setting, $matches ) ) { $globals['skins'][$matches[1]][$setting] = $value; unset( $setting ); } - elseif( preg_match( $regexExtensions, $setting, $matches ) ) { + elseif( $regexExtensions && preg_match( $regexExtensions, $setting, $matches ) ) { $globals['extensions'][$matches[1]][$setting] = $value; unset( $setting ); } - elseif( preg_match( $regexUnsetPrefixes, $setting, $matches ) ) + elseif( $regexUnsetPrefixes && preg_match( $regexUnsetPrefixes, $setting, $matches ) ) unset( $matches[1] ); } } -- To view, visit https://gerrit.wikimedia.org/r/299426 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3916b54352551fe9fe7c89c353eda4f72dbdefdd 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] Disable the cache if requested - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299423 Change subject: Disable the cache if requested .. Disable the cache if requested Previously it was not possible to disable the cache due to this bug --- M src/MediaWikiFarm.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/23/299423/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index f028358..43ffea5 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -298,7 +298,7 @@ if( is_file( dirname( dirname( $this->farmDir ) ) . '/includes/DefaultSettings.php' ) ) $this->codeDir = null; - if( !is_dir( $this->cacheDir ) ) + if( $this->cacheDir && !is_dir( $this->cacheDir ) ) mkdir( $this->cacheDir ); # Read the farms configuration -- To view, visit https://gerrit.wikimedia.org/r/299423 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I898d79f049299fe446f46ec9c9c6d9af9595eff1 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] Added the farm in the cache path ; computed performance with... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299418 Change subject: Added the farm in the cache path ; computed performance with a strict protocol: doc added ; removed cache parameter from publicised parameters .. Added the farm in the cache path ; computed performance with a strict protocol: doc added ; removed cache parameter from publicised parameters Previously there was a collision in cache if two farms used a same file name: fixed. The cache parameter is no more publicised in default configuration files. The reasoning is: * the user doesn’t have to know how to configure the cache directory param, that is another thing to explain in installation, and a default setting is fine, either developer-fixed, either in the main config file * the cache directory must be known before the main config file is loaded, to cache this file * it is convenient to have a possibility to disable cache, for developers * it is convenient to have a possibility to change the cache directory (shared hosts or Windows) * no cache is not an option So removing publicity of this core config param is probably the better option: by default there is a cache in a known location, and if absolutely needed, the location can be changed or the cache disabled. --- M docs/config/LocalSettings.php M docs/config/MediaWikiFarmDirectories.php M docs/config/farms.json M docs/config/farms.php M docs/config/farms.yml M docs/configuration.rst M docs/farms-schema.json M docs/performance.rst M src/MediaWikiFarm.php 9 files changed, 128 insertions(+), 75 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/18/299418/1 diff --git a/docs/config/LocalSettings.php b/docs/config/LocalSettings.php index e0c6be1..58b424c 100644 --- a/docs/config/LocalSettings.php +++ b/docs/config/LocalSettings.php @@ -10,11 +10,6 @@ // There must be a file 'farms.yml' or 'farms.php' or 'farms.json' inside. $wgMediaWikiFarmConfigDir = '/etc/mediawiki'; -// Cache directory. -// This can speed up the time spend by this extension from 9ms to 2ms. Set to -// null if you want to disable the cache. -$wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; - # Include the code. require "$IP/extensions/MediaWikiFarm/MediaWikiFarm.php"; diff --git a/docs/config/MediaWikiFarmDirectories.php b/docs/config/MediaWikiFarmDirectories.php index c17f08b..00db886 100644 --- a/docs/config/MediaWikiFarmDirectories.php +++ b/docs/config/MediaWikiFarmDirectories.php @@ -34,15 +34,3 @@ */ $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) ); - -/** - * Cache directory. - * - * Type: string|null. - * - * It is recommended to set this variable to a readable directory to speed up the time spent - * by this extension from 9ms to 2ms. If you want to disable the cache, you can set this - * variable to null. - */ -$wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; - diff --git a/docs/config/farms.json b/docs/config/farms.json index 9e3ad0a..fdd911b 100644 --- a/docs/config/farms.json +++ b/docs/config/farms.json @@ -1,5 +1,6 @@ { - "mywiki\\.example\\.org": { + "mywiki": { + "server": "mywiki\\.example\\.org", "suffix": "wiki", "wikiID": "mywiki", "config": [ diff --git a/docs/config/farms.php b/docs/config/farms.php index 97716d4..aa4140b 100644 --- a/docs/config/farms.php +++ b/docs/config/farms.php @@ -3,8 +3,9 @@ return array( # Placeholder configuration for a first installation as detailled in the documentation - 'mywiki\.example\.org' => array( + 'mywiki' => array( + 'server' => 'mywiki\.example\.org', 'suffix' => 'wiki', 'wikiID' => 'mywiki', 'config' => array( @@ -16,8 +17,12 @@ ); /* +return array( + # Configuration similar to the Wikimedia farm - '(?[a-z-]+)\.(?[a-z]+)\.org' => array( + 'wikimedia' => array( + + 'server' => '(?[a-z-]+)\.(?[a-z]+)\.org', 'variables' => array( @@ -32,10 +37,14 @@ 'versions' => 'wikiversions.json', 'data' => '/srv/data/org/$family/$lang', 'config' => array( - array( 'file' => 'org/InitialiseSettings.php', + array( 'file' => 'org/DefaultSettings.yml', 'key' => '*', ), - array( 'file' => 'org/PrivateSettings.php', + array( 'file' => 'org/Settings-$family.yml', + 'key' => '*$family', + 'default' => '$family', + ), + array( 'file' => 'org/PrivateSettings.yml', 'key' => '*',
[MediaWiki-commits] [Gerrit] Added a variable $data which can be used in config parameter... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299422 Change subject: Added a variable $data which can be used in config parameters for data directory .. Added a variable $data which can be used in config parameters for data directory /cache, /images, etc should be defined as subdirectories of this data directory --- M docs/performance.rst M src/MediaWikiFarm.php 2 files changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/22/299422/1 diff --git a/docs/performance.rst b/docs/performance.rst index cca3653..f0860a8 100644 --- a/docs/performance.rst +++ b/docs/performance.rst @@ -54,6 +54,7 @@ mean = 0.3264median = 0.2786std = 0.1485min = 0.1972 max = 0.8500range = 0.6528values = 50 + Performance architecture diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index db5041b..f028358 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -606,7 +606,7 @@ # 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 - $globals['general'] = $wgConf->getAll( $myWiki, $mySuffix ); + $globals['general'] = $wgConf->getAll( $myWiki, $mySuffix, array( 'data' => $this->params['data'] ) ); # 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 -- To view, visit https://gerrit.wikimedia.org/r/299422 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib08bd5783607ada0fda7e65551af360bc0cd7b0b 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] Register two mechanisms to avoid creating a LocalSettings.php - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299427 Change subject: Register two mechanisms to avoid creating a LocalSettings.php .. Register two mechanisms to avoid creating a LocalSettings.php 1. defined MW_CONFIG_FILE to tell MediaWiki to load the file MediaWikiFarm/src/main.php instead of LocalSettings.php. This mechanism exists since MediaWiki 1.17. 2. defined MW_CONFIG_CALLBACK to tell MediaWiki to call a callback function to load the configuration instead of loading LocalSettings.php. This mechanism is currently experimental and is not active because of limitations. This mechanism exists since MediaWiki 1.15. --- M src/MediaWikiFarm.php 1 file changed, 37 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/27/299427/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 3b1808e..3aefcbc 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -79,6 +79,12 @@ if( getcwd() != $wgMediaWikiFarm->params['code'] ) chdir( $wgMediaWikiFarm->params['code'] ); + # Define config callback to avoid creating a stub LocalSettings.php (experimental) + #define( 'MW_CONFIG_CALLBACK', 'MediaWikiFarm::loadConfig' ); + + # Define config file to avoid creating a stub LocalSettings.php + define( 'MW_CONFIG_FILE', $wgMediaWikiFarm->getConfigFile() ); + return $entryPoint; } @@ -249,6 +255,36 @@ return $this->farmDir . '/src/main.php'; } + /** +* Load the whole configuration in the case MW_CONFIG_CALLBACK is registered (experimental). +* +* This is about the same thing as the file src/main.php, but given it is not possible +* to "execute require_once in a global scope", the extensions/skins loaded with +* require_once are not called (existing global variables could be introduced with +* extract( $GLOBALS, EXTR_REFS ) but newly-created variables can not be detected and +* exported to global scope). +* +* NB: this loading mechanism (constant MW_CONFIG_CALLBACK) exists since MediaWiki 1.15. +* +* @return void +*/ + static function loadConfig() { + + # Load general MediaWiki configuration + MediaWikiFarm::getInstance()->loadMediaWikiConfig(); + + # Load skins with the wfLoadSkin mechanism + MediaWikiFarm::getInstance()->loadSkinsConfig(); + + # Load extensions with the wfLoadExtension mechanism + MediaWikiFarm::getInstance()->loadExtensionsConfig(); + + foreach( MediaWikiFarm::getInstance()->params['globals']['execFiles'] as $execFile ) { + + @include $execFile; + } + } + /* @@ -316,7 +352,7 @@ * * @param array $farms All farm configurations. * @param string $host Requested host. -* return bool One of the farm has been selected. +* @return bool One of the farm has been selected. */ private function selectFarm( $farms, $host ) { -- To view, visit https://gerrit.wikimedia.org/r/299427 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iae056a0bbc89f211532899bb82c90403edc45d28 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] Added wgExtensionCredits for backward compatibility - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299429 Change subject: Added wgExtensionCredits for backward compatibility .. Added wgExtensionCredits for backward compatibility --- M extension.json M src/MediaWikiFarm.php 2 files changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/29/299429/1 diff --git a/extension.json b/extension.json index d83af68..d3d1eaa 100644 --- a/extension.json +++ b/extension.json @@ -1,11 +1,12 @@ { "name": "MediaWikiFarm", - "version": "0.1.0-dev", + "version": "0.1.0", "author": [ "Seb35" ], "descriptionmsg": "mediawikifarm-desc", "license-name": "GPL-3.0+", + "url": "https://www.mediawiki.org/wiki/Extension:MediaWikiFarm";, "type": "other", "requires": { "MediaWiki": ">= 1.1.0" diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 3aefcbc..3ed0bfb 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -220,6 +220,18 @@ wfLoadExtension( 'MediaWikiFarm', $this->codeDir ? $this->farmDir . '/extension.json' : null ); unset( $this->params['globals']['extensions']['MediaWikiFarm']['_loading'] ); } + else { + $GLOBALS['wgExtensionCredits']['other'][] = array( + 'path' => dirname( dirname( __FILE__ ) ) . '/MediaWikiFarm.php', + 'name' => 'MediaWikiFarm', + 'version' => '0.1.0', + 'author' => 'Seb35', + 'url' => 'https://www.mediawiki.org/wiki/Extension:MediaWikiFarm', + 'descriptionmsg' => 'mediawikifarm-desc', + 'license-name' => 'GPL-3.0+' + ); + + } // Load extensions with the wfLoadExtension mechanism foreach( $this->params['globals']['extensions'] as $extension => $value ) { -- To view, visit https://gerrit.wikimedia.org/r/299429 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1e723ec1b5f88d5dbfcc7c22dc14e9e866cbd9d0 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] Added performance with PHP7+OPcache: 0.5ms (/total=45ms) vs ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299420 Change subject: Added performance with PHP7+OPcache: 0.5ms (/total=45ms) vs 3ms (/total=350ms) ; better indent if JSON .. Added performance with PHP7+OPcache: 0.5ms (/total=45ms) vs 3ms (/total=350ms) ; better indent if JSON --- M docs/farms-schema.json M docs/performance.rst 2 files changed, 32 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/20/299420/1 diff --git a/docs/farms-schema.json b/docs/farms-schema.json index c8e8c4e..b3d0689 100644 --- a/docs/farms-schema.json +++ b/docs/farms-schema.json @@ -10,12 +10,16 @@ "type": "object", "description": "Configuration of a farm.", "additionalProperties": false, - "required": ["server", "suffix", "wikiID"], + "required": [ + "server", + "suffix", + "wikiID" + ], "properties": { "server": { "type": "string", "description": "Regular expression of the server names.", - "pattern": "^[a-zA-Z0-9\\[\\]\\(\\)<>.*?+_-]+$" + "pattern": "^[a-zA-Z0-9\\[\\]\\(\\)<>.*?+_|-]+$" }, "variables": { "type": "array", @@ -25,9 +29,11 @@ "type": "object", "description": "An host variable.", "additionalProperties": false, - "required": ["variable"], + "required": [ + "variable" + ], "properties": { - "variable": { + "variable": { "type": "string", "description": "Name of the host variable." }, @@ -64,7 +70,9 @@ "type": "object", "description": "A configuration file.", "additionalProperties": false, - "required": ["file"], + "required": [ + "file" + ], "properties": { "file": { "type": "string", @@ -83,7 +91,9 @@ "exec": { "type": "boolean", "description": "This file must be directly.", - "enum": [true] + "enum": [ + true + ] } } } @@ -94,12 +10
[MediaWiki-commits] [Gerrit] Fix some bugs with old MediaWiki versions - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299424 Change subject: Fix some bugs with old MediaWiki versions .. Fix some bugs with old MediaWiki versions --- M src/MediaWikiFarm.php M src/main.php 2 files changed, 10 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/24/299424/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 43ffea5..4dfbca3 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -574,6 +574,11 @@ if( $this->unusable ) return false; + # In MediaWiki 1.16, $wgConf is not created by default + if( is_null( $wgConf ) ) { + $wgConf = new SiteConfiguration(); + } + $myWiki = $this->params['wikiID']; $mySuffix = $this->params['suffix']; if( $this->params['version'] ) $cacheFile = $this->replaceVariables( 'config-$VERSION-$SUFFIX-$WIKIID.php' ); diff --git a/src/main.php b/src/main.php index b34bbf8..3524294 100644 --- a/src/main.php +++ b/src/main.php @@ -15,6 +15,11 @@ * MediaWiki configuration */ +# Old MediaWiki installations doesn’t load DefaultSettings.php before LocalSettings.php +if( !isset( $wgVersion ) ) { + require_once "$IP/includes/DefaultSettings.php"; +} + # Load general MediaWiki configuration MediaWikiFarm::getInstance()->loadMediaWikiConfig(); -- To view, visit https://gerrit.wikimedia.org/r/299424 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie21e5efae43c0b1f856f2c78eabe3fb990973d4c 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] Added user documentation (complete 3.5/5); changed default c... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299416 Change subject: Added user documentation (complete 3.5/5); changed default config according to doc .. Added user documentation (complete 3.5/5); changed default config according to doc --- A docs/concepts.rst M docs/config/farms.json M docs/config/farms.php M docs/config/farms.yml A docs/configuration.rst A docs/index.rst A docs/installation.rst M docs/performance.txt A docs/scripts.rst A docs/user.rst M src/MediaWikiFarm.php 11 files changed, 428 insertions(+), 118 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/16/299416/1 diff --git a/docs/concepts.rst b/docs/concepts.rst new file mode 100644 index 000..5d609e3 --- /dev/null +++ b/docs/concepts.rst @@ -0,0 +1,69 @@ + +Concepts + + +It is explained here the vocabulary and the big picture of how MediaWiki and MediaWikiFarm manages multiple wikis. + +History +=== + +MediaWiki has a long history of managing multiple wikis, since Wikimedia quickly had to manage many projects (Wikipedia, Wikisource, etc.) and many wikis by project (many languages for each project). MediaWiki (called “phase3” at the time) was born during 2002-2003; the SiteConfiguration class, which manages multiple configurations, was created mid-2004 (according to Git history). The definitions below are a legacy of this class SiteConfiguration, which is still used internally to compile the configurations. + +Definitions +=== + +The basic concept is the **farm**, which is a set of wikis, whose the configuration is collectively managed by an operator. For example, Wikimedia wikis are collectively a farm of wikis, Wikia wikis are a farm of wikis, the Wikimedia Beta Cluster is another farm (whose the aim is to create a pre-production environment for the main Wikimedia farm). + +The wikis are represented by a **wikiID**, an arbitrary name to identify individual wikis. In the original spirit of the farm concept, the wikiID is the database name of the wiki, but the wikiID can be more generally though as "just identifiers", linked or not to the database name. For instance, Wikimedia wikis have wikiIDs strictly linked to the database name of the wiki: "enwiki" for English-speaking Wikipedia, "huwiki" for Hungarian-speaking Wikipedia, "nvwiki" for Navajo-speaking Wikipedia, "frwiktionary" for French-speaking Wiktionary, etc. + +The wikis can be naturally sorted according to their **suffix**, their canonical family. As the name suggests it, the suffix of wikiIDs must match a suffix. The exact meaning can be defined farm by farm; and if there is no such natural classification, an arbitrary suffix can be defined (but a non-empty suffix must be defined). For Wikimedia wikis the natural families are the projects: "wiktionary" for the Wiktionaries, "wikivoyage" for the Wikivoyage sites, "wiki" for Wikipedia (for historical reasons). In a farm where you have multiple distincts groups of people, for instance clients or communities, you can define a suffix as a group of people, and each group can own some wikis. + +Other classifications can be defined [todo: but currently not implemented in MediaWikiFarm]: wikis can be grouped by **tags**. Here the list of wikis must be manually defined. For instance Wikimedia has tags such: wikis where the VisualEditor is proposed as a Beta Feature, read-only wikis, private wikis, small wikis, or the database cluster of the wikis (there are currently 7 clusters), or the deployment group (there are currently 3 groups: test wikis, all wikis except Wikipedia, and Wikipedia). + +Configuration += + +MediaWiki has many configuration parameters (currently about 730 parameters). Although each parameter has a default value, each wiki must change at least 5 to 10 parameters, and often between 20 and 50 parameters are changed. In a farm, this can become difficult to manage. Hence, the above classification can help to set parameters to groups of wikis. + +For instance, take the parameter $wgDefaultSkin, the skin used for anonymous visitors. +1. by default, MediaWiki defines "vector" as default skin; +2. you can prefer a default to "modern" in your farm; +3. different groups of people, who have each their suffixes, prefer respectively "nimbus" and "cologneblue"; +4. for the anniversary event of the farm, each group of people creates a dedicated wiki for the event, and a common graphic identity is decided with the "metrolook" skin; +5. in order to get more flexibility for the portal of the anniversary event, the skin "chameleon" (Bootstrap) is used with a custom stylesheet. + +Such a complicated scenario can be easily implemented if the classifications have been correctly defined: +2. the default value for the farm is "vector"; +3. the two suffixes get the respective values "nimbus" and "col
[MediaWiki-commits] [Gerrit] Fix bug where version is lost after the initial cache setup - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299431 Change subject: Fix bug where version is lost after the initial cache setup .. Fix bug where version is lost after the initial cache setup --- M src/MediaWikiFarm.php 1 file changed, 4 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/31/299431/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 7563cc0..8117c69 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -539,9 +539,10 @@ $deployments = $this->readFile( $this->params['deployments'], $this->configDir ); if( $deployments === false ) $deployments = array(); } - if( array_key_exists( $this->params['wikiID'], $deployments ) ) - $this->params['code'] = $this->codeDir . '/' . $deployments[$this->params['wikiID']]; - + if( array_key_exists( $this->params['wikiID'], $deployments ) ) { + $version = $deployments[$this->params['wikiID']]; + $this->params['code'] = $this->codeDir . '/' . $version; + } # In the case multiversion is configured and version is already known elseif( is_string( $this->codeDir ) && is_string( $version ) ) { -- To view, visit https://gerrit.wikimedia.org/r/299431 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8de85eb5c16123b5d73d34f1dcbf57773d520ab0 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] Update Composer dependencies - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299428 Change subject: Update Composer dependencies .. Update Composer dependencies --- M composer.lock 1 file changed, 634 insertions(+), 380 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/28/299428/1 diff --git a/composer.lock b/composer.lock index dbc47a8..db87783 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";, "This file is @generated automatically" ], -"hash": "c4133552c61829812823b39328b0df7f", +"hash": "3bb7400bdb0f5c6ddb1017c708c95e39", "content-hash": "1704923f8317734c9f932ccf6afc", "packages": [ { "name": "symfony/yaml", -"version": "v3.0.3", +"version": "v3.1.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git";, -"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c" +"reference": "eca51b7b65eb9be6af88ad7cc91685f1556f5c9a" }, "dist": { "type": "zip", -"url": "https://api.github.com/repos/symfony/yaml/zipball/b5ba64cd67ecd6887f63868fa781ca094bd1377c";, -"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c", +"url": "https://api.github.com/repos/symfony/yaml/zipball/eca51b7b65eb9be6af88ad7cc91685f1556f5c9a";, +"reference": "eca51b7b65eb9be6af88ad7cc91685f1556f5c9a", "shasum": "" }, "require": { @@ -27,7 +27,7 @@ "type": "library", "extra": { "branch-alias": { -"dev-master": "3.0-dev" +"dev-master": "3.1-dev" } }, "autoload": { @@ -54,7 +54,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com";, -"time": "2016-02-23 15:16:06" +"time": "2016-05-26 21:46:24" } ], "packages-dev": [ @@ -326,6 +326,47 @@ "time": "2014-09-09 13:34:57" }, { +"name": "dompdf/dompdf", +"version": "v0.6.2", +"source": { +"type": "git", +"url": "https://github.com/dompdf/dompdf.git";, +"reference": "cc06008f75262510ee135b8cbb14e333a309f651" +}, +"dist": { +"type": "zip", +"url": "https://api.github.com/repos/dompdf/dompdf/zipball/cc06008f75262510ee135b8cbb14e333a309f651";, +"reference": "cc06008f75262510ee135b8cbb14e333a309f651", +"shasum": "" +}, +"require": { +"phenx/php-font-lib": "0.2.*" +}, +"type": "library", +"autoload": { +"classmap": [ +"include/" +] +}, +"notification-url": "https://packagist.org/downloads/";, +"license": [ +"LGPL" +], +"authors": [ +{ +"name": "Fabien Ménager", +"email": "fabien.mena...@gmail.com" +}, +{ +"name": "Brian Sweeney", +"email": "eclecticg...@gmail.com" +} +], +"description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter", +"homepage": "https://github.com/dompdf/dompdf";, +"time": "2015-12-07 04:07:13" +}, +{ "name": "erusev/parsedown", "version": "1.6.0", "source": { @@ -363,123 +404,6 @@ "parser" ], "time": "2015-10-04 16:44:32" -}, -{ -"name": "herrera-io/json", -"version": "1.0.3", -"source": { -"type": "git", -"url": "https://github.com/kherge-abandoned/php-json.git";, -"reference": "60c696c9370a1e5136816ca557c17f82a6fa83f1" -}, -"dist": { -"type": "zip", -"url": "https://api.github.com/repos/kherge-abandoned/php-json/zipball/60c696c9370a1e5136816ca557c17f82a6fa83f1";, -"reference": "60c696c9370a1e5136816ca557c17f82a6fa83f1", -"shasum": "" -}, -"require": { -"ext-json": "*", -"justinrainbow/json-schema": ">=1.0,<2.0-dev", -"php": ">=5.3.3", -"seld/jsonlint": ">=1.0,<2.0-dev" -}, -"require-dev": { -
[MediaWiki-commits] [Gerrit] Added a callback to give the suffix - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299425 Change subject: Added a callback to give the suffix .. Added a callback to give the suffix Mainly used to partially improve the situation when CentralAuth is used. --- M src/MediaWikiFarm.php 1 file changed, 26 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/25/299425/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 4dfbca3..51dc4ef 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -606,7 +606,7 @@ # Populate wgConf if( !$this->populatewgConf() ) - return false; + return false; # Get specific configuration for this wiki # Do not use SiteConfiguration::extractAllGlobals or the configuration caching would become @@ -628,6 +628,8 @@ # Save this configuration in a serialised file $this->cacheFile( $globals, $cacheFile ); } + + $wgConf->siteParamsCallback = array( $this, 'SiteConfigurationSiteParamsCallback' ); } /** @@ -703,6 +705,29 @@ } /** +* Callback to use in SiteConfiguration. +* +* It is not possible to retrieve the language because SiteConfiguration will loop. +* It is not ideal since other parameters from other suffixes are not known. +* +* @param SiteConfiguration $wgConf SiteConfiguration object. +* @param string $dbName Database name. +* @return array +*/ + function SiteConfigurationSiteParamsCallback( $wgConf, $wikiID ) { + + if( substr( $wikiID, strlen( $wikiID ) - strlen( $this->params['suffix'] ) ) != $this->params['suffix'] ) + return null; + + return array( + 'suffix' => $this->params['suffix'], + 'lang' => '', + 'tags' => [], + 'params' => [], + ); + } + + /** * Extract from the general configuration skin and extension configuration * * @return void -- To view, visit https://gerrit.wikimedia.org/r/299425 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8839a486d15b4bf26b520a65f328979b8760239a 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] PHP is now the default cache format - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299421 Change subject: PHP is now the default cache format .. PHP is now the default cache format Compared to serialised format, PHP files can be opcached: gain a factor 3. Mean time to load LocalSettings.php was previously 0.75ms with OPcache, it is now 0.33ms. Mean time to load LocalSettings.php without MediaWikiFarm is 0.19ms. Hence MediaWikiFarm takes 0.14ms (with OPcache). --- M docs/performance.rst M src/MediaWikiFarm.php 2 files changed, 21 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/21/299421/1 diff --git a/docs/performance.rst b/docs/performance.rst index ab8d077..cca3653 100644 --- a/docs/performance.rst +++ b/docs/performance.rst @@ -50,6 +50,10 @@ mean = 0.7494median = 0.6160std = 0.2886min = 0.4861 max = 1.6530range = 1.1668values = 50 +* LocalSettings.php with only MediaWikiFarm extension with cache, with PHP extension OPcache and cache in PHP format: + +mean = 0.3264median = 0.2786std = 0.1485min = 0.1972 max = 0.8500range = 0.6528values = 50 + Performance architecture diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index afaf74a..db5041b 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -576,8 +576,8 @@ $myWiki = $this->params['wikiID']; $mySuffix = $this->params['suffix']; - if( $this->params['version'] ) $cacheFile = $this->replaceVariables( 'config-$VERSION-$SUFFIX-$WIKIID.ser' ); - else $cacheFile = $this->replaceVariables( 'config-$SUFFIX-$WIKIID.ser' ); + if( $this->params['version'] ) $cacheFile = $this->replaceVariables( 'config-$VERSION-$SUFFIX-$WIKIID.php' ); + else $cacheFile = $this->replaceVariables( 'config-$SUFFIX-$WIKIID.php' ); $this->params['globals'] = false; # Check modification time of original config files @@ -828,8 +828,13 @@ if( !is_file( $prefixedFile ) ) return false; + # Format PHP + if( $format == '.php' ) + + $array = @include $prefixedFile; + # Format 'serialisation' - if( $format == '.ser' ) { + elseif( $format == '.ser' ) { $content = file_get_contents( $prefixedFile ); @@ -839,22 +844,17 @@ $array = @unserialize( $content ); } - # Format PHP - elseif( $format == '.php' ) - - $array = @include $prefixedFile; - # Cached version - elseif( is_string( $this->cacheDir ) && is_file( $this->cacheDir . '/' . $filename . '.ser' ) && @filemtime( $this->cacheDir . '/' . $filename . '.ser' ) >= filemtime( $prefixedFile ) ) + elseif( is_string( $this->cacheDir ) && is_file( $this->cacheDir . '/' . $filename . '.php' ) && @filemtime( $this->cacheDir . '/' . $filename . '.php' ) >= filemtime( $prefixedFile ) ) - return $this->readFile( $filename . '.ser', $this->cacheDir ); + return $this->readFile( $filename . '.php', $this->cacheDir ); # Format YAML elseif( $format == '.yml' || $format == '.yaml' ) { # Load Composer libraries # There is no warning if not present because to properly handle the error by returning false - # This is only included here to avoid delays (~3ms) during the loading using cached files or other formats + # This is only included here to avoid delays (~3ms without OPcache) during the loading using cached files or other formats if( is_file( dirname( __FILE__ ) . '/../vendor/autoload.php' ) ) include_once dirname( __FILE__ ) . '/../vendor/autoload.php'; @@ -897,7 +897,7 @@ if( is_array( $array ) ) { if( $format != '.php' && $format != '.ser' ) - $this->cacheFile( $array, $filename.'.ser' ); + $this->cacheFile( $array, $filename.'.php' ); return $array; } @@ -925,14 +925,14 @@ mkdir( dirname( $prefixedFile ) ); $tmpFile = $prefixedFile . '.tmp';
[MediaWiki-commits] [Gerrit] Doc about performance ; minor changes - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299419 Change subject: Doc about performance ; minor changes .. Doc about performance ; minor changes --- M docs/index.rst M docs/performance.rst M scripts/mwscript.php M scripts/validate-schema.php M src/MediaWikiFarm.php 5 files changed, 39 insertions(+), 29 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/19/299419/1 diff --git a/docs/index.rst b/docs/index.rst index 2652cde..d21aabf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,5 +15,5 @@ internals -sysadmin: mwscript, conversion de localsettings +sysadmin: conversion de localsettings diff --git a/docs/performance.rst b/docs/performance.rst index fa8e91d..6c12aec 100644 --- a/docs/performance.rst +++ b/docs/performance.rst @@ -40,3 +40,18 @@ mean = 14.7820median = 13.8605std = 2.0367min = 13.0639 max = 20.6609range = 7.5970values = 50 + +Performance architecture + + +Since the early versions of MediaWikiFarm, only the configuration of each wiki was cached (this was inspired from the Wikimedia’s CommonSettings.php). The only invalidation of this cache is when origin files are changed. + +This was a good point to improve performance, but two bottlenecks were then identified: +* the reading and parsing of the YAML files (main config file, existence of variables, config files) was quite slow (7-8 ms); +* YAML files needed an autoloading from Composer, and this was quite slow (2-3 ms). + +To improve these two points, a general cache directory is defined, and if this one exists, the reading function systematically write a cached file in a format natively understood by PHP -- serialised format. The next trivial step was to call Composer autoloader only when a YAML file is about to be read. After this operation, the mean time spent in LocalSettings.php decreased from about 13-15 ms to 4-5 ms. Hence, given the time spent by a classical LocalSettings.php is 3 ms, MediaWikiFarm costs 2 ms. + +It was tried the CDB format as an alternative to serialised format, but I was not convinced by the performance when I tried to load the entire file (wiki configuration). Three limitations of the CDB format are: it is a PHP extension (a Composer fallback library was written by Wikimedia), it is a dictionary (and cannot be a list), and values are strings (a serialisation of the value must be applied beforehand). Possibly the gain is more important when only some informations are read, as it could be the case for existence files. Another test in this direction could be tried. + +Another development direction is to create a unique cache file containing all wikiIDs of a given farm and associated versions and invalidate this one each time an origin file is changed. Possibly the CDB format could give good performance in this case. In this scenario, with the CDB format, the 'existence' part of MediaWikiFarm would be time-constant with a hopefully small time. diff --git a/scripts/mwscript.php b/scripts/mwscript.php index 41f5d48..7b392ae 100644 --- a/scripts/mwscript.php +++ b/scripts/mwscript.php @@ -156,10 +156,6 @@ PARAMS; # Clean this script -if( !is_file( $mwfScript ) ) { - echo "Script not found.\n"; - exit( 1 ); -} $argv[0] = $mwfScript; unset( $mwfHost ); unset( $mwfScript ); @@ -168,10 +164,9 @@ # Execute the script -// Possibly it could be better to do a true system call with a child process (PHP function "system"), BUT -// hostname must be passed as an environment variable and more importantly, in the current implementation of -// MediaWikiFarm, the called version of the extension will be $version/extensions/MediaWikiFarm, and this -// version is probably not configured as a standalone extension (directories set in LocalSettings.php); so -// it will not work in current implementation. +if( !is_file( $argv[0] ) ) { + echo "Script not found.\n"; + exit( 1 ); +} require $argv[0]; diff --git a/scripts/validate-schema.php b/scripts/validate-schema.php index f529a79..5152af0 100644 --- a/scripts/validate-schema.php +++ b/scripts/validate-schema.php @@ -40,7 +40,7 @@ // If you use $ref or if you are unsure, resolve those references here // This modifies the $schema object $refResolver = new JsonSchema\RefResolver( $retriever ); - $refResolver->resolve( $schema, 'file://' . __DIR__ ); + $refResolver->resolve( $schema, 'file://' . dirname( __FILE__ ) ); // Validate $validator = new JsonSchema\Validator(); diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 99382df..afaf74a 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -303,8 +303,8 @@ # Read the farms configuration if( $farms = $this->readF
[MediaWiki-commits] [Gerrit] The CLI monoversion didn’t work anymore, fixed - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299414 Change subject: The CLI monoversion didn’t work anymore, fixed .. The CLI monoversion didn’t work anymore, fixed --- M docs/config/LocalSettings.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/14/299414/1 diff --git a/docs/config/LocalSettings.php b/docs/config/LocalSettings.php index 541613e..e0c6be1 100644 --- a/docs/config/LocalSettings.php +++ b/docs/config/LocalSettings.php @@ -4,7 +4,7 @@ */ # Protect against web entry -if( !defined( 'MEDIAWIKI' ) ) exit; +if( !defined( 'MEDIAWIKI' ) && PHP_SAPI != 'cli' ) exit; // Configuration directory. // There must be a file 'farms.yml' or 'farms.php' or 'farms.json' inside. @@ -16,7 +16,7 @@ $wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; # Include the code. -require_once "$IP/extensions/MediaWikiFarm/MediaWikiFarm.php"; +require "$IP/extensions/MediaWikiFarm/MediaWikiFarm.php"; # Do not add other configuration here, but instead in the config files # read by MediaWikiFarm -- even for global settings. -- To view, visit https://gerrit.wikimedia.org/r/299414 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9155c9855feb8e2739899c3484582ee95d03be33 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] Renamed an old doc to .rst - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299417 Change subject: Renamed an old doc to .rst .. Renamed an old doc to .rst --- R docs/performance.rst 1 file changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/17/299417/1 diff --git a/docs/performance.txt b/docs/performance.rst similarity index 100% rename from docs/performance.txt rename to docs/performance.rst -- To view, visit https://gerrit.wikimedia.org/r/299417 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4720c1eda4d2bf65c0477352579d5c895ac11876 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] Documentation - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299413 Change subject: Documentation .. Documentation --- M MediaWikiFarm.php M docs/config/LocalSettings.multiversion.php M src/MediaWikiFarm.php 3 files changed, 13 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/13/299413/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index 7e0c71f..6f59fef 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -23,6 +23,6 @@ MediaWikiFarm::load(); # Load MediaWiki configuration - require_once MediaWikiFarm::getInstance()->loadConfigDirectory(); + require_once MediaWikiFarm::getInstance()->getConfigFile(); } diff --git a/docs/config/LocalSettings.multiversion.php b/docs/config/LocalSettings.multiversion.php index 40e6cb0..a3676a5 100644 --- a/docs/config/LocalSettings.multiversion.php +++ b/docs/config/LocalSettings.multiversion.php @@ -7,7 +7,7 @@ if( !defined( 'MEDIAWIKI' ) ) exit; # Include the code. -require_once MediaWikiFarm::getInstance()->loadConfigDirectory(); +require_once MediaWikiFarm::getInstance()->getConfigFile(); # Do not add other configuration here, but instead in the config files # read by MediaWikiFarm -- even for global settings. diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 6ccb7b6..f3deeeb 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -237,7 +237,17 @@ } } - function loadConfigDirectory() { + /** +* Return the file where is loaded the configuration. +* +* This function is important to avoid the two parts of the extension (checking of +* existence and loading of configuration) are located in the same directory in the +* case mono- and multi-version installations are mixed. Without it, this class +* could be defined by two different files, and PHP doesn’t like it. +* +* @return string File where is loaded the configuration. +*/ + function getConfigFile() { return $this->farmDir . '/src/main.php'; } -- To view, visit https://gerrit.wikimedia.org/r/299413 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ide5bb6197d2c50868ca71cfc45d7ff4db3a74313 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] Version 0.1.0-dev - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299415 Change subject: Version 0.1.0-dev .. Version 0.1.0-dev --- M extension.json 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/15/299415/1 diff --git a/extension.json b/extension.json index d47db02..d83af68 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "MediaWikiFarm", - "version": "0.0.0-dev", + "version": "0.1.0-dev", "author": [ "Seb35" ], @@ -12,7 +12,8 @@ }, "config": { "MediaWikiFarmConfigDir": "/etc/mediawiki", - "MediaWikiFarmCodeDir": null + "MediaWikiFarmCodeDir": null, + "MediaWikiFarmCacheDir": "/tmp/mw-cache" }, "MessagesDirs": { "MediaWikiFarm": [ -- To view, visit https://gerrit.wikimedia.org/r/299415 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibb677fef000ea10f9e009cd56fd597c3a9a468dc 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] Correct path for extension.json in case of multiversion - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299412 Change subject: Correct path for extension.json in case of multiversion .. Correct path for extension.json in case of multiversion --- M MediaWikiFarm.php M src/MediaWikiFarm.php 2 files changed, 8 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/12/299412/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index aa2b861..7e0c71f 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -25,3 +25,4 @@ # Load MediaWiki configuration require_once MediaWikiFarm::getInstance()->loadConfigDirectory(); } + diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index ee4a288..6ccb7b6 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -212,6 +212,12 @@ if( $this->unusable ) return; + # Register this extension MediaWikiFarm to appear in Special:Version + if( function_exists( 'wfLoadExtension' ) ) { + wfLoadExtension( 'MediaWikiFarm', $this->codeDir ? $this->farmDir . '/extension.json' : null ); + unset( $this->params['globals']['extensions']['MediaWikiFarm']['_loading'] ); + } + // Load extensions with the wfLoadExtension mechanism foreach( $this->params['globals']['extensions'] as $extension => $value ) { @@ -590,9 +596,6 @@ # Extract from the general configuration skin and extension configuration $this->extractSkinsAndExtensions(); - # Register this extension MediaWikiFarm to appear in Special:Version - $globals['extensions']['MediaWikiFarm'] = array( '_loading' => 'wfLoadExtension' ); - # Save this configuration in a serialised file $this->cacheFile( $globals, $cacheFile ); } @@ -756,7 +759,7 @@ return null; # An extension.json/skin.json file is in the directory -> assume it is the loading mechanism - if( is_file( $this->params['code'].'/'.$type.'s/'.$name.'/'.$type.'.json' ) ) + if( function_exists( 'wfLoad'.ucfirst($type) ) && is_file( $this->params['code'].'/'.$type.'s/'.$name.'/'.$type.'.json' ) ) return 'wfLoad'.ucfirst($type); # A MyExtension.php file is in the directory -> assume it is the loading mechanism -- To view, visit https://gerrit.wikimedia.org/r/299412 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia74a21caf51c0076fa5b84fcd559a99efe64996a 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] Bug when executing a script in monoversion installations - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299408 Change subject: Bug when executing a script in monoversion installations .. Bug when executing a script in monoversion installations Added some other checks in constants; it is not really beautiful as of now, but I plan to strictly xor mono- and multi-version installations, and it should simplify these constants, namely by removing 'child' installations in multiversion installations. --- M MediaWikiFarm.php M scripts/mwscript.php M src/MediaWikiFarm.php M src/main.php 4 files changed, 30 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/08/299408/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index 2127018..377fa69 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -10,7 +10,7 @@ */ # Protect against web entry -if( !defined( 'MEDIAWIKI' ) ) exit; +if( !defined( 'MEDIAWIKI' ) && PHP_SAPI != 'cli' ) exit; /* * Parameters @@ -49,5 +49,6 @@ *Code * == */ -require_once __DIR__ . '/src/main.php'; +if( defined( 'MEDIAWIKI' ) ) + require_once __DIR__ . '/src/main.php'; diff --git a/scripts/mwscript.php b/scripts/mwscript.php index 248c9cc..c97b876 100644 --- a/scripts/mwscript.php +++ b/scripts/mwscript.php @@ -10,14 +10,22 @@ # Protect against web entry if( PHP_SAPI != 'cli' ) exit; -/** Definition of a constant to protect dedicated entry points. */ -define( 'MEDIAWIKI_FARM', true ); - # Configuration of the MediaWiki Farm -$wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) ); -$wgMediaWikiFarmConfigDir = '/etc/mediawiki'; -$wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; -@include_once dirname( dirname( __FILE__ ) ) . '/config/MediaWikiFarmDirectories.php'; +if( is_file( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/includes/DefaultSettings.php' ) ) { + + $IP = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); + require "$IP/LocalSettings.php"; +} +else { + + /** Definition of a constant to protect dedicated entry points. */ + define( 'MEDIAWIKI_FARM', true ); + + $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) ); + $wgMediaWikiFarmConfigDir = '/etc/mediawiki'; + $wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; + require_once dirname( dirname( __FILE__ ) ) . '/config/MediaWikiFarmDirectories.php'; +} # Include library // @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound @@ -134,10 +142,11 @@ MediaWikiFarm::getEntryPoint( $mwfScript, $mwfHost ); # Display parameters +$mwfVersion = $wgMediaWikiFarm->params['version'] ? $wgMediaWikiFarm->params['version'] : 'current'; echo <params['suffix']}) -Version: {$wgMediaWikiFarm->params['version']}: {$wgMediaWikiFarm->params['code']} +Version: $mwfVersion: {$wgMediaWikiFarm->params['code']} Script: $mwfScript @@ -149,8 +158,10 @@ exit( 1 ); } $argv[0] = $mwfScript; -unset( $mwfScript ); unset( $mwfHost ); +unset( $mwfScript ); +unset( $mwfVersion ); +unset( $IP ); # Execute the script // Possibly it could be better to do a true system call with a child process (PHP function "system"), BUT diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 63b7dd3..f8cd5c7 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -8,7 +8,7 @@ */ # Protect against web entry -if( !defined( 'MEDIAWIKI' ) && !defined( 'MEDIAWIKI_FARM' ) ) exit; +if( !defined( 'MEDIAWIKI' ) && !defined( 'MEDIAWIKI_FARM' ) && PHP_SAPI != 'cli' ) exit; # Protect against double inclusion # This could happen even with require_once in the case of multiversion installation @@ -428,6 +428,7 @@ global $IP, $wgVersion; + # Replace variables in the file name containing all versions, if existing $this->setWikiProperty( 'versions' ); # In the case multiversion is configured and version is already known @@ -458,10 +459,10 @@ $this->params['code'] = $this->codeDir . '/' . $version; } - # In the case no multiversion is configured + # In the case this is a monoversion installation elseif( is_null( $this->codeDir ) ) { - $version = $wgVersion; + $version = ''; $this->params['code'] = $IP; } else { @@ -538,7 +539,8 @@ $myWiki = $this->params['wikiID']; $mySuffix = $this->params['suffix']; - $cacheFile = $this->replaceVariables( '$VERSION-$SUFFIX-$WIKIID.ser' ); + if( $this->params['version'] ) $cacheF
[MediaWiki-commits] [Gerrit] Removed the constant MEDIAWIKI_FARM and I checked all config... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299410 Change subject: Removed the constant MEDIAWIKI_FARM and I checked all configurations they works and they are not available on the Web as raw files .. Removed the constant MEDIAWIKI_FARM and I checked all configurations they works and they are not available on the Web as raw files The 6 considered configurations are: 1/ - on the Web (FPM SAPI), or - on command line (CLI SAPI); 2/ - in a multiversion installation, or - in a monoversion installation, or - in transition from mono to multiversion, i.e. entry points are on multiversion but LocalSettings are still monoversion (both in the same version of MediaWikiFarm). --- M MediaWikiFarm.php M docs/config/LocalSettings.multiversion.php M docs/config/LocalSettings.php M scripts/mwscript.php M src/MediaWikiFarm.php M src/api.php.txt M src/img_auth.php.txt M src/index.php.txt M src/load.php.txt M src/main.php M src/opensearch_desc.php.txt 11 files changed, 64 insertions(+), 86 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/10/299410/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index 377fa69..aa2b861 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -12,43 +12,16 @@ # Protect against web entry if( !defined( 'MEDIAWIKI' ) && PHP_SAPI != 'cli' ) exit; -/* - * Parameters - * == */ - -/** - * Configuration directory. - * - * Type: string (path). - * - * This parameter should be specified in your LocalSettings.php, before the require_once. - * The value must be a readable directory. Depending of your openness policy, you could - * publish all or parts of the configuration files, but probably you don’t want to publish - * private informations like database configuration, upgrade key, etc. - */ -#$wgMediaWikiFarmConfigDir = '/etc/mediawiki'; - - -/** - * Code directory. - * - * Type: string|null (path). - * - * If your farm can manage multiple MediaWiki versions, set this parameter to a directory - * where each subdirectory is a MediaWiki installation in a given version+flavour. Although - * it is probably easier to name the subdirectories with the MediaWiki version, the names - * are entirely independent from the real version inside the subdirectory. - */ -#$wgMediaWikiFarmCodeDir = null; - - - - - -/* - *Code - * == */ - -if( defined( 'MEDIAWIKI' ) ) - require_once __DIR__ . '/src/main.php'; - +# Load MediaWiki configuration +if( defined( 'MEDIAWIKI' ) ) { + + # Load class definition + if( !class_exists( 'MediaWikiFarm' ) ) + require_once dirname( __FILE__ ) . '/src/MediaWikiFarm.php'; + + # Load MediaWikiFarm + MediaWikiFarm::load(); + + # Load MediaWiki configuration + require_once MediaWikiFarm::getInstance()->loadConfigDirectory(); +} diff --git a/docs/config/LocalSettings.multiversion.php b/docs/config/LocalSettings.multiversion.php index 04fba54..40e6cb0 100644 --- a/docs/config/LocalSettings.multiversion.php +++ b/docs/config/LocalSettings.multiversion.php @@ -1,13 +1,13 @@ loadConfigDirectory(); # Do not add other configuration here, but instead in the config files # read by MediaWikiFarm -- even for global settings. diff --git a/docs/config/LocalSettings.php b/docs/config/LocalSettings.php index ff7f2d1..541613e 100644 --- a/docs/config/LocalSettings.php +++ b/docs/config/LocalSettings.php @@ -1,9 +1,11 @@ params['version'] ? $wgMediaWikiFarm->params['version'] : 'current'; +$mwfVersion = MediaWikiFarm::getInstance()->params['version'] ? MediaWikiFarm::getInstance()->params['version'] : 'current'; echo <params['suffix']}) @@ -160,6 +166,7 @@ unset( $mwfVersion ); unset( $IP ); + # Execute the script // Possibly it could be better to do a true system call with a child process (PHP function "system"), BUT // hostname must be passed as an environment variable and more importantly, in the current implementation of diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 042d591..6a2f345 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -7,13 +7,6 @@ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version ultérieure */ -# Protect against web entry -if( !defined( 'MEDIAWIKI' ) && !defined( 'MEDIAWIKI_FARM' ) && PHP_SAPI != 'cli' ) exit; - -# Protect against double inclusion -# This could happen even with require_once in the case of multiversion installation -if( defined( 'MEDIAWIKI_FARM' ) ) return; - /** * This class computes the configuration of a specific wiki from a set of configuration files. * The configuration is composed of the list of authorised wikis and different configuration @@ -28,11 +21,14 @@ /** @var MediaWikiFarm|null Singleton. */ private static $self = null
[MediaWiki-commits] [Gerrit] Suppress some PHPMD warnings - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299392 Change subject: Suppress some PHPMD warnings .. Suppress some PHPMD warnings --- M src/MediaWikiFarm.php 1 file changed, 14 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/92/299392/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 2236aaf..83e85f5 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -292,6 +292,7 @@ * Replacement of the variables in the host name. * * @return string|null|false If an existing version is found in files, returns a string; if no version is found, returns null; if the host is missing in existence files, returns false; if an existence file is missing or badly formatted, return false and turns this object into a unusable state. +* @SuppressWarnings(PHPMD.ElseExpression) */ private function replaceHostVariables() { @@ -376,6 +377,7 @@ * * @param string|null $version If a string, this is the version already got, just set it. * @return bool The version was set, and the wiki could exist. +* @SuppressWarnings(PHPMD.ElseExpression) */ private function setVersion( $version = null ) { @@ -486,6 +488,8 @@ * ) * * @return array Global parameter variables and loading mechanisms for skins and extensions. +* @SuppressWarnings(PHPMD.StaticAccess) +* @SuppressWarnings(PHPMD.ElseExpression) */ private function getMediaWikiConfig() { @@ -512,14 +516,13 @@ $this->params['globals'] = false; if( @filemtime( $cacheFile ) >= $oldness && is_string( $cacheFile ) ) { - if( preg_match( '/\.php$/', $cacheFile ) ) { + if( preg_match( '/\.php$/', $cacheFile ) ) $this->params['globals'] = @include $cacheFile; - } + else { $cache = @file_get_contents( $cacheFile ); - if ( $cache !== false ) { + if( $cache !== false ) $this->params['globals'] = unserialize( $cache ); - } } } else { @@ -675,6 +678,7 @@ * Popuplate wgConf from config files. * * @return bool Success. +* @SuppressWarnings(PHPMD.ElseExpression) */ private function populatewgConf() { @@ -751,6 +755,8 @@ * * @param string $filename Name of the requested file. * @return array|false The interpreted array in case of success, else false. +* @SuppressWarnings(PHPMD.CyclomaticComplexity) +* @SuppressWarnings(PHPMD.StaticAccess) */ function readFile( $filename ) { @@ -879,21 +885,21 @@ * in order to override permissions array with removed rights. * * @param array $array1. -* * @return array +* @SuppressWarning(PHPMD.StaticAccess) */ static private function arrayMerge( $array1/* ... */ ) { $out = $array1; $argsCount = func_num_args(); for ( $i = 1; $i < $argsCount; $i++ ) { foreach ( func_get_arg( $i ) as $key => $value ) { - if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) { + if( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) { $out[$key] = self::arrayMerge( $out[$key], $value ); - } elseif ( !isset( $out[$key] ) && !is_numeric( $key ) ) { + } elseif( !isset( $out[$key] ) && !is_numeric( $key ) ) { // Values that evaluate to true given precedence, for the // primary purpose of merging permissions arrays. $out[$key] = $value; - } elseif ( is_numeric( $key ) ) { + } elseif( is_numeric( $key ) ) { $out[] = $value; } } -- To view, visit https://gerrit.wikimedia.org/r/299392 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3c9750d92cc89b5f84170a479b4228324806fd74 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MediaWikiFarm Gerrit-Br
[MediaWiki-commits] [Gerrit] Now every request is first loaded with MediaWikiFarm::load i... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299409 Change subject: Now every request is first loaded with MediaWikiFarm::load instead of sometimes two methods .. Now every request is first loaded with MediaWikiFarm::load instead of sometimes two methods --- M scripts/mwscript.php M src/MediaWikiFarm.php M src/api.php.txt M src/img_auth.php.txt M src/index.php.txt M src/load.php.txt M src/main.php M src/opensearch_desc.php.txt 8 files changed, 23 insertions(+), 33 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/09/299409/1 diff --git a/scripts/mwscript.php b/scripts/mwscript.php index c97b876..6df30cb 100644 --- a/scripts/mwscript.php +++ b/scripts/mwscript.php @@ -18,9 +18,6 @@ } else { - /** Definition of a constant to protect dedicated entry points. */ - define( 'MEDIAWIKI_FARM', true ); - $wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) ); $wgMediaWikiFarmConfigDir = '/etc/mediawiki'; $wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; @@ -139,7 +136,7 @@ $mwfScript = 'maintenance/' . $mwfScript . '.php'; # Initialise the requested version -MediaWikiFarm::getEntryPoint( $mwfScript, $mwfHost ); +MediaWikiFarm::load( $mwfScript, $mwfHost ); # Display parameters $mwfVersion = $wgMediaWikiFarm->params['version'] ? $wgMediaWikiFarm->params['version'] : 'current'; diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index f8cd5c7..042d591 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -53,17 +53,17 @@ * -- */ /** -* In the case of multiversion installations, this select the version directory. +* This is the main function to initialise the MediaWikiFarm and check for existence of the wiki. * -* This function is called very early during the loading, even before MediaWiki -* is loaded (first function called by multiversion-dedicated entry points like -* `www/index.php`). +* In multiversion installations, this function is called very early during the loading, +* even before MediaWiki is loaded (first function called by multiversion-dedicated entry points +* like `www/index.php`). * * @param string $entryPoint Name of the entry point, e.g. 'index.php', 'load.php'… * @param string|null $host Requested host. * @return string $entryPoint Identical entry point as passed in input. */ - static function getEntryPoint( $entryPoint, $host = null ) { + static function load( $entryPoint = '', $host = null ) { global $wgMediaWikiFarm; @@ -80,7 +80,8 @@ } # Go to version directory - chdir( $wgMediaWikiFarm->params['code'] ); + if( getcwd() != $wgMediaWikiFarm->params['code'] ) + chdir( $wgMediaWikiFarm->params['code'] ); return $entryPoint; } @@ -426,7 +427,7 @@ */ private function setVersion( $version = null ) { - global $IP, $wgVersion; + global $IP; # Replace variables in the file name containing all versions, if existing $this->setWikiProperty( 'versions' ); @@ -539,8 +540,8 @@ $myWiki = $this->params['wikiID']; $mySuffix = $this->params['suffix']; - if( $this->params['version'] ) $cacheFile = $this->replaceVariables( '$VERSION-$SUFFIX-$WIKIID.ser' ); - else $cacheFile = $this->replaceVariables( '$SUFFIX-$WIKIID.ser' ); + if( $this->params['version'] ) $cacheFile = $this->replaceVariables( 'config-$VERSION-$SUFFIX-$WIKIID.ser' ); + else $cacheFile = $this->replaceVariables( 'config-$SUFFIX-$WIKIID.ser' ); $this->params['globals'] = false; # Check modification time of original config files diff --git a/src/api.php.txt b/src/api.php.txt index 782f5a7..12b7962 100644 --- a/src/api.php.txt +++ b/src/api.php.txt @@ -22,4 +22,4 @@ // @codingStandardsIgnoreEnd # Redirect to the requested version -require MediaWikiFarm::getEntryPoint( 'api.php' ); +require MediaWikiFarm::load( 'api.php' ); diff --git a/src/img_auth.php.txt b/src/img_auth.php.txt index 74402b0..5bd2484 100644 --- a/src/img_auth.php.txt +++ b/src/img_auth.php.txt @@ -22,4 +22,4 @@ // @codingStandardsIgnoreEnd # Redirect to the requested version -require MediaWikiFarm::getEntryPoint( 'img_auth.php' ); +require MediaWikiFarm::load( 'img_auth.php' ); diff --git a/src/index.php.txt b/src/index.php.txt index 998b670..c638736 100644 --- a/src/index.php.txt +++ b/src/index.p
[MediaWiki-commits] [Gerrit] Forgotten debug - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299411 Change subject: Forgotten debug .. Forgotten debug --- M src/MediaWikiFarm.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/11/299411/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 6a2f345..ee4a288 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -28,7 +28,7 @@ private $configDir = ''; /** @var string|null MediaWiki code directory, where each subdirectory is a MediaWiki installation. */ - public $codeDir = null; + private $codeDir = null; /** @var string|null MediaWiki cache directory. */ private $cacheDir = null; -- To view, visit https://gerrit.wikimedia.org/r/299411 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie7f2400f3f38994be108da9a3f5c0f177655a4e2 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] Added entry points for the multiversion case. - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299395 Change subject: Added entry points for the multiversion case. .. Added entry points for the multiversion case. In the multiversion case, these entry points must be copied in the directory /www of the extension (nonexistent in Git) and renamed with the extension .php (they have an additional .txt extension to protect the case where the extension is installed without the multiversion feature activated). These entry points load the MediaWikiFarm object, check the existence of the wiki, change the directory to the specific version directory, and load the real MediaWiki entry point. The performance has been checked by using microtime(true): this extension takes roughly mean=10ms (median=9ms; std=2ms; min=7.8ms; max=19ms; 50samples), against roughly mean=2.9ms (median=2.7ms; std=0.4ms; min=2.5ms; max=3.9ms; 50samples) with a classical LocalSettings.php with some config options and wfLoadSkin('Vector') (it is this function which takes all the time, config options take some microseconds). This performance is with a cache configuration enable (serialised file) (without this cache, add roughly 3-4ms). A big part of the time is spent by the Composer autoloader (mean=3ms; std=1ms). Given this one is only useful for YAML config files, I will create PHP cached config files corresponding to YAML files in order to remove this dependency apart if really needed. Note that require-dev dependencies add roughly 7-10ms, so the performance must be really computed without require-dev. --- M .gitignore M src/MediaWikiFarm.php A src/api.php.txt A src/img_auth.php.txt A src/index.php.txt A src/load.php.txt M src/main.php A src/opensearch_desc.php.txt 8 files changed, 167 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/95/299395/1 diff --git a/.gitignore b/.gitignore index 170443b..77181fc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ *~ # Composer -vendor +/vendor + +# Installation +/www diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 8eefd65..ab04a50 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -8,8 +8,10 @@ */ # Protect against web entry -if( !defined( 'MEDIAWIKI' ) ) exit; +if( !defined( 'MEDIAWIKI' ) && !defined( 'MEDIAWIKI_FARM' ) ) exit; +# Load Composer libraries +# There is no warning if not present because the only library loaded (YAML) could not be useful in some installations. @include_once __DIR__ . '/../vendor/autoload.php'; /** @@ -48,18 +50,52 @@ * -- */ /** +* In the case of multiversion installations, this select the version directory. +* +* This function is called very early during the loading, even before MediaWiki +* is loaded (first function called by multiversion-dedicated entry points like +* `www/index.php`). +* +* @param string $entryPoint Name of the entry point, e.g. 'index.php', 'load.php'… +* @param string|null $host Requested host. +* @return string $entryPoint Identical entry point as passed in input. +*/ + static function getEntryPoint( $entryPoint, $host = null ) { + + global $wgMediaWikiFarm; + + # Initialise object + $wgMediaWikiFarm = self::initialise( $host ); + + # Check existence + if( !$wgMediaWikiFarm->checkExistence() ) { + + echo 'Error: unknown wiki.'; + exit; + } + + # Go to version directory + chdir( $wgMediaWikiFarm->params['code'] ); + + return $entryPoint; + } + + /** * Initialise the unique object of type MediaWikiFarm. * -* @param string +* @param string|null $host Requested host. * @return MediaWikiFarm Singleton. */ - static function initialise( $host ) { + static function initialise( $host = null ) { global $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir; - if( self::$self == null ) + if( self::$self == null ) { + + # Warning: do not use $GLOBALS['_SERVER']['HTTP_HOST']: bug with PHP7: it is not initialised in early times of a script + if( is_null( $host ) ) $host = $_SERVER['HTTP_HOST']; self::$self = new self( $host, $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir ); - + } return self::$self; } @@ -79,6 +115,10 @@ if( $this->unusable )
[MediaWiki-commits] [Gerrit] Added a sample LocalSettings.php for monoversion installatio... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299399 Change subject: Added a sample LocalSettings.php for monoversion installations ; removed all isset, replaced by array_key_exists when applicable .. Added a sample LocalSettings.php for monoversion installations ; removed all isset, replaced by array_key_exists when applicable --- A docs/config/LocalSettings.php M src/MediaWikiFarm.php 2 files changed, 21 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/99/299399/1 diff --git a/docs/config/LocalSettings.php b/docs/config/LocalSettings.php new file mode 100644 index 000..5681f46 --- /dev/null +++ b/docs/config/LocalSettings.php @@ -0,0 +1,18 @@ +codeDir ) && is_dir( $this->codeDir . '/' . ((string) $choices[$value]) ) && is_file( $this->codeDir . '/' . ((string) $choices[$value]) . '/includes/DefaultSettings.php' ) ) + if( is_string( $this->codeDir ) && is_dir( $this->codeDir . '/' . ((string) $choices[$value]) ) && is_file( $this->codeDir . '/' . ((string) $choices[$value]) . '/includes/DefaultSettings.php' ) ) $version = (string) $choices[$value]; } } @@ -956,9 +956,9 @@ $argsCount = func_num_args(); for ( $i = 1; $i < $argsCount; $i++ ) { foreach ( func_get_arg( $i ) as $key => $value ) { - if( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) { + if( array_key_exists( $key, $out ) && is_array( $out[$key] ) && is_array( $value ) ) { $out[$key] = self::arrayMerge( $out[$key], $value ); - } elseif( !isset( $out[$key] ) && !is_numeric( $key ) ) { + } elseif( !array_key_exists( $key, $out ) && !is_numeric( $key ) ) { // Values that evaluate to true given precedence, for the // primary purpose of merging permissions arrays. $out[$key] = $value; -- To view, visit https://gerrit.wikimedia.org/r/299399 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If5adcb58e5d13d5fdbc53048065354354630e009 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] Documentation - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299407 Change subject: Documentation .. Documentation --- M composer.json M scripts/mwscript.php M src/api.php.txt M src/img_auth.php.txt M src/index.php.txt M src/load.php.txt M src/opensearch_desc.php.txt 7 files changed, 7 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/07/299407/1 diff --git a/composer.json b/composer.json index 51528b8..185a3a2 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "scripts": { "validate-schema": "php ./scripts/validate-schema.php", - "phpdoc": "./vendor/bin/phpdoc -d ./src -t ./docs/code", + "phpdoc": "./vendor/bin/phpdoc -d src,scripts -e php,php.txt -t ./docs/code", "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor ." } } diff --git a/scripts/mwscript.php b/scripts/mwscript.php index bf9cdb0..248c9cc 100644 --- a/scripts/mwscript.php +++ b/scripts/mwscript.php @@ -10,7 +10,7 @@ # Protect against web entry if( PHP_SAPI != 'cli' ) exit; -# Definition of a constant to protect dedicated entry points +/** Definition of a constant to protect dedicated entry points. */ define( 'MEDIAWIKI_FARM', true ); # Configuration of the MediaWiki Farm diff --git a/src/api.php.txt b/src/api.php.txt index 43e0634..782f5a7 100644 --- a/src/api.php.txt +++ b/src/api.php.txt @@ -7,7 +7,7 @@ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version ultérieure */ -# Definition of a constant to protect dedicated entry points +/** Definition of a constant to protect dedicated entry points. */ define( 'MEDIAWIKI_FARM', true ); # Configuration of the MediaWiki Farm diff --git a/src/img_auth.php.txt b/src/img_auth.php.txt index 039538c..74402b0 100644 --- a/src/img_auth.php.txt +++ b/src/img_auth.php.txt @@ -7,7 +7,7 @@ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version ultérieure */ -# Definition of a constant to protect dedicated entry points +/** Definition of a constant to protect dedicated entry points. */ define( 'MEDIAWIKI_FARM', true ); # Configuration of the MediaWiki Farm diff --git a/src/index.php.txt b/src/index.php.txt index 4879943..998b670 100644 --- a/src/index.php.txt +++ b/src/index.php.txt @@ -7,7 +7,7 @@ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version ultérieure */ -# Definition of a constant to protect dedicated entry points +/** Definition of a constant to protect dedicated entry points. */ define( 'MEDIAWIKI_FARM', true ); # Configuration of the MediaWiki Farm diff --git a/src/load.php.txt b/src/load.php.txt index 50e4c78..f33e996 100644 --- a/src/load.php.txt +++ b/src/load.php.txt @@ -7,7 +7,7 @@ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version ultérieure */ -# Definition of a constant to protect dedicated entry points +/** Definition of a constant to protect dedicated entry points. */ define( 'MEDIAWIKI_FARM', true ); # Configuration of the MediaWiki Farm diff --git a/src/opensearch_desc.php.txt b/src/opensearch_desc.php.txt index 01caaab..3bb374b 100644 --- a/src/opensearch_desc.php.txt +++ b/src/opensearch_desc.php.txt @@ -7,7 +7,7 @@ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version ultérieure */ -# Definition of a constant to protect dedicated entry points +/** Definition of a constant to protect dedicated entry points. */ define( 'MEDIAWIKI_FARM', true ); # Configuration of the MediaWiki Farm -- To view, visit https://gerrit.wikimedia.org/r/299407 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I86562355bc2ab7ea214daac40d819e24cfd96e76 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] Better JSON schema - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299396 Change subject: Better JSON schema .. Better JSON schema --- M docs/farms-schema.json 1 file changed, 41 insertions(+), 149 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/96/299396/1 diff --git a/docs/farms-schema.json b/docs/farms-schema.json index 926be60..f25a7df 100644 --- a/docs/farms-schema.json +++ b/docs/farms-schema.json @@ -9,58 +9,28 @@ { "type": "object", "additionalProperties": false, + "required": ["suffix", "wikiID"], "properties": { "variables": { "type": "array", "description": "List of variables in the host.", "additionalItems": false, - "items": [ - { - "type": "object", - "description": "An host variable.", - "additionalProperties": false, - "properties": { - "variable": { - "type": "string", - "description": "Name of the host variable." - }, - "file": { - "type": "string", - "description": "Path of the existing values for this variable." - } - } - }, - { - "type": "object", - "description": "An host variable.", - "additionalProperties": false, - "properties": { - "variable": { - "type": "string", - "description": "Name of the host variable." - }, - "file": { - "type": "string", - "description": "Path of the existing values for this variable." - } - } - }, - { - "type": "object", - "description": "An host variable.", - "additionalProperties": false, - "properties": { - "variable": { - "type": "string", - "description": "Name of the host variable." -
[MediaWiki-commits] [Gerrit] Added support for reading serialised files in readFile; adde... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299397 Change subject: Added support for reading serialised files in readFile; added a function to cache a file in serialised or PHP format; used these two functions in getMediaWikiConfig .. Added support for reading serialised files in readFile; added a function to cache a file in serialised or PHP format; used these two functions in getMediaWikiConfig This prepares for a larger change where all files will be cached. --- M src/MediaWikiFarm.php 1 file changed, 59 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/97/299397/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index ab04a50..a5c74d5 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -543,16 +543,9 @@ $this->params['globals'] = false; - if( $cacheFile && @filemtime( $cacheFile ) >= $oldness && is_string( $cacheFile ) ) { - if( preg_match( '/\.php$/', $cacheFile ) ) -$this->params['globals'] = @include $cacheFile; - - else { - $cache = @file_get_contents( $cacheFile ); - if( $cache !== false ) - $this->params['globals'] = unserialize( $cache ); - } - } + if( $cacheFile && is_string( $cacheFile ) && is_file( $cacheFile) && @filemtime( $cacheFile ) >= $oldness ) + $this->params['globals'] = $this->readFile( $cacheFile ); + else { $this->params['globals'] = array( @@ -587,21 +580,8 @@ $globals['extensions']['MediaWikiFarm'] = array( '_loading' => 'wfLoadExtension' ); # Save this configuration in a serialised file - if( $cacheFile ) { - @mkdir( dirname( $cacheFile ) ); - $tmpFile = tempnam( dirname( $cacheFile ), basename( $cacheFile ).'.tmp' ); - chmod( $tmpFile, 0744 ); - if( preg_match( '/\.php$/', $cacheFile ) ) { - if( $tmpFile && file_put_contents( $tmpFile, "cacheFile( $globals, $cacheFile ); } } @@ -780,29 +760,46 @@ * -- */ /** -* Read a file either in PHP, YAML (if library available), JSON, or dblist, and returns the interpreted array. +* Read a file either in PHP, YAML (if library available), JSON, dblist, or serialised, and returns the interpreted array. * -* The choice between the format depends on the extension: php, yml, yaml, json, dblist. +* The choice between the format depends on the extension: php, yml, yaml, json, dblist, serialised. * * @param string $filename Name of the requested file. +* @param string $directory Parent directory. * @return array|false The interpreted array in case of success, else false. * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.StaticAccess) */ - function readFile( $filename ) { + private function readFile( $filename, $directory = '' ) { # Check parameter - if( !is_string( $filename ) || !is_file( $filename ) ) + if( !is_string( $filename ) ) return false; # Detect the format # Note the regex must be greedy to correctly select double extensions $format = preg_replace( '/^.*\.([a-z]+)$/', '$1', $filename ); + # Check the file exists + $filename = $directory ? $directory . '/' . $filename : $filename; + if( !is_file( $filename ) ) + return false; + # Format PHP if( $format == 'php' ) $array = @include $filename; + + # Format 'serialisation' + elseif( $format == 'ser' ) { + + $content = @file_get_contents( $filename ); + + if( !$content ) + return array(); + + $array = @unserialize( $content ); + } # Format YAML elseif( $format == 'yml' || $format == 'yaml' ) { @@ -824,7 +821,7 @@
[MediaWiki-commits] [Gerrit] Reduced NPath/Cyclomatic complexity of __construct; suppress... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299393 Change subject: Reduced NPath/Cyclomatic complexity of __construct; suppressed some unuseful conditions; improved efficiency of getMediaWikiConfig .. Reduced NPath/Cyclomatic complexity of __construct; suppressed some unuseful conditions; improved efficiency of getMediaWikiConfig And suppressed some NPath/Cyclomatic complexity warnings And renamed $this->paramsDir into $this->configDir (previous automatic rename of $this->config with this false positive) --- M src/MediaWikiFarm.php 1 file changed, 66 insertions(+), 86 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/93/299393/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 83e85f5..fe636bb 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -113,11 +113,6 @@ if( $this->unusable ) return false; - if( !is_array( $this->params ) && array_key_exists( 'globals', $this->params ) ) { - $this->unusable = true; - return; - } - if( !is_array( $this->params['globals'] ) ) $this->getMediaWikiConfig(); @@ -215,23 +210,23 @@ private function __construct( $host, $configDir = '/etc/mediawiki', $codeDir = null ) { # Check parameters - if( !isset( $host ) || !is_string( $host ) ) + if( !is_string( $host ) || + !(is_string( $configDir ) && is_dir( $configDir )) || + !(is_null( $codeDir ) xor (is_string( $codeDir ) && is_dir( $codeDir ))) + ) { + $this->unusable = true; - if( isset( $configDir ) && (!is_string( $configDir ) || !is_dir( $configDir )) ) - $this->unusable = true; - if( isset( $codeDir ) && (!is_string( $codeDir ) || !is_dir( $codeDir )) ) - $this->unusable = true; - - if( $this->unusable ) return; + return; + } # Set parameters - $this->paramsDir = $configDir; + $this->configDir = $configDir; $this->codeDir = $codeDir; # Read the farm(s) configuration - if( $configs = $this->readFile( $this->paramsDir . '/farms.yml' ) ); - elseif( $configs = $this->readFile( $this->paramsDir . '/farms.php' ) ); - elseif( $configs = $this->readFile( $this->paramsDir . '/farms.json' ) ); + if( $configs = $this->readFile( $this->configDir . '/farms.yml' ) ); + elseif( $configs = $this->readFile( $this->configDir . '/farms.php' ) ); + elseif( $configs = $this->readFile( $this->configDir . '/farms.json' ) ); else $this->unusable = true; # Now select the right configuration amoung all farms @@ -262,7 +257,7 @@ # For each proposed farm, check if the host matches foreach( $configs as $regex => $config ) { - if( !preg_match( '/' . $regex . '/', $host, $matches ) ) + if( !preg_match( '/' . $regex . '/i', $host, $matches ) ) continue; # Initialise variables from the host @@ -293,6 +288,7 @@ * * @return string|null|false If an existing version is found in files, returns a string; if no version is found, returns null; if the host is missing in existence files, returns false; if an existence file is missing or badly formatted, return false and turns this object into a unusable state. * @SuppressWarnings(PHPMD.ElseExpression) +* @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function replaceHostVariables() { @@ -315,7 +311,7 @@ continue; # Really check if the variable is in the listing file - $choices = $this->readFile( $this->paramsDir . '/' . $this->replaceVariables( $variable['file'] ) ); + $choices = $this->readFile( $this->configDir . '/' . $this->replaceVariables( $variable['file'] ) ); if( $choices === false ) { $this->unusable = true; return false; @@ -349,9 +345,6 @@ */ private function setWikiID() { - if( $this->unusable ) - return false; -
[MediaWiki-commits] [Gerrit] Added a script to execute a MediaWiki script in the context ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299406 Change subject: Added a script to execute a MediaWiki script in the context of a farm .. Added a script to execute a MediaWiki script in the context of a farm --- A scripts/mwscript.php M src/MediaWikiFarm.php M src/main.php 3 files changed, 168 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/06/299406/1 diff --git a/scripts/mwscript.php b/scripts/mwscript.php new file mode 100644 index 000..bf9cdb0 --- /dev/null +++ b/scripts/mwscript.php @@ -0,0 +1,162 @@ + + * @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 + */ + +# Protect against web entry +if( PHP_SAPI != 'cli' ) exit; + +# Definition of a constant to protect dedicated entry points +define( 'MEDIAWIKI_FARM', true ); + +# Configuration of the MediaWiki Farm +$wgMediaWikiFarmCodeDir = dirname( dirname( dirname( __FILE__ ) ) ); +$wgMediaWikiFarmConfigDir = '/etc/mediawiki'; +$wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; +@include_once dirname( dirname( __FILE__ ) ) . '/config/MediaWikiFarmDirectories.php'; + +# Include library +// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound +require_once dirname( dirname( __FILE__ ) ) . '/src/MediaWikiFarm.php'; +// @codingStandardsIgnoreEnd + +# A small helper function +/** + * Get a command line parameter. + * + * The parameter can be removed from the list, except the first parameter (script name). + * + * @param string|integer $name Parameter name or position (from 0). + * @param bool $shift Remove this parameter from the list? + * @return string|null Value of the parameter. + */ +function mwfGetParam( $name, $shift = true ) { + + global $argc, $argv; + + $posArg = 0; + $nbArgs = 0; + $value = null; + + # Search a named parameter + if( is_string( $name ) ) { + + for( $posArg = 1; $posArg < $argc; $posArg++ ) { + + if( substr( $argv[$posArg], 0, strlen($name)+3 ) == '--'.$name.'=' ) { + $value = substr( $argv[$posArg], strlen($name)+3 ); + $nbArgs = 1; + break; + } + elseif( $argv[$posArg] == '--'.$name && $posArg < $argc - 1 ) { + $value = $argv[$posArg+1]; + $nbArgs = 2; + break; + } + } + } + + # Search a positional parameter + elseif( is_int( $name ) ) { + if( $name == 0 ) + $shift = false; + if( $name >= $argc ) + return null; + $value = $argv[$name]; + $nbArgs = 1; + } + + # Remove the parameter from the list + if( $shift ) { + + $argc -= $nbArgs; + $argv = array_merge( array_slice( $argv, 0, $posArg ), array_slice( $argv, $posArg+$nbArgs ) ); + } + + return $value; +} + +# Usage help +/** + * Display help and return success or error. + * + * @param bool $error Return an error code? + * @return void + */ +function mwfUsage( $error = true ) { + + global $argv; + $fullPath = realpath( $argv[0] ); + + # Minimal help, be it an error or not + echo <params['suffix']}) +Version: {$wgMediaWikiFarm->params['version']}: {$wgMediaWikiFarm->params['code']} +Script: $mwfScript + + +PARAMS; + +# Clean this script +if( !is_file( $mwfScript ) ) { + echo "Script not found.\n"; + exit( 1 ); +} +$argv[0] = $mwfScript; +unset( $mwfScript ); +unset( $mwfHost ); + +# Execute the script +// Possibly it could be better to do a true system call with a child process (PHP function "system"), BUT +// hostname must be passed as an environment variable and more importantly, in the current implementation of +// MediaWikiFarm, the called version of the extension will be $version/extensions/MediaWikiFarm, and this +// version is probably not configured as a standalone extension (directories set in LocalSettings.php); so +// it will not work in current implementation. +require $argv[0]; + diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 38cab2b..63b7dd3 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -74,9 +74,9 @@ if( !$wgMediaWikiFarm->checkExistence() ) { $version = $_SERVER['SERVER_PROTOCOL'] && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.0' ? '1.0' : '1.1'; -
[MediaWiki-commits] [Gerrit] Moved example files farms.yml/json/php to docs/config ; the ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299402 Change subject: Moved example files farms.yml/json/php to docs/config ; the directory /config can be used for production configuration if wanted .. Moved example files farms.yml/json/php to docs/config ; the directory /config can be used for production configuration if wanted --- M .gitignore R docs/config/farms.json R docs/config/farms.php R docs/config/farms.yml 4 files changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/02/299402/1 diff --git a/.gitignore b/.gitignore index 77181fc..4f1842a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ /vendor # Installation +/config /www diff --git a/config/farms.json b/docs/config/farms.json similarity index 100% rename from config/farms.json rename to docs/config/farms.json diff --git a/config/farms.php b/docs/config/farms.php similarity index 100% rename from config/farms.php rename to docs/config/farms.php diff --git a/config/farms.yml b/docs/config/farms.yml similarity index 100% rename from config/farms.yml rename to docs/config/farms.yml -- To view, visit https://gerrit.wikimedia.org/r/299402 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic5ba21126886f614aa0d457b80b57a3b8598e9b2 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] Additional checks on the host - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299405 Change subject: Additional checks on the host .. Additional checks on the host --- M src/MediaWikiFarm.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/05/299405/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index c02bbb8..38cab2b 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -256,7 +256,7 @@ private function __construct( $host, $configDir, $codeDir = null, $cacheDir = null ) { # Check parameters - if( !is_string( $host ) || + if( !is_string( $host ) || $host == '' || !(is_string( $configDir ) && is_dir( $configDir )) || !(is_null( $codeDir ) xor (is_string( $codeDir ) && is_dir( $codeDir ))) || !(is_null( $cacheDir ) xor is_string( $cacheDir )) @@ -308,7 +308,7 @@ # For each proposed farm, check if the host matches foreach( $configs as $regex => $config ) { - if( !preg_match( '/' . $regex . '/i', $host, $matches ) ) + if( !preg_match( '/^' . $regex . '$/i', $host, $matches ) ) continue; # Initialise variables from the host -- To view, visit https://gerrit.wikimedia.org/r/299405 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2280eec0438d303e3bc5ab206e3060f111508bc6 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] Generalisation of cache files to all files read. - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299398 Change subject: Generalisation of cache files to all files read. .. Generalisation of cache files to all files read. For now it is in the subdirectory '.cache' of the config directory. Composer is now only loaded when YAML files must be read. Performance has drastically improved (in ms): mean = 4.7572 median = 4.3525 std= 0.9047 min= 3.8898 max= 6.9201 range = 3.0303 samples = 50 Performance in the case nothing is cached is about 12ms; it is between if some files are cached. For information, an equivalent LocalSettings.php is loaded in 2.9ms (mean). So this extension takes ~1.85ms. Possibly performance could be still improved by creating a unique file with all existing wikis (of a farm) with their version associated, although there is no certainty about that (possibly a big file could take more time than two small files). --- M src/MediaWikiFarm.php 1 file changed, 56 insertions(+), 53 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/98/299398/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index a5c74d5..69e94cb 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -10,10 +10,6 @@ # Protect against web entry if( !defined( 'MEDIAWIKI' ) && !defined( 'MEDIAWIKI_FARM' ) ) exit; -# Load Composer libraries -# There is no warning if not present because the only library loaded (YAML) could not be useful in some installations. -@include_once __DIR__ . '/../vendor/autoload.php'; - /** * This class computes the configuration of a specific wiki from a set of configuration files. * The configuration is composed of the list of authorised wikis and different configuration @@ -264,9 +260,9 @@ $this->codeDir = $codeDir; # Read the farm(s) configuration - if( $configs = $this->readFile( $this->configDir . '/farms.yml' ) ); - elseif( $configs = $this->readFile( $this->configDir . '/farms.php' ) ); - elseif( $configs = $this->readFile( $this->configDir . '/farms.json' ) ); + if( $configs = $this->readFile( 'farms.yml', $this->configDir ) ); + elseif( $configs = $this->readFile( '/farms.json', $this->configDir ) ); + elseif( $configs = $this->readFile( '/farms.php', $this->configDir ) ); else $this->unusable = true; # Now select the right configuration amoung all farms @@ -351,7 +347,7 @@ continue; # Really check if the variable is in the listing file - $choices = $this->readFile( $this->configDir . '/' . $this->replaceVariables( $variable['file'] ) ); + $choices = $this->readFile( $this->replaceVariables( $variable['file'] ), $this->configDir ); if( $choices === false ) { $this->unusable = true; return false; @@ -390,11 +386,11 @@ # Set suffix $this->setWikiProperty( 'suffix' ); - $this->variables['suffix'] = $this->params['suffix']; + $this->variables['SUFFIX'] = $this->params['suffix']; # Set wikiID $this->setWikiProperty( 'wikiID' ); - $this->variables['wikiID'] = $this->params['wikiID']; + $this->variables['WIKI'] = $this->params['wikiID']; # Check consistency if( !$this->params['suffix'] || !$this->params['wikiID'] ) { @@ -426,7 +422,7 @@ # In the case multiversion is configured, but version is not known as of now elseif( is_string( $this->codeDir ) && is_null( $version ) ) { - $versions = $this->readFile( $this->params['versions'] ); + $versions = $this->readFile( $this->params['versions'], $this->configDir ); if( !$versions ) { $this->unusable = true; @@ -459,7 +455,7 @@ } # Set the version in the wiki configuration and as a variable to be used later - $this->variables['version'] = $version; + $this->variables['VERSION'] = $version; $this->params['version'] = $version; return true; @@ -476,7 +472,6 @@ $this->params['config'] = array(); $this->setWikiProperty( 'data' ); - $this->setWikiProperty( 'cache' ); $this->setWikiProperty( 'config'
[MediaWiki-commits] [Gerrit] First pass on standardisation of directories (multiversion):... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299400 Change subject: First pass on standardisation of directories (multiversion): the MediaWikiFarm extension must be installed next to MediaWiki versions and inside each MediaWiki version .. First pass on standardisation of directories (multiversion): the MediaWikiFarm extension must be installed next to MediaWiki versions and inside each MediaWiki version Defined a LocalSettings.php for multiversion, a simple inclusion of the version-specific MediaWikiFarm extension --- A docs/config/LocalSettings.multiversion.php M docs/config/LocalSettings.php M src/MediaWikiFarm.php M src/api.php.txt M src/img_auth.php.txt M src/index.php.txt M src/load.php.txt M src/main.php M src/opensearch_desc.php.txt 9 files changed, 28 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/00/299400/1 diff --git a/docs/config/LocalSettings.multiversion.php b/docs/config/LocalSettings.multiversion.php new file mode 100644 index 000..04fba54 --- /dev/null +++ b/docs/config/LocalSettings.multiversion.php @@ -0,0 +1,13 @@ +https://gerrit.wikimedia.org/r/299400 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I25f16007c56b314f2be197d3cc8f5d5b7088ee1f 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] Exported a part of getMediaWikiConfig() to extractSkinsAndEx... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299394 Change subject: Exported a part of getMediaWikiConfig() to extractSkinsAndExtensions() .. Exported a part of getMediaWikiConfig() to extractSkinsAndExtensions() This reduces the NPath complexity of getMediaWikiConfig from 5620 to 132 and split the cyclomatic complexity (29) into 16 for getMediaWikiConfig and 14 for extractSkinsAndExtensions --- M src/MediaWikiFarm.php 1 file changed, 103 insertions(+), 92 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/94/299394/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index fe636bb..8eefd65 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -541,73 +541,12 @@ //$globals['general']['wgDefaultUserOptions'] = MediaWikiFarm::arrayMerge( $wgConf->get( '+wgDefaultUserOptions', $myWiki, $mySuffix ), $globals['general']['wgDefaultUserOptions'] ); # Extract from the general configuration skin and extension configuration - # Search for skin and extension activation - $unsetPrefixes = array(); - foreach( $globals['general'] as $setting => $value ) { - if( preg_match( '/^wgUseSkin(.+)$/', $setting, $matches ) && $value === true ) { - - $skin = $matches[1]; - $loadingMechanism = $this->detectLoadingMechanism( 'skin', $skin ); - - if( is_null( $loadingMechanism ) ) $unsetPrefixes[] = $skin; - else $globals['skins'][$skin] = array( '_loading' => $loadingMechanism ); - - unset( $globals['general'][$setting] ); - } - elseif( preg_match( '/^wgUseExtension(.+)$/', $setting, $matches ) && $value === true ) { - - $extension = $matches[1]; - $loadingMechanism = $this->detectLoadingMechanism( 'extension', $extension ); - - if( is_null( $loadingMechanism ) ) $unsetPrefixes[] = $extension; - else $globals['extensions'][$extension] = array( '_loading' => $loadingMechanism ); - - unset( $globals['general'][$setting] ); - } - elseif( preg_match( '/^wgUse(?:Skin|Extension|LocalExtension)(.+)$/', $setting, $matches ) && $value !== true ) { - - $unsetPrefixes[] = $matches[1]; - unset( $globals['general'][$setting] ); - } - } + $this->extractSkinsAndExtensions(); - # Extract skin and extension configuration from the general configuration - $regexSkins = '/^wg(' . implode( '|', - array_map( - function( $a ) { return preg_quote( $a, '/' ); }, - array_keys( $globals['skins'] ) - ) - ) . ')/'; - $regexExtensions = '/^wg(' . implode( '|', - array_map( - function( $a ) { return preg_quote( $a, '/' ); }, - array_keys( $globals['extensions'] ) - ) - ) . ')/'; - $regexUnsetPrefixes = '/^wg(' . implode( '|', - array_map( - function( $a ) { return preg_quote( $a, '/' ); }, - $unsetPrefixes - ) - ) . ')/'; - foreach( $globals['general'] as $setting => $value ) { - - if( preg_match( $regexExtensions, $setting, $matches ) ) { - $globals['extensions'][$matches[1]][$setting] = $value; - unset( $setting ); - } - elseif( preg_match( $regexSkins, $setting, $matches ) ) { -
[MediaWiki-commits] [Gerrit] Added support for external executable config files - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299403 Change subject: Added support for external executable config files .. Added support for external executable config files --- M src/MediaWikiFarm.php M src/main.php 2 files changed, 33 insertions(+), 30 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/03/299403/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 2678076..317a22e 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -25,26 +25,26 @@ * Properties * -- */ - /** @var MediaWikiFarm|null [private] Singleton. */ + /** @var MediaWikiFarm|null Singleton. */ private static $self = null; - /** @var string [private] Farm configuration directory. */ + /** @var string Farm configuration directory. */ private $configDir = ''; - /** @var string|null [private] MediaWiki code directory, where each subdirectory is a MediaWiki installation. */ + /** @var string|null MediaWiki code directory, where each subdirectory is a MediaWiki installation. */ private $codeDir = null; - /** @var string|null [private] MediaWiki cache directory. */ + /** @var string|null MediaWiki cache directory. */ private $cacheDir = null; - /** @var bool [private] This object cannot be used because of an emergency error. */ + /** @var bool This object cannot be used because of an emergency error. */ public $unusable = false; - /** @var array [private] Farm configuration file. */ - public $params = array(); - - /** @var array [private] Variables related to the current request. */ + /** @var array Variables related to the current request. */ public $variables = array(); + + /** @var array Configuration parameters for this wiki. */ + public $params = array(); @@ -154,7 +154,7 @@ function loadMediaWikiConfig() { if( $this->unusable ) - return false; + return; if( !is_array( $this->params['globals'] ) ) $this->getMediaWikiConfig(); @@ -178,7 +178,7 @@ function loadSkinsConfig() { if( $this->unusable ) - return false; + return; // Load skins with the wfLoadSkin mechanism foreach( $this->params['globals']['skins'] as $skin => $value ) { @@ -211,7 +211,7 @@ function loadExtensionsConfig() { if( $this->unusable ) - return false; + return; // Load extensions with the wfLoadExtension mechanism foreach( $this->params['globals']['extensions'] as $extension => $value ) { @@ -553,7 +553,8 @@ $this->params['globals'] = array( 'general' => array(), 'skins' => array(), - 'extensions' => array() + 'extensions' => array(), + 'execFiles' => array(), ); $globals =& $this->params['globals']; @@ -603,7 +604,11 @@ foreach( $this->params['config'] as $configFile ) { # Executable config files - if( array_key_exists( 'exec', $configFile ) ) continue; + if( array_key_exists( 'exec', $configFile ) ) { + + $this->params['globals']['execFiles'][] = $this->configDir . '/' . $configFile['file']; + continue; + } $theseSettings = $this->readFile( $configFile['file'], $this->configDir ); if( $theseSettings === false ) { diff --git a/src/main.php b/src/main.php index 222c1f8..3768f45 100644 --- a/src/main.php +++ b/src/main.php @@ -10,14 +10,15 @@ # Protect against web entry if( !defined( 'MEDIAWIKI' ) ) exit; +# Class where the logic is require_once __DIR__ . '/MediaWikiFarm.php'; - -$wgMediaWikiFarm = MediaWikiFarm::initialise( $GLOBALS['_SERVER']['HTTP_HOST'] ); /* - * Check existence + * Verify existence of the wiki */ + +$wgMediaWikiFarm = MediaWikiFarm::initialise(); if( !$wgMediaWikiFarm->checkExistence() ) { @@ -30,16 +31,8 @@ * MediaWiki */ -// Load general MediaWiki configuration +# Load general MediaWiki configuration $wgMediaWikiFarm->loadM
[MediaWiki-commits] [Gerrit] Add status 404 in case of nonexistent wiki - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299404 Change subject: Add status 404 in case of nonexistent wiki .. Add status 404 in case of nonexistent wiki --- M src/MediaWikiFarm.php M src/main.php 2 files changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/04/299404/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 317a22e..c02bbb8 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -73,6 +73,8 @@ # Check existence if( !$wgMediaWikiFarm->checkExistence() ) { + $version = $_SERVER['SERVER_PROTOCOL'] && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.0' ? '1.0' : '1.1'; + header( "HTTP/$version 404 Not Found" ); echo 'Error: unknown wiki.'; exit; } @@ -96,7 +98,7 @@ if( self::$self == null ) { # Warning: do not use $GLOBALS['_SERVER']['HTTP_HOST']: bug with PHP7: it is not initialised in early times of a script - if( is_null( $host ) ) $host = $_SERVER['HTTP_HOST']; + if( is_null( $host ) ) $host = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; self::$self = new self( $host, $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir, $wgMediaWikiFarmCacheDir ); } return self::$self; diff --git a/src/main.php b/src/main.php index 3768f45..9490f48 100644 --- a/src/main.php +++ b/src/main.php @@ -22,6 +22,8 @@ if( !$wgMediaWikiFarm->checkExistence() ) { + $version = $_SERVER['SERVER_PROTOCOL'] && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.0' ? '1.0' : '1.1'; + header( "HTTP/$version 404 Not Found" ); echo 'Error: unknown wiki.'; exit; } -- To view, visit https://gerrit.wikimedia.org/r/299404 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I11a65c269aa5f4d18fe6fc7994cfd02271cadbd8 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] In multiversion installations, added an optional file to set... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299401 Change subject: In multiversion installations, added an optional file to set directories ; added a dedicated property for cacheDir .. In multiversion installations, added an optional file to set directories ; added a dedicated property for cacheDir The cache directory must be set before the main config file, farms.yml, is read, because this file should also be cached. So this option is removed from farms.yml. --- M config/farms.json M config/farms.php M config/farms.yml M docs/config/LocalSettings.php A docs/config/MediaWikiFarmDirectories.php M docs/farms-schema.json M src/MediaWikiFarm.php M src/api.php.txt M src/img_auth.php.txt M src/index.php.txt M src/load.php.txt M src/opensearch_desc.php.txt 12 files changed, 100 insertions(+), 43 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/01/299401/1 diff --git a/config/farms.json b/config/farms.json index f40cfbc..86b90d6 100644 --- a/config/farms.json +++ b/config/farms.json @@ -13,7 +13,6 @@ "wikiID": "$lang$family", "versions": "wikiversions.json", "data": "/srv/data/org/$family/$lang", - "cache": "/tmp/mw-cache/org-$version-$family-$lang", "config": [ { "file": "org/InitialiseSettings.php", @@ -43,7 +42,6 @@ "suffix": "$client", "wikiID": "$wiki-$client", "data": "/srv/data/com/example/$client/$wiki", - "cache": "/tmp/mw-cache/com-example-$version-$client-$wiki", "config": [ { "file": "com/example/DefaultSettings.yml", diff --git a/config/farms.php b/config/farms.php index dd138a9..902f4e4 100644 --- a/config/farms.php +++ b/config/farms.php @@ -17,7 +17,6 @@ 'wikiID' => '$lang$family', 'versions' => 'wikiversions.json', 'data' => '/srv/data/org/$family/$lang', - 'cache' => '/tmp/mw-cache/org-$version-$family-$lang', 'config' => array( array( 'file' => 'org/InitialiseSettings.php', 'key' => '*' @@ -46,7 +45,6 @@ 'suffix' => '$client', 'wikiID' => '$wiki-$client', 'data' => '/srv/data/com/example/$client/$wiki', - 'cache' => '/tmp/mw-cache/com-example-$version-$client-$wiki', 'config' => array( array( 'file' => 'com/example/DefaultSettings.yml', 'key' => 'default' diff --git a/config/farms.yml b/config/farms.yml index 78fa067..bc1686c 100644 --- a/config/farms.yml +++ b/config/farms.yml @@ -12,7 +12,6 @@ wikiID: '$lang$family' versions: 'wikiversions.json' data: '/srv/data/org/$family/$lang' -cache: '/tmp/mw-cache/org-$version-$family-$lang' config: - file: 'org/InitialiseSettings.php' key: '*' @@ -35,7 +34,6 @@ suffix: '$client' wikiID: '$wiki-$client' data: '/srv/data/com/example/$client/$wiki' -cache: '/tmp/mw-cache/com-example-$version-$client-$wiki' config: - file: 'com/example/DefaultSettings.yml' key: 'default' diff --git a/docs/config/LocalSettings.php b/docs/config/LocalSettings.php index d2432a0..ff7f2d1 100644 --- a/docs/config/LocalSettings.php +++ b/docs/config/LocalSettings.php @@ -2,15 +2,17 @@ /** * Configuration managed by MediaWikiFarm -- MonoVersion case. - * - * Just change the configuration directory, preferably in a directory not exposed on the Web. - * Then add the sample file farms.yml inside and start customising it. */ -# Configuration directory. -# There must be a file 'farms.yml' or 'farms.php' or 'farms.json' inside. +// Configuration directory. +// There must be a file 'farms.yml' or 'farms.php' or 'farms.json' inside. $wgMediaWikiFarmConfigDir = '/etc/mediawiki'; +// Cache directory. +// This can speed up the time spend by this extension from 9ms to 2ms. Set to +// null if you want to disable the cache. +$wgMediaWikiFarmCacheDir = '/tmp/mw-cache'; + # Include the code. require_once "$IP/extensions/MediaWikiFarm/MediaWikiFarm.php"; diff --git a/docs/config/MediaWikiFarmDirectories.php b/docs/config/MediaWikiFarmDirectories.php new file mode 100644 index 000..c17f08b --- /dev/null +++ b/docs/config/MediaWikiFarmDirectories.php @@ -0,0 +1,48 @@ +unusable = true; @@ -262,6 +267,10 @@ # Set parameters $this->configDir = $configDir; $this->codeDir = $codeDir; + $this->cacheDir = $cacheDir; + + if( !is_dir( $this->cacheDir ) ) + @mkdir( $this->cacheDir );
[MediaWiki-commits] [Gerrit] Created a subfunction of getMediaWikiConfig to decrease NPat... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299391 Change subject: Created a subfunction of getMediaWikiConfig to decrease NPath complexity .. Created a subfunction of getMediaWikiConfig to decrease NPath complexity --- M src/MediaWikiFarm.php 1 file changed, 70 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/91/299391/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 2efd5cc..2236aaf 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -531,57 +531,9 @@ $globals['skins'] = array(); $globals['extensions'] = array(); - foreach( $this->params['config'] as $configFile ) { - - # Executable config files - if( array_key_exists( 'exec', $configFile ) ) continue; - - $theseSettings = $this->readFile( $this->paramsDir . '/' . $configFile['file'] ); - if( $theseSettings === false ) { - $this->unusable = true; - return false; - } - - # Key 'default' => no choice of the wiki - if( $configFile['key'] == 'default' ) { - - foreach( $theseSettings as $setting => $value ) { - - $wgConf->settings[$setting]['default'] = $value; - } - } - - # Key '*' => choice of any wiki - elseif( $configFile['key'] == '*' ) { - - foreach( $theseSettings as $setting => $value ) { - - foreach( $value as $suffix => $val ) { - - $wgConf->settings[$setting][$suffix] = $val; - } - } - } - - # Other key - else { - - $defaultKey = null; - if( array_key_exists( 'default', $configFile ) ) - $defaultKey = $this->replaceVariables( $configFile['default'] ); - $classicKey = $this->replaceVariables( $configFile['key'] ); - - foreach( $theseSettings as $setting => $values ) { - - foreach( $values as $wiki => $val ) { - - if( $wiki == 'default' && $defaultKey ) $wgConf->settings[$setting][$defaultKey] = $val; - else $wgConf->settings[$setting][str_replace( '*', $wiki, $classicKey )] = $val; - } - } - } - } - + # Populate wgConf + if( !$this->populatewgConf() ) + return false; // Get specific configuration for this wiki // Do not use SiteConfiguration::extractAllGlobals or the configuration caching would become @@ -719,6 +671,73 @@ return null; } + /** +* Popuplate wgConf from config files. +* +* @return bool Success. +*/ + private function populatewgConf() { + + global $wgConf; + + if( $this->unusable ) + return false; + + foreach( $this->params['config'] as $configFile ) { + + # Executable config files + if( array_key_exists( 'exec', $configFile ) ) continue; + +
[MediaWiki-commits] [Gerrit] Change order of methods: public functions, private, then hel... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299388 Change subject: Change order of methods: public functions, private, then helpers ; make private properties and methods if it is not necessarily public .. Change order of methods: public functions, private, then helpers ; make private properties and methods if it is not necessarily public --- M src/MediaWikiFarm.php 1 file changed, 303 insertions(+), 303 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/88/299388/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 653c46a..2cc8b40 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -24,13 +24,13 @@ * -- */ /** @var MediaWikiFarm|null [private] Singleton. */ - public static $self = null; + private static $self = null; /** @var string [private] Farm configuration directory. */ - public $configDir = '/etc/mediawiki'; + private $configDir = '/etc/mediawiki'; /** @var string|null [private] MediaWiki code directory, where each subdirectory is a MediaWiki installation. */ - public $codeDir = null; + private $codeDir = null; /** @var bool [private] This object cannot be used because of an emergency error. */ public $unusable = false; @@ -104,132 +104,93 @@ } /** -* Computation of the suffix and wikiID. +* This function loads MediaWiki configuration (parameters). * -* This function is the central point to get the unique identifier of the wiki, wikiID. -* -* @return bool The wikiID and suffix were set, and the wiki could exist. -*/ - function setWikiID() { - - if( $this->unusable ) - return false; - - $this->params['version'] = null; - $this->params['globals'] = null; - - # Set suffix - $this->setWikiProperty( 'suffix' ); - $this->variables['suffix'] = $this->params['suffix']; - - # Set wikiID - $this->setWikiProperty( 'wikiID' ); - $this->variables['wikiID'] = $this->params['wikiID']; - - # Check consistency - if( !$this->params['suffix'] || !$this->params['wikiID'] ) { - $this->unusable = true; - return false; - } - - return true; - } - - /** -* Setting of the version, either from the input if already got, either from a file. -* -* @param string|null $version If a string, this is the version already got, just set it. -* @return bool The version was set, and the wiki could exist. -*/ - function setVersion( $version = null ) { - - global $IP, $wgVersion; - - if( $this->unusable ) - return false; - - $this->setWikiProperty( 'versions' ); - - # In the case multiversion is configured and version is already known - if( is_string( $version ) && is_string( $this->codeDir ) && is_file( $this->codeDir . '/' . $version . '/includes/DefaultSettings.php' ) ) - $this->params['code'] = $this->codeDir . '/' . $version; - - # In the case multiversion is configured, but version is not known as of now - elseif( is_null( $version ) && is_string( $this->codeDir ) ) { - - $versions = $this->readFile( $this->params['versions'] ); - - if( !$versions ) { - $this->unusable = true; - return false; - } - - if( array_key_exists( $this->params['wikiID'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->params['wikiID']] . '/includes/DefaultSettings.php' ) ) - $version = $versions[$this->params['wikiID']]; - - elseif( array_key_exists( $this->params['suffix'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->params['suffix']] . '/includes/DefaultSettings.php' ) ) - $version = $versions[$this->params['suffix']]; - - elseif( array_key_exists( 'default', $versions ) && is_file( $this->codeDir . '/' . $versions['default'] . '/includes/DefaultSettings.php' ) ) - $version = $versions['default']; -
[MediaWiki-commits] [Gerrit] Micro-optimisation: preg_replace to str_replace - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299390 Change subject: Micro-optimisation: preg_replace to str_replace .. Micro-optimisation: preg_replace to str_replace --- M src/MediaWikiFarm.php 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/90/299390/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 873ab50..2efd5cc 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -576,7 +576,7 @@ foreach( $values as $wiki => $val ) { if( $wiki == 'default' && $defaultKey ) $wgConf->settings[$setting][$defaultKey] = $val; - else $wgConf->settings[$setting][preg_replace( '/\*/', $wiki, $classicKey )] = $val; + else $wgConf->settings[$setting][str_replace( '*', $wiki, $classicKey )] = $val; } } } @@ -823,7 +823,7 @@ $rvalues = array(); foreach( $this->variables as $key => $val ) { - $rkeys[] = '/\$' . preg_quote( $key, '/' ) . '/'; + $rkeys[] = '$' . $key; $rvalues[] = $val; } } @@ -832,7 +832,7 @@ return ''; elseif( is_string( $value ) ) - $value = preg_replace( $rkeys, $rvalues, $value ); + $value = str_replace( $rkeys, $rvalues, $value ); elseif( !is_array( $value ) ) { @@ -843,7 +843,7 @@ foreach( $value as &$subvalue ) { foreach( $subvalue as &$subsubvalue ) - $subsubvalue = preg_replace( $rkeys, $rvalues, $subsubvalue ); + $subsubvalue = str_replace( $rkeys, $rvalues, $subsubvalue ); } } -- To view, visit https://gerrit.wikimedia.org/r/299390 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0ebebbfd542571d56d43633a9ed4bee2170ba438 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] Possibility to cache config in a PHP file ; fixed bug during... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299389 Change subject: Possibility to cache config in a PHP file ; fixed bug during compilation of the config .. Possibility to cache config in a PHP file ; fixed bug during compilation of the config --- M src/MediaWikiFarm.php 1 file changed, 19 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/89/299389/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 2cc8b40..873ab50 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -512,15 +512,20 @@ $this->params['globals'] = false; if( @filemtime( $cacheFile ) >= $oldness && is_string( $cacheFile ) ) { - $cache = @file_get_contents( $cacheFile ); - if ( $cache !== false ) { - $this->params['globals'] = unserialize( $cache ); + if( preg_match( '/\.php$/', $cacheFile ) ) { +$this->params['globals'] = @include $cacheFile; + } + else { + $cache = @file_get_contents( $cacheFile ); + if ( $cache !== false ) { + $this->params['globals'] = unserialize( $cache ); + } } } else { $this->params['globals'] = array(); - $globals &= $this->params['globals']; + $globals =& $this->params['globals']; $globals['general'] = array(); $globals['skins'] = array(); @@ -672,9 +677,16 @@ if( is_string( $cacheFile ) ) { @mkdir( dirname( $cacheFile ) ); $tmpFile = tempnam( dirname( $cacheFile ), basename( $cacheFile ).'.tmp' ); - chmod( $tmpFile, 0640 ); - if( $tmpFile && file_put_contents( $tmpFile, serialize( $globals ) ) ) { - rename( $tmpFile, $cacheFile ); + chmod( $tmpFile, 0744 ); + if( preg_match( '/\.php$/', $cacheFile ) ) { + if( $tmpFile && file_put_contents( $tmpFile, "https://gerrit.wikimedia.org/r/299389 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I387be3677765d9927d11e9142555b989f32cecb2 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] Fix for the previous commit - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299386 Change subject: Fix for the previous commit .. Fix for the previous commit --- M src/MediaWikiFarm.php 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/86/299386/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 3a7fd36..0cacff8 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -567,11 +567,9 @@ $myWiki = $this->wiki['wikiID']; $mySuffix = $this->wiki['suffix']; - $codeDir = $this->wiki['code']; $cacheFile = $this->wiki['cache']; //var_dump($wgConf); - //var_dump($codeDir); //var_dump($cacheFile); //var_dump($myWiki); //var_dump($mySuffix); @@ -599,6 +597,9 @@ foreach( $this->wiki['config'] as $configFile ) { + # Executable config files + if( array_key_exists( 'exec', $configFile ) ) continue; + $theseSettings = $this->readFile( $this->configDir . '/' . $configFile['file'] ); if( $theseSettings === false ) { $this->unusable = true; -- To view, visit https://gerrit.wikimedia.org/r/299386 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I99108386cba1cf9cc4a6053ab57502d149d53529 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] Changed location of exec-config to improve consistency of th... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299385 Change subject: Changed location of exec-config to improve consistency of the schema; strict verification of the JSON schema .. Changed location of exec-config to improve consistency of the schema; strict verification of the JSON schema --- M config/farms.json M config/farms.php M config/farms.yml M docs/farms-schema.json 4 files changed, 216 insertions(+), 144 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/85/299385/1 diff --git a/config/farms.json b/config/farms.json index 2bb3a5b..f40cfbc 100644 --- a/config/farms.json +++ b/config/farms.json @@ -22,9 +22,12 @@ { "file": "org/PrivateSettings.php", "key": "*" + }, + { + "file": "org/ExecSettings.php", + "exec": true } - ], - "exec-config": "org/ExecSettings.php" + ] }, "(?[a-z]+)-(?[a-z]+)\\.example\\.com": { "variables": [ @@ -53,9 +56,12 @@ { "file": "com/example/PrivateSettings.yml", "key": "*" + }, + { + "file": "com/example/ExecSettings.php", + "exec": true } - ], - "exec-config": "com/example/ExecSettings.php" + ] }, "(?[a-z]+)_(?[a-z]+)\\.example\\.com": { "redirect": "$client-$wiki.example.com" diff --git a/config/farms.php b/config/farms.php index 4755d74..dd138a9 100644 --- a/config/farms.php +++ b/config/farms.php @@ -25,8 +25,10 @@ array( 'file' => 'org/PrivateSettings.php', 'key' => '*' ), + array( 'file' => 'org/ExecSettings.php', + 'exec' => true + ), ), - 'exec-config' => 'org/ExecSettings.php', ), # Configuration for a small wiki farm @@ -55,8 +57,10 @@ array( 'file' => 'com/example/PrivateSettings.yml', 'key' => '*' ), + array( 'file' => 'com/example/ExecSettings.php', + 'exec' => true + ), ), - 'exec-config' => 'com/example/ExecSettings.php', ), # Aliases diff --git a/config/farms.yml b/config/farms.yml index 82a16cd..78fa067 100644 --- a/config/farms.yml +++ b/config/farms.yml @@ -18,7 +18,8 @@ key: '*' - file: 'org/PrivateSettings.php' key: '*' -exec-config: 'org/ExecSettings.php' + - file: 'org/ExecSettings.php' +exec: true # Configuration for a small wiki farm '(?[a-z]+)-(?[a-z]+)\.example\.com': @@ -42,7 +43,8 @@ key: '*' - file: 'com/example/PrivateSettings.yml' key: '*' -exec-config: 'com/example/ExecSettings.php' + - file: 'com/example/ExecSettings.php' +exec: true # Aliases diff --git a/docs/farms-schema.json b/docs/farms-schema.json index b852ac3..926be60 100644 --- a/docs/farms-schema.json +++ b/docs/farms-schema.json @@ -2,153 +2,213 @@ "$schema": "http://json-schema.org/draft-04/schema#";, "name": "Configuration of MediaWikiFarm extension to manage MediaWiki farms.", "type": "object", - "additionalProperties": true, + "additionalProperties": false, "patternProperties": { - "^[a-zA-Z0-9\\[\\]\\(\\)\\<>.*?+_-]+$": { - "type": "object", - "properties": { - "variables": { - "type": "array", - "description": "List of variables in the host.", - "additionalItems": false, - "items": [ - { - "type": "object", - "description": "An host variable.", - "properties": { - "variable": { - "type": "string", - "description": "Name of the host variable." +
[MediaWiki-commits] [Gerrit] Simplified setWikiPropertyValue by removing one argument - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299384 Change subject: Simplified setWikiPropertyValue by removing one argument .. Simplified setWikiPropertyValue by removing one argument --- M src/MediaWikiFarm.php 1 file changed, 40 insertions(+), 35 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/84/299384/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index f7f8a1c..3a7fd36 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -122,10 +122,10 @@ $this->wiki['version'] = null; $this->wiki['globals'] = null; - $this->setWikiProperty( 'suffix', false, true ); + $this->setWikiProperty( 'suffix', true ); $this->variables['suffix'] = $this->wiki['suffix']; - $this->setWikiProperty( 'wikiID', false, true ); + $this->setWikiProperty( 'wikiID', true ); $this->variables['wikiID'] = $this->wiki['wikiID']; if( !array_key_exists( 'wikiID', $this->wiki ) || !array_key_exists( 'suffix', $this->wiki ) ) { @@ -159,7 +159,7 @@ $this->wiki['code'] = $this->codeDir . '/' . $version; # In the case multiversion is configured, but version is not known as of now - else if( is_null( $version ) && is_string( $this->codeDir ) ) { + elseif( is_null( $version ) && is_string( $this->codeDir ) ) { $versions = $this->readFile( $this->config['versions'] ); @@ -171,10 +171,10 @@ if( array_key_exists( $this->wiki['wikiID'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->wiki['wikiID']] . '/includes/DefaultSettings.php' ) ) $version = $versions[$this->wiki['wikiID']]; - else if( $this->wiki['suffix'] && array_key_exists( $this->wiki['suffix'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->wiki['suffix']] . '/includes/DefaultSettings.php' ) ) + elseif( array_key_exists( $this->wiki['suffix'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->wiki['suffix']] . '/includes/DefaultSettings.php' ) ) $version = $versions[$this->wiki['suffix']]; - else if( array_key_exists( 'default', $versions ) && is_file( $this->codeDir . '/' . $versions['default'] . '/includes/DefaultSettings.php' ) ) + elseif( array_key_exists( 'default', $versions ) && is_file( $this->codeDir . '/' . $versions['default'] . '/includes/DefaultSettings.php' ) ) $version = $versions['default']; else return false; @@ -183,7 +183,7 @@ } # In the case no multiversion is configured - else if( is_null( $this->codeDir ) ) { + elseif( is_null( $this->codeDir ) ) { $version = $wgVersion; $this->wiki['code'] = $IP; @@ -210,14 +210,24 @@ if( $this->unusable ) return false; - $this->setWikiProperty( 'data', false ); - $this->setWikiProperty( 'cache', false ); - $this->setWikiProperty( 'config', true ); - $this->setWikiProperty( 'exec-config', true ); + if( !array_key_exists( 'config', $this->wiki ) ) + $this->wiki['config'] = array(); + elseif( is_string( $this->wiki['config'] ) ) + $this->wiki['config'] = array( $this->wiki['config'] ); + + if( !array_key_exists( 'exec-config', $this->wiki ) ) + $this->wiki['exec-config'] = array(); + elseif( is_string( $this->wiki['exec-config'] ) ) + $this->wiki['exec-config'] = array( $this->wiki['exec-config'] ); + + $this->setWikiProperty( 'data'); + $this->setWikiProperty( 'cache' ); + $this->setWikiProperty( 'config' ); + $this->setWikiProperty( 'exec-config' ); foreach( $this->wiki['variables'] as &$variable ) { - $this->setWikiPropertyValue( $variable['file'], false ); + $this->setWikiPropertyValue( $variable['file'] ); } return true; @@ -276,8 +286,8 @@ # Read the farm(s) configuration
[MediaWiki-commits] [Gerrit] [phpmd] Nullify 'unusedcode' ruleset; and by the way fix a m... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299381 Change subject: [phpmd] Nullify 'unusedcode' ruleset; and by the way fix a minor bug .. [phpmd] Nullify 'unusedcode' ruleset; and by the way fix a minor bug --- M src/MediaWikiFarm.php 1 file changed, 6 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/81/299381/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 12937ac..9ee7e19 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -235,7 +235,7 @@ $wgConf->suffixes = array( $this->wiki['suffix'] ); $wikiIDs = $this->readFile( $this->configDir . '/' . $this->wiki['suffix'] . '/wikis.yml' ); - foreach( $wikiIDs as $wiki => $value ) { + foreach( array_keys( $wikiIDs ) as $wiki ) { $wgConf->wikis[] = $wiki . '-' . $this->wiki['suffix']; } } @@ -374,7 +374,7 @@ $filename = $variable['file']; # Really check if the variable is in the listing file - $this->setWikiPropertyValue( $filename, false, false, true ); + $this->setWikiPropertyValue( $filename, false, true ); $choices = $this->readFile( $this->configDir . '/' . $filename ); if( $choices === false ) { $this->unusable = true; @@ -492,7 +492,7 @@ else return; } - $this->setWikiPropertyValue( $this->wiki[$name], $toArray, $create, $reset ); + $this->setWikiPropertyValue( $this->wiki[$name], $toArray, $reset ); } /** @@ -500,11 +500,10 @@ * * @param string|null $value Value of the property. * @param bool $toArray Change a string to an array with the string. -* @param bool $create Create the property the empty string if non-existent. * @param bool $reset Empty the variables internal cache after operation. * @return void */ - private function setWikiPropertyValue( &$value, $toArray = false, $create = false, $reset = false ) { + private function setWikiPropertyValue( &$value, $toArray = false, $reset = false ) { static $rkeys = array(), $rvalues = array(); if( count( $rkeys ) == 0 ) { @@ -818,7 +817,7 @@ wfLoadSkin( $skin ); - unset( $skins[$skin]['_loading'] ); + unset( $this->wiki['globals']['skins'][$skin]['_loading'] ); } // Set skin parameters as global variables @@ -851,7 +850,7 @@ wfLoadExtension( $extension ); - unset( $extensions[$extension]['_loading'] ); + unset( $this->wiki['globals']['extensions'][$extension]['_loading'] ); } // Set extension parameters as global variables -- To view, visit https://gerrit.wikimedia.org/r/299381 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5b5cd3c29a1847b70bfd498a3c907d6924e1af32 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] Simplify the function setWikiProperty by removing one almost... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299383 Change subject: Simplify the function setWikiProperty by removing one almost-unused argument ; simplify getMediaWikiConfig by splitting a part in an other function (NPath complexity from 826348 to 486092) .. Simplify the function setWikiProperty by removing one almost-unused argument ; simplify getMediaWikiConfig by splitting a part in an other function (NPath complexity from 826348 to 486092) --- M src/MediaWikiFarm.php 1 file changed, 55 insertions(+), 43 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/83/299383/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index b661fa9..f7f8a1c 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -122,18 +122,18 @@ $this->wiki['version'] = null; $this->wiki['globals'] = null; - $this->setWikiProperty( 'suffix', false, true, true ); + $this->setWikiProperty( 'suffix', false, true ); $this->variables['suffix'] = $this->wiki['suffix']; - $this->setWikiProperty( 'wikiID', false, false, true ); + $this->setWikiProperty( 'wikiID', false, true ); $this->variables['wikiID'] = $this->wiki['wikiID']; - if( !array_key_exists( 'wikiID', $this->wiki ) ) { + if( !array_key_exists( 'wikiID', $this->wiki ) || !array_key_exists( 'suffix', $this->wiki ) ) { $this->unusable = true; return false; } - if( !$this->wiki['wikiID'] ) + if( !$this->wiki['wikiID'] || !$this->wiki['suffix'] ) return false; return true; @@ -436,7 +436,6 @@ return false; try { - $array = Symfony\Component\Yaml\Yaml::parse( @file_get_contents( $filename ) ); } catch( Symfony\Component\Yaml\Exception\ParseException $e ) { @@ -460,14 +459,19 @@ return explode( "\n", $content ); } + + # Error for any other format else return false; + # Return an empty array if null (empty file or value 'null) if( is_null( $array ) ) return array(); + # Regular return for arrays elseif( is_array( $array ) ) return $array; + # Error for any other type return false; } @@ -476,17 +480,13 @@ * * @param string $name Name of the property. * @param bool $toArray Change a string to an array with the string. -* @param bool $create Create the property the empty string if non-existent. * @param bool $reset Empty the variables internal cache after operation. * @return void */ - private function setWikiProperty( $name, $toArray = false, $create = false, $reset = false ) { + private function setWikiProperty( $name, $toArray = false, $reset = false ) { - if( !array_key_exists( $name, $this->wiki ) ) { - - if( $create ) $this->wiki[$name] = ''; - else return; - } + if( !array_key_exists( $name, $this->wiki ) ) + return; $this->setWikiPropertyValue( $this->wiki[$name], $toArray, $reset ); } @@ -667,44 +667,29 @@ if( preg_match( '/^wgUseSkin(.+)$/', $setting, $matches ) && $value === true ) { $skin = $matches[1]; - if( is_dir( $codeDir.'/skins/'.$skin ) ) { - - $globals['skins'][$skin] = array(); - - if( is_file( $codeDir.'/skins/'.$skin.'/skin.json' ) ) { - $globals['skins'][$skin]['_loading'] = 'wfLoadSkin'; - } - elseif( is_file( $codeDir.'/skins/'.$skin.'/'.$skin.'.php' ) ) { - $globals['skins'][$skin]['_loading'] = 'require_once'; -
[MediaWiki-commits] [Gerrit] Homogeneisation of arrays: there is now only the 'params' ar... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299387 Change subject: Homogeneisation of arrays: there is now only the 'params' array instead of the previous 'config' and 'wiki' ; work to better manage variables .. Homogeneisation of arrays: there is now only the 'params' array instead of the previous 'config' and 'wiki' ; work to better manage variables Sadly, this commit decreases the performance from (mean) 10.2ms to 11.7ms, I don’t understand why but the rewrite is probably more important to even commit it. --- M src/MediaWikiFarm.php M src/main.php 2 files changed, 101 insertions(+), 139 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/87/299387/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 0cacff8..653c46a 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -36,13 +36,10 @@ public $unusable = false; /** @var array [private] Farm configuration file. */ - public $config = array(); + public $params = array(); - /** @var array [private] Variables inside the host. */ + /** @var array [private] Variables related to the current request. */ public $variables = array(); - - /** @var array Selected wiki. */ - public $wiki = array(); @@ -118,23 +115,22 @@ if( $this->unusable ) return false; - $this->wiki = $this->config; - $this->wiki['version'] = null; - $this->wiki['globals'] = null; + $this->params['version'] = null; + $this->params['globals'] = null; - $this->setWikiProperty( 'suffix', true ); - $this->variables['suffix'] = $this->wiki['suffix']; + # Set suffix + $this->setWikiProperty( 'suffix' ); + $this->variables['suffix'] = $this->params['suffix']; - $this->setWikiProperty( 'wikiID', true ); - $this->variables['wikiID'] = $this->wiki['wikiID']; + # Set wikiID + $this->setWikiProperty( 'wikiID' ); + $this->variables['wikiID'] = $this->params['wikiID']; - if( !array_key_exists( 'wikiID', $this->wiki ) || !array_key_exists( 'suffix', $this->wiki ) ) { + # Check consistency + if( !$this->params['suffix'] || !$this->params['wikiID'] ) { $this->unusable = true; return false; } - - if( !$this->wiki['wikiID'] || !$this->wiki['suffix'] ) - return false; return true; } @@ -156,37 +152,37 @@ # In the case multiversion is configured and version is already known if( is_string( $version ) && is_string( $this->codeDir ) && is_file( $this->codeDir . '/' . $version . '/includes/DefaultSettings.php' ) ) - $this->wiki['code'] = $this->codeDir . '/' . $version; + $this->params['code'] = $this->codeDir . '/' . $version; # In the case multiversion is configured, but version is not known as of now elseif( is_null( $version ) && is_string( $this->codeDir ) ) { - $versions = $this->readFile( $this->config['versions'] ); + $versions = $this->readFile( $this->params['versions'] ); if( !$versions ) { $this->unusable = true; return false; } - if( array_key_exists( $this->wiki['wikiID'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->wiki['wikiID']] . '/includes/DefaultSettings.php' ) ) - $version = $versions[$this->wiki['wikiID']]; + if( array_key_exists( $this->params['wikiID'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->params['wikiID']] . '/includes/DefaultSettings.php' ) ) + $version = $versions[$this->params['wikiID']]; - elseif( array_key_exists( $this->wiki['suffix'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->wiki['suffix']] . '/includes/DefaultSettings.php' ) ) - $version = $versions[$this->wiki['suffix']]; + elseif( array_key_exists( $this->params['suffix'], $versions ) && is_file( $this->codeDir . '/' . $versions[$this->params['suffix']] . '/includes/DefaultSettings.php'
[MediaWiki-commits] [Gerrit] [composer] Added phpmd as require-dev - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299380 Change subject: [composer] Added phpmd as require-dev .. [composer] Added phpmd as require-dev --- M composer.json M composer.lock 2 files changed, 168 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/80/299380/1 diff --git a/composer.json b/composer.json index 299a4a3..51528b8 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "require-dev": { "justinrainbow/json-schema": "*", "phpdocumentor/phpdocumentor": "*", - "jakub-onderka/php-parallel-lint": "*" + "jakub-onderka/php-parallel-lint": "*", + "phpmd/phpmd" : "*" }, "scripts": { "validate-schema": "php ./scripts/validate-schema.php", diff --git a/composer.lock b/composer.lock index 6f72c5f..dbc47a8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";, "This file is @generated automatically" ], -"hash": "b7a6ee60c9c2fffe98da86969717ad9f", -"content-hash": "92b7dcc8838aa83858834f366aedc67c", +"hash": "c4133552c61829812823b39328b0df7f", +"content-hash": "1704923f8317734c9f932ccf6afc", "packages": [ { "name": "symfony/yaml", @@ -917,6 +917,46 @@ "time": "2014-07-23 18:24:17" }, { +"name": "pdepend/pdepend", +"version": "2.2.4", +"source": { +"type": "git", +"url": "https://github.com/pdepend/pdepend.git";, +"reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06" +}, +"dist": { +"type": "zip", +"url": "https://api.github.com/repos/pdepend/pdepend/zipball/b086687f3a01dc6bb92d633aef071d2c5dd0db06";, +"reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06", +"shasum": "" +}, +"require": { +"php": ">=5.3.7", +"symfony/config": "^2.3.0|^3", +"symfony/dependency-injection": "^2.3.0|^3", +"symfony/filesystem": "^2.3.0|^3" +}, +"require-dev": { +"phpunit/phpunit": "^4.4.0,<4.8", +"squizlabs/php_codesniffer": "^2.0.0" +}, +"bin": [ +"src/bin/pdepend" +], +"type": "library", +"autoload": { +"psr-4": { +"PDepend\\": "src/main/php/PDepend" +} +}, +"notification-url": "https://packagist.org/downloads/";, +"license": [ +"BSD-3-Clause" +], +"description": "Official version of pdepend to be handled with Composer", +"time": "2016-03-10 15:15:04" +}, +{ "name": "phpcollection/phpcollection", "version": "0.4.0", "source": { @@ -1243,6 +1283,71 @@ "time": "2015-02-03 12:10:50" }, { +"name": "phpmd/phpmd", +"version": "2.4.2", +"source": { +"type": "git", +"url": "https://github.com/phpmd/phpmd.git";, +"reference": "fccbdb6b222f6d7a6d35af1c396ba5435cec76a9" +}, +"dist": { +"type": "zip", +"url": "https://api.github.com/repos/phpmd/phpmd/zipball/fccbdb6b222f6d7a6d35af1c396ba5435cec76a9";, +"reference": "fccbdb6b222f6d7a6d35af1c396ba5435cec76a9", +"shasum": "" +}, +"require": { +"pdepend/pdepend": "~2.0", +"php": ">=5.3.0" +}, +"require-dev": { +"phpunit/phpunit": "^4.0", +"squizlabs/php_codesniffer": "^2.0" +}, +"bin": [ +"src/bin/phpmd" +], +"type": "project", +"autoload": { +"psr-0": { +"PHPMD\\": "src/main/php" +} +}, +"notification-url": "https://packagist.org/downloads/";, +"license": [ +"BSD-3-Clause" +], +"authors": [ +{ +"name": "Manuel Pichler", +"email": "git...@manuel-pichler.de", +"homepage": "https://github.com/manuelpichler";, +"role": "Project Founder" +}, +{ +"name": "Other contributors", +"homepage": "https://github.com/phpmd/phpmd/graphs/contributor
[MediaWiki-commits] [Gerrit] Decrease cyclomatic complexity of readFile from 648 to 90 ; ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299382 Change subject: Decrease cyclomatic complexity of readFile from 648 to 90 ; better management of empty files .. Decrease cyclomatic complexity of readFile from 648 to 90 ; better management of empty files --- M src/MediaWikiFarm.php 1 file changed, 15 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/82/299382/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 9ee7e19..b661fa9 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -424,17 +424,13 @@ # Note the regex must be greedy to correctly select double extensions $format = preg_replace( '/^.*\.([a-z]+)$/', '$1', $filename ); - if( $format == 'php' ) { + # Format PHP + if( $format == 'php' ) $array = @include $filename; - - if( !is_array( $array ) ) - return false; - - return $array; - } - if( $format == 'yml' || $format == 'yaml' ) { + # Format YAML + elseif( $format == 'yml' || $format == 'yaml' ) { if( !class_exists( 'Symfony\Component\Yaml\Yaml' ) ) return false; @@ -442,10 +438,6 @@ try { $array = Symfony\Component\Yaml\Yaml::parse( @file_get_contents( $filename ) ); - if( !is_array( $array ) ) - return false; - - return $array; } catch( Symfony\Component\Yaml\Exception\ParseException $e ) { @@ -453,16 +445,13 @@ } } - if( $format == 'json' ) { + # Format JSON + elseif( $format == 'json' ) $array = json_decode( @file_get_contents( $filename ), true ); - if( !is_array( $array ) ) - return false; - - return $array; - } - if( $format == 'dblist' ) { + # Format dblist (simple list of strings separated by newlines) + elseif( $format == 'dblist' ) { $content = @file_get_contents( $filename ); @@ -471,6 +460,13 @@ return explode( "\n", $content ); } + else return false; + + if( is_null( $array ) ) + return array(); + + elseif( is_array( $array ) ) + return $array; return false; } -- To view, visit https://gerrit.wikimedia.org/r/299382 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1ca2a2fa6a5d5741d19a8d65b48545e58d595f8f 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] Added JSON format, soften requirement on YAML (possibly it i... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299370 Change subject: Added JSON format, soften requirement on YAML (possibly it is not installed and it works fine). .. Added JSON format, soften requirement on YAML (possibly it is not installed and it works fine). --- M src/MediaWikiFarm.php 1 file changed, 20 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/70/299370/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 0c1cbbf..d95e7f9 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -10,7 +10,7 @@ # Protect against web entry if( !defined( 'MEDIAWIKI' ) ) exit; -require_once __DIR__ . '/../vendor/autoload.php'; +@include_once __DIR__ . '/../vendor/autoload.php'; /** * This class computes the configuration of a specific wiki from a set of configuration files. @@ -272,6 +272,7 @@ # Read the farm(s) configuration if( $configs = $this->readFile( $this->configDir . '/farms.yml' ) ); + else if( $configs = $this->readFile( $this->configDir . '/farms.json' ) ); else if( $configs = $this->readFile( $this->configDir . '/farms.php' ) ); else $this->unusable = true; @@ -380,9 +381,9 @@ * --- */ /** -* Read a file either in PHP, YAML, or dblist, and returns the interpreted array. +* Read a file either in PHP, YAML (if library available), JSON, or dblist, and returns the interpreted array. * -* The choice between the format depends on the extension: php, yml, dblist. +* The choice between the format depends on the extension: php, yml, yaml, json, dblist. * * @param string $filename Name of the requested file. * @return array|false The interpreted array in case of success, else false. @@ -399,7 +400,7 @@ if( $format == 'php' ) { - $array = require $filename; + $array = @include $filename; if( !is_array( $array ) ) return false; @@ -407,22 +408,34 @@ return $array; } - if( $format == 'yml' ) { + if( $format == 'yml' || $format == 'yaml' ) { + + if( !class_exists( 'Symfony\Component\Yaml\Yaml' ) ) + return false; try { - $array = \Symfony\Component\Yaml\Yaml::parse( file_get_contents( $filename ) ); + $array = Symfony\Component\Yaml\Yaml::parse( file_get_contents( $filename ) ); if( !is_array( $array ) ) return false; return $array; } - catch( \Symfony\Component\Yaml\Exception\ParseException $e ) { + catch( Symfony\Component\Yaml\Exception\ParseException $e ) { return false; } } + if( $format == 'json' ) { + + $array = json_decode( file_get_contents( $filename ), true ); + if( !is_array( $array ) ) + return false; + + return $array; + } + if( $format == 'dblist' ) { $content = file_get_contents( $filename ); -- To view, visit https://gerrit.wikimedia.org/r/299370 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I607c0754224c655ee3a65268b346b7814d03d18f 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] Improved rights management in MediaWiki config files - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299373 Change subject: Improved rights management in MediaWiki config files .. Improved rights management in MediaWiki config files This can be considered as the last important part, which is now finished and the extension can thereof be considered mostly finished. --- M config/farms.php M config/farms.yml M src/MediaWikiFarm.php 3 files changed, 84 insertions(+), 66 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/73/299373/1 diff --git a/config/farms.php b/config/farms.php index b0bfc49..79aeee2 100644 --- a/config/farms.php +++ b/config/farms.php @@ -19,8 +19,12 @@ 'data' => '/srv/data/org/$family/$lang', 'cache' => '/tmp/mw-cache/org-$version-$family-$lang', 'config' => array( - 'org/InitialiseSettings.php', - 'org/PrivateSettings.php', + array( 'file' => 'org/InitialiseSettings.php', + 'key' => '*' + ), + array( 'file' => 'org/PrivateSettings.php', + 'key' => '*' + ), ), 'exec-config' => 'org/ExecSettings.php', ), @@ -42,9 +46,15 @@ 'data' => '/srv/data/com/example/$client/$wiki', 'cache' => '/tmp/mw-cache/com-example-$version-$client-$wiki', 'config' => array( - 'com/example/InitialiseSettings.yml', - 'com/example/PrivateSettings.yml', - 'com/example/GlobalSettings.yml', + array( 'file' => 'com/example/DefaultSettings.yml', + 'key' => 'default' + ), + array( 'file' => 'com/example/InitialiseSettings.yml', + 'key' => '*' + ), + array( 'file' => 'com/example/PrivateSettings.yml', + 'key' => '*' + ), ), 'exec-config' => 'com/example/ExecSettings.php', ), diff --git a/config/farms.yml b/config/farms.yml index f621328..e98a14d 100644 --- a/config/farms.yml +++ b/config/farms.yml @@ -14,8 +14,10 @@ data: '/srv/data/org/$family/$lang' cache: '/tmp/mw-cache/org-$version-$family-$lang' config: - - 'org/InitialiseSettings.php' - - 'org/PrivateSettings.php' + - file: 'org/InitialiseSettings.php' +key: '*' + - file: 'org/PrivateSettings.php' +key: '*' exec-config: 'org/ExecSettings.php' # Configuration for a small wiki farm @@ -34,7 +36,10 @@ data: '/srv/data/com/example/$client/$wiki' cache: '/tmp/mw-cache/com-example-$version-$client-$wiki' config: - - 'com/example/InitialiseSettings.yml' - - 'com/example/PrivateSettings.yml' - - 'com/example/GlobalSettings.yml' + - file: 'com/example/DefaultSettings.yml' +key: 'default' + - file: 'com/example/InitialiseSettings.yml' +key: '*' + - file: 'com/example/PrivateSettings.yml' +key: '*' exec-config: 'com/example/ExecSettings.php' diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index a6ac74a..ef75cc6 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -411,7 +411,7 @@ try { - $array = Symfony\Component\Yaml\Yaml::parse( file_get_contents( $filename ) ); + $array = Symfony\Component\Yaml\Yaml::parse( @file_get_contents( $filename ) ); if( !is_array( $array ) ) return false; @@ -425,7 +425,7 @@ if( $format == 'json' ) { - $array = json_decode( file_get_contents( $filename ), true ); + $array = json_decode( @file_get_contents( $filename ), true ); if( !is_array( $array ) ) return false; @@ -434,7 +434,7 @@ if( $format == 'dblist' ) { - $content = file_get_contents( $filename ); + $content = @file_get_contents( $filename ); if( !$content ) return array(); @@ -512,20 +512,8 @@ /** * Get or compute the configuration (MediaWiki, skins, extensions) for a wiki. * -* You have to specify the wiki, the suffix, and the version and, as parame
[MediaWiki-commits] [Gerrit] Resynchronised composer.lock - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299366 Change subject: Resynchronised composer.lock .. Resynchronised composer.lock --- M composer.lock 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/66/299366/1 diff --git a/composer.lock b/composer.lock index 2b7809b..73fdfb7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";, "This file is @generated automatically" ], -"hash": "9bc7830f38ef93c96be4b87ff4879e6e", -"content-hash": "626d7ef5ec2cb32172de65e20eea40df", +"hash": "8be9b590f4642af5415d041a1e1ca8e7", +"content-hash": "ce75a62d6bb1e89da21cf1a12f4216ae", "packages": [ { "name": "symfony/yaml", @@ -2739,7 +2739,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { -"php": ">=5.5.3" +"php": ">=5.5" }, "platform-dev": [] } -- To view, visit https://gerrit.wikimedia.org/r/299366 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7ea00d78f8ab493ed323e81ae7595c4dd8baa51e 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] Added a doc about performance (only to give an idea, the pro... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299374 Change subject: Added a doc about performance (only to give an idea, the protocol used is not strong) .. Added a doc about performance (only to give an idea, the protocol used is not strong) --- A docs/performance.txt 1 file changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/74/299374/1 diff --git a/docs/performance.txt b/docs/performance.txt new file mode 100644 index 000..f74797d --- /dev/null +++ b/docs/performance.txt @@ -0,0 +1,30 @@ +Performance +=== + +Method +-- + +Added microtime(true) at the top and bottom of the file LocalSettings.php. + +On a fresh MediaWiki installation. +The only skin installed was Vector. +No extensions were installed. + +The figures were obtained by loading about 15-20 times a same page, and the mean and standard deviation were estimated. +Obviously a stronger sampling protocol and computation would be better, but this only aims at giving a raw idea of the results. + + +Figures +--- + +* Classical LocalSettings.php: + +mean = 2.7ms std = 0.2ms + +* LocalSettings.php with only MediaWikiFarm extension without cache: + +mean = 11.6ms std = 1.0ms + +* LocalSettings.php with only MediaWikiFarm extension with cache: + +mean = 8.1ms std = 1.0ms -- To view, visit https://gerrit.wikimedia.org/r/299374 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I62c640e032b8a69d411faa91ca61da191aa311cd 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] Remove oddities with (wiki-)config files: now only one list ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299371 Change subject: Remove oddities with (wiki-)config files: now only one list of (wiki-)config files .. Remove oddities with (wiki-)config files: now only one list of (wiki-)config files --- M src/MediaWikiFarm.php 1 file changed, 3 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/71/299371/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index d95e7f9..a6ac74a 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -210,15 +210,11 @@ $this->setWikiProperty( 'data', false ); $this->setWikiProperty( 'cache', false ); $this->setWikiProperty( 'config', true ); - $this->setWikiProperty( 'post-config', true ); $this->setWikiProperty( 'exec-config', true ); foreach( $this->wiki['variables'] as &$variable ) { $this->setWikiPropertyValue( $variable['file'], false ); - $this->setWikiPropertyValue( $variable['config'], true ); - $this->setWikiPropertyValue( $variable['post-config'], true ); - $this->setWikiPropertyValue( $variable['exec-config'], true ); } return true; @@ -497,7 +493,7 @@ if( $toArray ) $value = array( $value ); else $value = preg_replace( $rkeys, $rvalues, $value ); } - else { + else if( !is_array( $value ) ) { $this->unusable = true; return; @@ -559,8 +555,8 @@ $codeDir = $this->wiki['code']; $cacheFile = $this->wiki['cache']; $generalYamlFilename = '/'.$this->wiki['config'][0]; - $suffixedYamlFilename = '/'.$this->wiki['variables'][0]['config'][0]; - $privateYamlFilename = '/'.$this->wiki['post-config'][0]; + $suffixedYamlFilename = '/'.$this->wiki['config'][1]; + $privateYamlFilename = '/'.$this->wiki['config'][2]; //var_dump($wgConf); //var_dump($codeDir); -- To view, visit https://gerrit.wikimedia.org/r/299371 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9343b16dc845a5a7fe072b568a23769a7c524197 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] Updated config files accordingly with the previous commit - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299372 Change subject: Updated config files accordingly with the previous commit .. Updated config files accordingly with the previous commit --- M config/farms.php M config/farms.yml 2 files changed, 6 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/72/299372/1 diff --git a/config/farms.php b/config/farms.php index e7ff326..b0bfc49 100644 --- a/config/farms.php +++ b/config/farms.php @@ -15,7 +15,7 @@ ), 'suffix' => '$family', 'wikiID' => '$lang$family', - 'versions' => 'wikiversions.yml', + 'versions' => 'wikiversions.json', 'data' => '/srv/data/org/$family/$lang', 'cache' => '/tmp/mw-cache/org-$version-$family-$lang', 'config' => array( @@ -32,7 +32,6 @@ array( 'variable' => 'client', 'file' => 'com/example/clients.yml', - 'config' => 'com/example/$client/InitialiseSettings.yml', ), array( 'variable' => 'wiki', 'file' => 'com/example/$client/wikis.yml', @@ -42,8 +41,8 @@ 'wikiID' => '$wiki-$client', 'data' => '/srv/data/com/example/$client/$wiki', 'cache' => '/tmp/mw-cache/com-example-$version-$client-$wiki', - 'config' => 'com/example/InitialiseSettings.yml', - 'post-config' => array( + 'config' => array( + 'com/example/InitialiseSettings.yml', 'com/example/PrivateSettings.yml', 'com/example/GlobalSettings.yml', ), diff --git a/config/farms.yml b/config/farms.yml index e53442c..f621328 100644 --- a/config/farms.yml +++ b/config/farms.yml @@ -10,7 +10,7 @@ suffix: '$family' wikiID: '$lang$family' -versions: 'wikiversions.yml' +versions: 'wikiversions.json' data: '/srv/data/org/$family/$lang' cache: '/tmp/mw-cache/org-$version-$family-$lang' config: @@ -25,7 +25,6 @@ - variable: 'client' file: 'com/example/clients.yml' - config: 'com/example/$client/InitialiseSettings.yml' - variable: 'wiki' file: 'com/example/$client/wikis.yml' @@ -34,8 +33,8 @@ wikiID: '$wiki-$client' data: '/srv/data/com/example/$client/$wiki' cache: '/tmp/mw-cache/com-example-$version-$client-$wiki' -config: 'com/example/InitialiseSettings.yml' -post-config: +config: + - 'com/example/InitialiseSettings.yml' - 'com/example/PrivateSettings.yml' - 'com/example/GlobalSettings.yml' exec-config: 'com/example/ExecSettings.php' -- To view, visit https://gerrit.wikimedia.org/r/299372 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6d4a6bd75c7a1dd1be64a83b64a55664283acdc2 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] Documentation - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299376 Change subject: Documentation .. Documentation --- M src/MediaWikiFarm.php 1 file changed, 7 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/76/299376/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 21ffcc3..de3d641 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -98,6 +98,7 @@ if( !$this->setWikiProperties() ) return false; + # Set available suffixes and wikis $this->setWgConf(); return true; @@ -220,11 +221,16 @@ return true; } + /** +* Set available suffixes and wikis. +* +* @todo Still hacky: before setting parameters in stone in farms.yml, various configurations should be reviewed to select accordingly the rights management modelisation +* @return void +*/ function setWgConf() { global $wgConf; - // TODO Still hacky: before setting parameters in stone in farms.yml, various configurations should be reviewed to select accordingly the rights management modelisation $wgConf->suffixes = array( $this->wiki['suffix'] ); $wikiIDs = $this->readFile( $this->configDir . '/' . $this->wiki['suffix'] . '/wikis.yml' ); foreach( $wikiIDs as $wiki => $value ) { -- To view, visit https://gerrit.wikimedia.org/r/299376 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I34f13007c990760d16d95d5c062435694e5004c7 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] Improved management of identifiers/variables, I think it is ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299369 Change subject: Improved management of identifiers/variables, I think it is ready for this part .. Improved management of identifiers/variables, I think it is ready for this part --- M config/farms.php M config/farms.yml M src/MediaWikiFarm.php M src/main.php 4 files changed, 246 insertions(+), 120 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/69/299369/1 diff --git a/config/farms.php b/config/farms.php index 4a196fc..e7ff326 100644 --- a/config/farms.php +++ b/config/farms.php @@ -3,7 +3,7 @@ return array( # Configuration similar to the Wikimedia farm - '(?[a-z]+)\.(?[a-z]+)\.org' => array( + '(?[a-z-]+)\.(?[a-z]+)\.org' => array( 'variables' => array( @@ -11,11 +11,11 @@ ), array( 'variable' => 'lang', 'file' => 'org/$family.dblist', - 'type' => 'language', ), ), 'suffix' => '$family', 'wikiID' => '$lang$family', + 'versions' => 'wikiversions.yml', 'data' => '/srv/data/org/$family/$lang', 'cache' => '/tmp/mw-cache/org-$version-$family-$lang', 'config' => array( diff --git a/config/farms.yml b/config/farms.yml index 6e733b9..e53442c 100644 --- a/config/farms.yml +++ b/config/farms.yml @@ -1,5 +1,5 @@ # Configuration similar to the Wikimedia farm -'(?[a-z]+)\.(?[a-z]+)\.org': +'(?[a-z-]+)\.(?[a-z]+)\.org': variables: @@ -7,10 +7,10 @@ - variable: 'lang' file: 'org/$family.dblist' - type: 'language' suffix: '$family' wikiID: '$lang$family' +versions: 'wikiversions.yml' data: '/srv/data/org/$family/$lang' cache: '/tmp/mw-cache/org-$version-$family-$lang' config: diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index fecaaf0..0c1cbbf 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -41,7 +41,7 @@ /** @var array [private] Variables inside the host. */ public $variables = array(); - /** @var array [private] Selected MediaWiki version. */ + /** @var array Selected wiki. */ public $wiki = array(); @@ -69,99 +69,143 @@ /** * Check the existence of the wiki, given variables values and files listing existing wikis. * -* A wiki exists if all variables are defined in the URL and all values are found in the -* corresponding listing file. Files can be in PHP, YAML, or dblist. +* A wiki exists if: +* - variables with a file attached are defined, and +* - a wikiID can be computed, and +* - a version is found and does exist, and +* - the various properties of the wiki are defined. * -* @return bool The wiki exists. +* @return bool The wiki does exist. */ function checkExistence() { - - global $IP, $wgVersion; if( $this->unusable ) return false; - $keys = array(); - $values = array(); - $version = null; - - # For each variable, in the given order, check if the variable exists, check if the - # wiki exists in the corresponding listing file, and get the version if available - foreach( $this->config['variables'] as $variable ) { - - $key = $variable['variable']; - - # If the variable doesn’t exist, continue - if( !array_key_exists( $key, $this->variables ) ) - continue; - - # Possibly the variables up to this one can be placeholders in filenames - $value = $this->variables[$key]; - $keys[] = '/\$' . preg_quote( $key, '/' ) . '/'; - $values[] = $value; - - # If every values are correct, continue - if( !array_key_exists( 'file', $variable ) ) - continue; - - # Really check if the variable is in the listing file - $choices = $this->readFile( $this->configDir . '/' . preg_replace( $keys, $values, $variable['file'] ) ); - if( $choices === false ) - return false; - - # Che
[MediaWiki-commits] [Gerrit] Do not fill suffixes and wikis in $wgConf (unuseful) - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299378 Change subject: Do not fill suffixes and wikis in $wgConf (unuseful) .. Do not fill suffixes and wikis in $wgConf (unuseful) --- M src/MediaWikiFarm.php 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/78/299378/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index de3d641..7826b57 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -99,7 +99,9 @@ return false; # Set available suffixes and wikis - $this->setWgConf(); + // 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(); return true; } -- To view, visit https://gerrit.wikimedia.org/r/299378 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id3409157ac8d04d5a867c9f7320fb29e56f94ac0 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] New feature: (internal) redirects - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299375 Change subject: New feature: (internal) redirects .. New feature: (internal) redirects --- M config/farms.php M config/farms.yml M src/MediaWikiFarm.php 3 files changed, 35 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/75/299375/1 diff --git a/config/farms.php b/config/farms.php index 79aeee2..d269636 100644 --- a/config/farms.php +++ b/config/farms.php @@ -58,4 +58,11 @@ ), 'exec-config' => 'com/example/ExecSettings.php', ), + + # Aliases + + '(?[a-z]+)_(?[a-z]+)\.example\.com' => array( + + 'redirect' => '$client-$wiki.example.com', + ), ); diff --git a/config/farms.yml b/config/farms.yml index e98a14d..82a16cd 100644 --- a/config/farms.yml +++ b/config/farms.yml @@ -43,3 +43,9 @@ - file: 'com/example/PrivateSettings.yml' key: '*' exec-config: 'com/example/ExecSettings.php' + +# Aliases + +'(?[a-z]+)_(?[a-z]+)\.example\.com': + +redirect: '$client-$wiki.example.com' diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index ef75cc6..21ffcc3 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -288,6 +288,12 @@ if( $this->unusable ) return false; + static $redirects = 0; + if( $redirects >= 5 ) { + $this->unusable = true; + return false; + } + # Check parameters if( !isset( $configs ) || !is_array( $configs ) ) return false; @@ -300,6 +306,22 @@ if( preg_match( '/' . $regex . '/', $host, $matches ) ) { + # Redirect + if( array_key_exists( 'redirect', $config ) ) { + + $keys = array(); + $values = array(); + foreach( $matches as $key => $value ) { + if( is_string( $key ) ) { + $keys[] = '/\$' . preg_quote( $key, '/' ) . '/'; + $values[] = $value; + } + } + + $redirects++; + return $this->selectFarm( $configs, preg_replace( $keys, $values, $config['redirect'] ) ); + } + # Get the selected configuration $this->config = $config; $this->variables = array(); -- To view, visit https://gerrit.wikimedia.org/r/299375 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9a6a24803568c2347b3ce63bf9d9e076f2d51892 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] Add Packagist package jakub-onderka/php-parallel-lint as req... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299377 Change subject: Add Packagist package jakub-onderka/php-parallel-lint as require-dev, added other versions for symfony/yaml and phpdocumentor/phpdocumentor .. Add Packagist package jakub-onderka/php-parallel-lint as require-dev, added other versions for symfony/yaml and phpdocumentor/phpdocumentor --- M composer.json M composer.lock 2 files changed, 68 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/77/299377/1 diff --git a/composer.json b/composer.json index 23b5779..c3958b5 100644 --- a/composer.json +++ b/composer.json @@ -12,18 +12,15 @@ "license": "GPL-3.0+", "require": { "php": ">=5.5", - "symfony/yaml": "~2.7" + "symfony/yaml": "^2.0 || ^3.0" }, "require-dev": { - "phpdocumentor/phpdocumentor": "2.*" + "phpdocumentor/phpdocumentor": "*", + "jakub-onderka/php-parallel-lint": "*" }, - "suggest": { - }, - "autoload": { - }, - "autoload-dev": { - }, + "prefer-lowest": true, "scripts": { - "phpdoc": "./vendor/bin/phpdoc -d ./src -t ./docs/code" + "phpdoc": "./vendor/bin/phpdoc -d ./src -t ./docs/code", + "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor ." } } diff --git a/composer.lock b/composer.lock index 73fdfb7..581898d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,30 +4,30 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";, "This file is @generated automatically" ], -"hash": "8be9b590f4642af5415d041a1e1ca8e7", -"content-hash": "ce75a62d6bb1e89da21cf1a12f4216ae", +"hash": "ff6554a09feaa09bf86916943b2ac71c", +"content-hash": "421b4c11221cc24d15683fcf41cead89", "packages": [ { "name": "symfony/yaml", -"version": "v2.8.3", +"version": "v3.0.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git";, -"reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995" +"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c" }, "dist": { "type": "zip", -"url": "https://api.github.com/repos/symfony/yaml/zipball/2a4ee40acb880c56f29fb1b8886e7ffe94f3b995";, -"reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995", +"url": "https://api.github.com/repos/symfony/yaml/zipball/b5ba64cd67ecd6887f63868fa781ca094bd1377c";, +"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c", "shasum": "" }, "require": { -"php": ">=5.3.9" +"php": ">=5.5.9" }, "type": "library", "extra": { "branch-alias": { -"dev-master": "2.8-dev" +"dev-master": "3.0-dev" } }, "autoload": { @@ -54,7 +54,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com";, -"time": "2016-02-23 07:41:20" +"time": "2016-02-23 15:16:06" } ], "packages-dev": [ @@ -480,6 +480,53 @@ "update" ], "time": "2013-10-30 17:23:01" +}, +{ +"name": "jakub-onderka/php-parallel-lint", +"version": "v0.9.2", +"source": { +"type": "git", +"url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git";, +"reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa" +}, +"dist": { +"type": "zip", +"url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/2ead2e4043ab125bee9554f356e0a86742c2d4fa";, +"reference": "2ead2e4043ab125bee9554f356e0a86742c2d4fa", +"shasum": "" +}, +"require": { +"php": ">=5.3.3" +}, +"require-dev": { +"jakub-onderka/php-console-highlighter": "~0.3", +"nette/tester": "~1.3" +}, +"suggest": { +"jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet" +}, +"bin": [ +"parallel-lint" +], +"type": "library", +"autoload": { +"classmap": [ +"./" +] +}, +"notification-url": "https://packagist.org/downloa
[MediaWiki-commits] [Gerrit] Added a JSON schema of config/farms.[yml|json|php], added co... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299379 Change subject: Added a JSON schema of config/farms.[yml|json|php], added config/farms.json, added a script to validate these config files .. Added a JSON schema of config/farms.[yml|json|php], added config/farms.json, added a script to validate these config files --- M composer.json M composer.lock A config/farms.json M config/farms.php A docs/farms-schema.json A scripts/validate-schema.php M src/MediaWikiFarm.php 7 files changed, 281 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/79/299379/1 diff --git a/composer.json b/composer.json index c3958b5..299a4a3 100644 --- a/composer.json +++ b/composer.json @@ -15,11 +15,12 @@ "symfony/yaml": "^2.0 || ^3.0" }, "require-dev": { + "justinrainbow/json-schema": "*", "phpdocumentor/phpdocumentor": "*", "jakub-onderka/php-parallel-lint": "*" }, - "prefer-lowest": true, "scripts": { + "validate-schema": "php ./scripts/validate-schema.php", "phpdoc": "./vendor/bin/phpdoc -d ./src -t ./docs/code", "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor ." } diff --git a/composer.lock b/composer.lock index 581898d..6f72c5f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";, "This file is @generated automatically" ], -"hash": "ff6554a09feaa09bf86916943b2ac71c", -"content-hash": "421b4c11221cc24d15683fcf41cead89", +"hash": "b7a6ee60c9c2fffe98da86969717ad9f", +"content-hash": "92b7dcc8838aa83858834f366aedc67c", "packages": [ { "name": "symfony/yaml", diff --git a/config/farms.json b/config/farms.json new file mode 100644 index 000..2bb3a5b --- /dev/null +++ b/config/farms.json @@ -0,0 +1,63 @@ +{ + "(?[a-z-]+)\\.(?[a-z]+)\\.org": { + "variables": [ + { + "variable": "family" + }, + { + "variable": "lang", + "file": "org/$family.dblist" + } + ], + "suffix": "$family", + "wikiID": "$lang$family", + "versions": "wikiversions.json", + "data": "/srv/data/org/$family/$lang", + "cache": "/tmp/mw-cache/org-$version-$family-$lang", + "config": [ + { + "file": "org/InitialiseSettings.php", + "key": "*" + }, + { + "file": "org/PrivateSettings.php", + "key": "*" + } + ], + "exec-config": "org/ExecSettings.php" + }, + "(?[a-z]+)-(?[a-z]+)\\.example\\.com": { + "variables": [ + { + "variable": "client", + "file": "com/example/clients.yml" + }, + { + "variable": "wiki", + "file": "com/example/$client/wikis.yml" + } + ], + "suffix": "$client", + "wikiID": "$wiki-$client", + "data": "/srv/data/com/example/$client/$wiki", + "cache": "/tmp/mw-cache/com-example-$version-$client-$wiki", + "config": [ + { + "file": "com/example/DefaultSettings.yml", + "key": "default" + }, + { + "file": "com/example/InitialiseSettings.yml", + "key": "*" + }, + { + "file": "com/example/PrivateSettings.yml", + "key": "*" + } + ], + "exec-config": "com/example/ExecSettings.php" + }, + "(?[a-z]+)_(?[a-z]+)\\.example\\.com": { + "redirect": "$client-$wiki.example.com" + } +} diff --git a/config/farms.php b/config/farms.php index d269636..4755d74 100644 --- a/config/farms.php +++ b/config/farms.php @@ -41,7 +41,7 @@ 'file' => 'com/example/$client/wikis.yml', ), ), - 'suffix' => '$family', + 'suffix' => '$client', 'wikiID' => '$wiki-$c
[MediaWiki-commits] [Gerrit] New file src/main.php are the loading steps are executed in ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299363 Change subject: New file src/main.php are the loading steps are executed in a global scope, improve homogeneity inside the class MediaWikiFarm .. New file src/main.php are the loading steps are executed in a global scope, improve homogeneity inside the class MediaWikiFarm The global scrope is required for extensions (and skins) using $wgMyConfigParameter = stuff. Nowadays most last versions of MediaWiki extensions do use the better syntax $GLOBALS['wgMyConfigParameter'] = stuff, or, still better, use the MediaWiki loading mechanism (wfLoadExtension/wfLoadSkin), but the loading in the global scrope is used here for compatibility with old extensions or old versions of extensions. This extension does work as of this version, although some work is still needed to better manage the suffixes and wiki sets (of the MediaWiki SiteConfiguration context), allowing to view and configure wikis by sets and subsets. --- M MediaWikiFarm.php M src/MediaWikiFarm.php A src/main.php 3 files changed, 294 insertions(+), 193 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/63/299363/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index 2d73a8b..02b9684 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -9,129 +9,45 @@ * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version ultérieure */ - # Protect against web entry -if ( !defined( 'MEDIAWIKI' ) ) { - exit; -} +if( !defined( 'MEDIAWIKI' ) ) exit; + +/* + * Parameters + * == */ /** * Configuration directory. * + * Type: string (path). + * * This parameter should be specified in your LocalSettings.php, before the require_once. - * The value must be a readable directory. It is recommended this directory is not readable - * from the Web. + * The value must be a readable directory. Depending of your openness policy, you could + * publish all or parts of the configuration files, but probably you don’t want to publish + * private informations like database configuration, upgrade key, etc. */ $wgMediaWikiFarmConfigDir = '/etc/mediawiki'; - - - - /** - * Code. + * Code directory. * - * Please do not remove the following lines. + * Type: string|null (path). + * + * If your farm can manage multiple MediaWiki versions, set this parameter to a directory + * where each subdirectory is a MediaWiki installation in a given version+flavour. Although + * it is probably easier to name the subdirectories with the MediaWiki version, the names + * are entirely independent from the real version inside the subdirectory. */ - -require_once "$IP/extensions/MediaWikiFarm/src/MediaWikiFarm.php"; - -$wgMediaWikiFarm = MediaWikiFarm::initialise( $GLOBALS['_SERVER']['HTTP_HOST'] ); +$wgMediaWikiFarmCodeDir = null; -# Create a MediaWiki farm -//$farm = new MediaWikiFarm( $wgMediaWikiFarmConfigDir, $wgMediaWikiFarmCodeDir ); - -# Select the wiki given the HTTP Host -//$farm->selectWikiFromHost( $GLOBALS['_SERVER']['HTTP_HOST'] ); - -# Select the configuration and export it -//$farm->getConfig(); - -var_dump( $wgMediaWikiFarm );echo "\n\n"; - -# Get client and wiki - -$wvgClient = $wgMediaWikiFarm->variables['client']; -$wvgWiki = $wgMediaWikiFarm->variables['wiki']; - -var_dump( $wvgClient ); -var_dump( $wvgWiki ); -echo "\n\n"; -# Check existence +/* + *Code + * == */ -var_dump( $wgMediaWikiFarm->checkExistence() ); -echo "\n\n"; - -if( !$wgMediaWikiFarm->checkExistence() ) { - - echo 'Error: unknown wiki.'; - exit; -} - - -$wgConf->suffixes = array( $wvgClient ); - -// Wikis: a simple list of the wikis for the requested client, e.g. array( 'da', 'cv' ) -$wvgClientWikis = $wgMediaWikiFarm->readFile( $wgMediaWikiFarmConfigDir.'/'.$wvgClient.'/wikis.yml' ); -$wvgVersion = false; -foreach( $wvgClientWikis as $wiki => $value ) { - $wgConf->wikis[] = $wiki.'-'.$wvgClient; -} - -// Get version -$wvgVersion = $wvgClientWikis[$wvgWiki]; - -if( !preg_match( '/^1\.\d{1,2}/', $wvgVersion ) ) { - echo 'Error: unknown wiki.'; - exit; -} - -exit; - -// Obtain the global configuration -$wvgGlobals = MediaWikiFarm::getMediaWikiConfig( $wvgWiki, $wvgClient, $wvgVersion, $wgConf, - array( 'codeDir' => $wgMediaWikiFarmCodeDir, -'cacheFile' => '/tmp/mw-cache/conf-$version-$wiki-$suffix', -'generalYamlFilename' => '/InitialiseSettings.yml', -'suffixedYamlFilename' => '/$suffix/InitialiseSettings.yml', -'privateYamlFilename' => '/PrivateSettings.yml', -
[MediaWiki-commits] [Gerrit] [WIP] Improved early selection of a farm and a wiki, properl... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299361 Change subject: [WIP] Improved early selection of a farm and a wiki, properly checked the existence of the wiki .. [WIP] Improved early selection of a farm and a wiki, properly checked the existence of the wiki --- M MediaWikiFarm.php M src/MediaWikiFarm.php 2 files changed, 153 insertions(+), 45 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/61/299361/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index 11e950d..e30a048 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -29,7 +29,7 @@ require_once "$IP/extensions/MediaWikiFarm/src/MediaWikiFarm.php"; -MediaWikiFarm::initialise(); +$wgMediaWikiFarm = MediaWikiFarm::initialise( $GLOBALS['_SERVER']['HTTP_HOST'] ); @@ -42,35 +42,37 @@ # Select the configuration and export it //$farm->getConfig(); -function wvgGetWikiFromURL() { - - if( !preg_match( '/^([a-zA-Z0-9]+)-([a-zA-Z0-9]+)\.example.com$/', $GLOBALS['_SERVER']['HTTP_HOST'], $matches ) ) { - echo 'Error: unknown wiki.'; - exit; - } - - return array( $matches[2], $matches[1] ); -} +var_dump( $wgMediaWikiFarm );echo "\n\n"; -list( $wvgWiki, $wvgClient ) = wvgGetWikiFromURL(); +# Get client and wiki -// Suffixes (clients): only the current client is saved to avoid any information leak to other clients, e.g. array( 'wikipedia' ) -$wgConf->suffixes = array( $wvgClient ); -if( !in_array( $wvgClient, Yaml::parse( file_get_contents( $wgMediaWikiFarmConfigDir . '/clients.yml' ) ) ) ) { +$wvgClient = $wgMediaWikiFarm->variables['client']; +$wvgWiki = $wgMediaWikiFarm->variables['wiki']; + +var_dump( $wvgClient ); +var_dump( $wvgWiki ); +echo "\n\n"; + + +# Check existence + +var_dump( $wgMediaWikiFarm->checkExistence() ); +echo "\n\n"; + +if( !$wgMediaWikiFarm->checkExistence() ) { + echo 'Error: unknown wiki.'; exit; } + +$wgConf->suffixes = array( $wvgClient ); + // Wikis: a simple list of the wikis for the requested client, e.g. array( 'da', 'cv' ) -$wvgClientWikis = Yaml::parse( file_get_contents( $wgMediaWikiFarmConfigDir.'/'.$wvgClient.'/wikis.yml' ) ); +$wvgClientWikis = $wgMediaWikiFarm->readFile( $wgMediaWikiFarmConfigDir.'/'.$wvgClient.'/wikis.yml' ); $wvgVersion = false; foreach( $wvgClientWikis as $wiki => $value ) { $wgConf->wikis[] = $wiki.'-'.$wvgClient; -} - -if( !in_array( $wvgWiki.'-'.$wvgClient, $wgConf->wikis ) ) { - echo 'Error: unknown wiki.'; - exit; } // Get version @@ -81,6 +83,8 @@ exit; } +exit; + // Obtain the global configuration $wvgGlobals = MediaWikiFarm::getMediaWikiConfig( $wvgWiki, $wvgClient, $wvgVersion, $wgConf, array( 'codeDir' => $wgMediaWikiFarmCodeDir, diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 9d77152..202a31d 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -1,4 +1,9 @@ config ); return self::$self; + } + + /** +* Check the existence of the wiki, given variables values and files listing existing wikis. +* +* A wiki exists if all variables are defined in the URL and all values are found in the +* corresponding listing file. Files can be in PHP, YAML, or dblist. +* +* @return bool The wiki exists. +*/ + function checkExistence() { + + $keys = array(); + $values = array(); + + foreach( $this->config['variables'] as $variable ) { + + $key = $variable['variable']; + if( !array_key_exists( $key, $this->variables ) ) + return false; + + $value = $this->variables[$key]; + $keys[] = '/\$' . preg_quote( $key, '/' ) . '/'; + $values[] = $value; + + $choices = $this->readFile( preg_replace( $keys, $values, $this->configDir.'/'.$variable['file'] ) ); + if( $choices === false ) + return false; + + $isNumeric = array_keys( $choices ) === range( 0, count( $choices ) - 1 ); + if( $isNumeric && !in_array( $value, $choices ) ) + return false; + + if( !$isNumeric && !array_key_exists( $value, $choices ) ) + return false; + } + + return true; } @@ -58,29 +104,21 @@ */ private function __construct( $host,
[MediaWiki-commits] [Gerrit] Update config files - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299368 Change subject: Update config files .. Update config files Already used in my dev environment (adapted) --- M config/farms.php M config/farms.yml 2 files changed, 20 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/68/299368/1 diff --git a/config/farms.php b/config/farms.php index cf4db0c..4a196fc 100644 --- a/config/farms.php +++ b/config/farms.php @@ -8,18 +8,21 @@ 'variables' => array( array( 'variable' => 'family', - 'file' => '$family.dblist', ), array( 'variable' => 'lang', + 'file' => 'org/$family.dblist', 'type' => 'language', ), ), + 'suffix' => '$family', + 'wikiID' => '$lang$family', 'data' => '/srv/data/org/$family/$lang', 'cache' => '/tmp/mw-cache/org-$version-$family-$lang', 'config' => array( 'org/InitialiseSettings.php', 'org/PrivateSettings.php', ), + 'exec-config' => 'org/ExecSettings.php', ), # Configuration for a small wiki farm @@ -28,19 +31,22 @@ 'variables' => array( array( 'variable' => 'client', - 'file' => 'clients.yml', + 'file' => 'com/example/clients.yml', 'config' => 'com/example/$client/InitialiseSettings.yml', ), array( 'variable' => 'wiki', - 'file' => '$client/wikis.yml', + 'file' => 'com/example/$client/wikis.yml', ), ), + 'suffix' => '$family', + 'wikiID' => '$wiki-$client', 'data' => '/srv/data/com/example/$client/$wiki', 'cache' => '/tmp/mw-cache/com-example-$version-$client-$wiki', 'config' => 'com/example/InitialiseSettings.yml', 'post-config' => array( 'com/example/PrivateSettings.yml', - 'com/example/GlobalSettings.php', + 'com/example/GlobalSettings.yml', ), + 'exec-config' => 'com/example/ExecSettings.php', ), ); diff --git a/config/farms.yml b/config/farms.yml index 99cfe9b..6e733b9 100644 --- a/config/farms.yml +++ b/config/farms.yml @@ -4,16 +4,19 @@ variables: - variable: 'family' - file: '$family.dblist' - variable: 'lang' + file: 'org/$family.dblist' type: 'language' +suffix: '$family' +wikiID: '$lang$family' data: '/srv/data/org/$family/$lang' cache: '/tmp/mw-cache/org-$version-$family-$lang' config: - 'org/InitialiseSettings.php' - 'org/PrivateSettings.php' +exec-config: 'org/ExecSettings.php' # Configuration for a small wiki farm '(?[a-z]+)-(?[a-z]+)\.example\.com': @@ -21,15 +24,18 @@ variables: - variable: 'client' - file: 'clients.yml' + file: 'com/example/clients.yml' config: 'com/example/$client/InitialiseSettings.yml' - variable: 'wiki' - file: '$client/wikis.yml' + file: 'com/example/$client/wikis.yml' +suffix: '$client' +wikiID: '$wiki-$client' data: '/srv/data/com/example/$client/$wiki' cache: '/tmp/mw-cache/com-example-$version-$client-$wiki' config: 'com/example/InitialiseSettings.yml' post-config: - 'com/example/PrivateSettings.yml' - - 'com/example/GlobalSettings.php' + - 'com/example/GlobalSettings.yml' +exec-config: 'com/example/ExecSettings.php' -- To view, visit https://gerrit.wikimedia.org/r/299368 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic15fb8e0a8400e8f237868fc8063d7a8c04be732 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] Added extension.json and i18n directory and (auto-)register ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299367 Change subject: Added extension.json and i18n directory and (auto-)register this extension to appear in Special:Version .. Added extension.json and i18n directory and (auto-)register this extension to appear in Special:Version --- A extension.json A i18n/en.json A i18n/fr.json M src/MediaWikiFarm.php 4 files changed, 45 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/67/299367/1 diff --git a/extension.json b/extension.json new file mode 100644 index 000..d47db02 --- /dev/null +++ b/extension.json @@ -0,0 +1,26 @@ +{ + "name": "MediaWikiFarm", + "version": "0.0.0-dev", + "author": [ + "Seb35" + ], + "descriptionmsg": "mediawikifarm-desc", + "license-name": "GPL-3.0+", + "type": "other", + "requires": { + "MediaWiki": ">= 1.1.0" + }, + "config": { + "MediaWikiFarmConfigDir": "/etc/mediawiki", + "MediaWikiFarmCodeDir": null + }, + "MessagesDirs": { + "MediaWikiFarm": [ + "i18n" + ] + }, + "AutoloadClasses": { + "MediaWikiFarms": "src/MediaWikiFarm.php" + }, + "manifest_version": 1 +} diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 000..3a4be28 --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,8 @@ +{ +"@metadata": { +"authors": [ +"Seb35" +] +}, +"mediawikifarm-desc": "Turns a MediaWiki installation into a farm consisting of multiple independant wikis." +} diff --git a/i18n/fr.json b/i18n/fr.json new file mode 100644 index 000..1bb7340 --- /dev/null +++ b/i18n/fr.json @@ -0,0 +1,8 @@ +{ +"@metadata": { +"authors": [ +"Seb35" +] +}, +"mediawikifarm-desc": "Transforme une installation MediaWiki en une ferme de nombreux wikis indépendants." +} diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 0ad057b..fecaaf0 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -577,6 +577,9 @@ } } + // Register this extension MediaWikiFarm to appear in Special:Version + $globals['extensions']['MediaWikiFarm']['_loading'] = 'wfLoadExtension'; + // Save this configuration in a serialised file @mkdir( dirname( $cacheFile ) ); $tmpFile = tempnam( dirname( $cacheFile ), basename( $cacheFile ).'.tmp' ); -- To view, visit https://gerrit.wikimedia.org/r/299367 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibaee11a6f007d88f54aef963de3850b66d7b29d5 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] Commented variables in the main file, it should not override... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299364 Change subject: Commented variables in the main file, it should not override the real value given in LocalSettings.php .. Commented variables in the main file, it should not override the real value given in LocalSettings.php --- M MediaWikiFarm.php M composer.json 2 files changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/64/299364/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index 02b9684..2127018 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -26,7 +26,7 @@ * publish all or parts of the configuration files, but probably you don’t want to publish * private informations like database configuration, upgrade key, etc. */ -$wgMediaWikiFarmConfigDir = '/etc/mediawiki'; +#$wgMediaWikiFarmConfigDir = '/etc/mediawiki'; /** @@ -39,7 +39,7 @@ * it is probably easier to name the subdirectories with the MediaWiki version, the names * are entirely independent from the real version inside the subdirectory. */ -$wgMediaWikiFarmCodeDir = null; +#$wgMediaWikiFarmCodeDir = null; diff --git a/composer.json b/composer.json index 9c8ae9a..23b5779 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,6 @@ "autoload-dev": { }, "scripts": { - "phpdoc": "./vendor/phpdocumentor/phpdocumentor/bin/phpdoc -d ./src -t ./docs/code" + "phpdoc": "./vendor/bin/phpdoc -d ./src -t ./docs/code" } } -- To view, visit https://gerrit.wikimedia.org/r/299364 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0757a145ab0985eca5f08e496fcb0c7eb89e180f 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] Added configuration, added Composer to manage the YAML depen... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299360 Change subject: Added configuration, added Composer to manage the YAML dependency in the main section and phpDocumentor in the dev section .. Added configuration, added Composer to manage the YAML dependency in the main section and phpDocumentor in the dev section --- A .gitignore A composer.json A composer.lock A config/farms.php A config/farms.yml 5 files changed, 2,861 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/60/299360/1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 000..170443b --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Backup files +*.swp +*~ + +# Composer +vendor diff --git a/composer.json b/composer.json new file mode 100644 index 000..9c8ae9a --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "mediawiki-extensions/media-wiki-farm", + "description": "Configuration management for MediaWiki farms.", + "keywords": ["mediawiki"], + "homepage": "https://www.seb35.fr";, + "authors": [ + { + "name": "Sébastien Beyou", + "homepage": "https://www.seb35.fr"; + } + ], + "license": "GPL-3.0+", + "require": { + "php": ">=5.5", + "symfony/yaml": "~2.7" + }, + "require-dev": { + "phpdocumentor/phpdocumentor": "2.*" + }, + "suggest": { + }, + "autoload": { + }, + "autoload-dev": { + }, + "scripts": { + "phpdoc": "./vendor/phpdocumentor/phpdocumentor/bin/phpdoc -d ./src -t ./docs/code" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 000..2b7809b --- /dev/null +++ b/composer.lock @@ -0,0 +1,2745 @@ +{ +"_readme": [ +"This file locks the dependencies of your project to a known state", +"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";, +"This file is @generated automatically" +], +"hash": "9bc7830f38ef93c96be4b87ff4879e6e", +"content-hash": "626d7ef5ec2cb32172de65e20eea40df", +"packages": [ +{ +"name": "symfony/yaml", +"version": "v2.8.3", +"source": { +"type": "git", +"url": "https://github.com/symfony/yaml.git";, +"reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995" +}, +"dist": { +"type": "zip", +"url": "https://api.github.com/repos/symfony/yaml/zipball/2a4ee40acb880c56f29fb1b8886e7ffe94f3b995";, +"reference": "2a4ee40acb880c56f29fb1b8886e7ffe94f3b995", +"shasum": "" +}, +"require": { +"php": ">=5.3.9" +}, +"type": "library", +"extra": { +"branch-alias": { +"dev-master": "2.8-dev" +} +}, +"autoload": { +"psr-4": { +"Symfony\\Component\\Yaml\\": "" +}, +"exclude-from-classmap": [ +"/Tests/" +] +}, +"notification-url": "https://packagist.org/downloads/";, +"license": [ +"MIT" +], +"authors": [ +{ +"name": "Fabien Potencier", +"email": "fab...@symfony.com" +}, +{ +"name": "Symfony Community", +"homepage": "https://symfony.com/contributors"; +} +], +"description": "Symfony Yaml Component", +"homepage": "https://symfony.com";, +"time": "2016-02-23 07:41:20" +} +], +"packages-dev": [ +{ +"name": "cilex/cilex", +"version": "1.1.0", +"source": { +"type": "git", +"url": "https://github.com/Cilex/Cilex.git";, +"reference": "7acd965a609a56d0345e8b6071c261fbdb926cb5" +}, +"dist": { +"type": "zip", +"url": "https://api.github.com/repos/Cilex/Cilex/zipball/7acd965a609a56d0345e8b6071c261fbdb926cb5";, +"reference": "7acd965a609a56d0345e8b6071c261fbdb926cb5", +"shasum": "" +}, +"require": { +"cilex/console-service-provider": "1.*", +"php": ">=5.3.3", +"pimple/pimple": "~1.0", +"symfony/finder": "~2.1", +"symfony/process": "~2.1" +}, +"require-dev": { +"phpun
[MediaWiki-commits] [Gerrit] Move the main file to the nominal file name - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299358 Change subject: Move the main file to the nominal file name .. Move the main file to the nominal file name --- R MediaWikiFarm.php 1 file changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/58/299358/1 diff --git a/LocalSettings.php b/MediaWikiFarm.php similarity index 100% rename from LocalSettings.php rename to MediaWikiFarm.php -- To view, visit https://gerrit.wikimedia.org/r/299358 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I04afd41b58271d83ff8a9d67069f63ba7120d809 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] License headers - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299362 Change subject: License headers .. License headers --- M MediaWikiFarm.php M src/MediaWikiFarm.php 2 files changed, 14 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/62/299362/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index e30a048..2d73a8b 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -1,6 +1,14 @@ + * @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 + */ -use Symfony\Component\Yaml\Yaml; # Protect against web entry if ( !defined( 'MEDIAWIKI' ) ) { @@ -16,7 +24,7 @@ */ $wgMediaWikiFarmConfigDir = '/etc/mediawiki'; -$wgMediaWikiFarmConfigDir = '/srv/www/mediawiki-farm/config'; + diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 202a31d..0e4251c 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -1,6 +1,10 @@ + * @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 */ require_once __DIR__ . '/../vendor/autoload.php'; -- To view, visit https://gerrit.wikimedia.org/r/299362 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0d158fe2f3a2d02b501b3bb6d44df7481c9c9db6 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] Improved setting of the 'wiki properties' depending on varia... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299365 Change subject: Improved setting of the 'wiki properties' depending on variables .. Improved setting of the 'wiki properties' depending on variables --- M src/MediaWikiFarm.php M src/main.php 2 files changed, 116 insertions(+), 46 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/65/299365/1 diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php index 70799ef..0ad057b 100644 --- a/src/MediaWikiFarm.php +++ b/src/MediaWikiFarm.php @@ -38,6 +38,9 @@ /** @var array [private] Farm configuration file. */ public $config = array(); + /** @var array [private] Variables inside the host. */ + public $variables = array(); + /** @var array [private] Selected MediaWiki version. */ public $wiki = array(); @@ -73,7 +76,7 @@ */ function checkExistence() { - global $IP; + global $IP, $wgVersion; if( $this->unusable ) return false; @@ -88,16 +91,16 @@ $key = $variable['variable']; - # The variable must exist + # If the variable doesn’t exist, continue if( !array_key_exists( $key, $this->variables ) ) - return false; + continue; # Possibly the variables up to this one can be placeholders in filenames $value = $this->variables[$key]; $keys[] = '/\$' . preg_quote( $key, '/' ) . '/'; $values[] = $value; - # If every value is correct, continue + # If every values are correct, continue if( !array_key_exists( 'file', $variable ) ) continue; @@ -123,57 +126,63 @@ } # When the wiki is found, replace all variables in other configuration files - $keys[] = '/\$version/'; - $values[] = $version ? $version : ''; - $this->wiki = $this->config; - $this->wiki['version'] = $version; - $this->wiki['globals'] = null; - if( isset( $version ) ) - $this->wiki['code'] = $this->codeDir . (isset( $version ) ? '/' . $version : ''); + if( is_string( $version ) ) + $this->wiki['code'] = $this->codeDir . '/' . $version; else $this->wiki['code'] = $IP; - $this->wiki['data'] = preg_replace( $keys, $values, $this->wiki['data'] ); - if( array_key_exists( 'cache', $this->wiki ) ) $this->wiki['cache'] = preg_replace( $keys, $values, $this->wiki['cache'] ); - if( array_key_exists( 'config', $this->wiki ) ) { - - if( is_string( $this->wiki['config'] ) ) - $this->wiki['config'] = array( $this->wiki['config'] ); - - foreach( $this->wiki['config'] as &$configFile ) - $configFile = preg_replace( $keys, $values, $configFile ); + + if( !$version ) $version = $wgVersion; + $this->variables['version'] = $version; + $this->wiki['version'] = $version; + + if( !array_key_exists( 'wikiID', $this->wiki ) || !is_string( $this->wiki['wikiID'] ) || !$this->wiki['wikiID'] ) { + $this->unusable = true; + return false; } - if( array_key_exists( 'post-config', $this->wiki ) ) { - - if( is_string( $this->wiki['post-config'] ) ) - $this->wiki['post-config'] = array( $this->wiki['post-config'] ); - - foreach( $this->wiki['post-config'] as &$configFile ) - $configFile = preg_replace( $keys, $values, $configFile ); - } + return true; + } + + /** +* Computation of the properties, which could depend on the suffix, wikiID, or other variables. +* +* This function is the central point to get the unique identifier of the wiki, wikiID. +* +* @return void +*/ + function setWikiID() { + + global $wgConf; + + if( $this->unusable
[MediaWiki-commits] [Gerrit] Creation of a class, first step - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299357 Change subject: Creation of a class, first step .. Creation of a class, first step --- M LocalSettings.php 1 file changed, 314 insertions(+), 296 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/57/299357/1 diff --git a/LocalSettings.php b/LocalSettings.php index 64c57d2..a1b3a2d 100644 --- a/LocalSettings.php +++ b/LocalSettings.php @@ -8,325 +8,343 @@ } /** - * Get or compute the configuration (MediaWiki, skins, extensions) for a wiki - * - * You have to specify the wiki, the suffix, and the version and, as parameters, the configuration - * and code directories and the caching file. This function uses a caching mechanism to avoid - * recompute each time the configuration; it is rebuilt when origin configuration files are changed. - * - * The params argument should have the following keys: - * - 'configDir' (string) Configuration directory where are the various configuration files - * - 'codeDir' (string) Code directory where MediaWiki code is - * - 'cacheFile' (string) Template filename of the caching file - * - 'generalYamlFilename' (string) Path for the general YAML file, relative to configDir - * - 'suffixedYamlFilename' (string) Path for the suffixed YAML file, relative to configDir - * - 'privateYamlFilename' (string) Path for the privale YAML file, relative to configDir - * In cacheFile and suffixedYamlFilename, the string '$suffix' will be replaced by the actual - * suffix, and in cacheFile, the strings '$wiki' and '$version' will be replaced by the actual - * wiki identifier and the version. - * - * The returned array has the following format: - * array( 'general' => array( 'wgSitename' => 'Foo', ... ), - *'skins' => array( '_loading' => 'wfLoadSkin'|'require_once', - * 'wgFlowParsoidTimeout' => 100, ... - *), - *'extensions' => array( '_loading' => 'wfLoadExtension'|'require_once', - * 'wgFlowParsoidTimeout' => 100, ... - * ) - * ) - * - * @param $wiki string Name of the wiki - * @param $suffix string Suffix of the wiki (main family type) - * @param $version string Version of the wiki - * @param $wgConf SiteConfiguration object from MediaWiki - * @param $params array Parameters for this configuration management - * @return array Global parameter variables and loading mechanisms for skins and extensions + * This class computes the configuration of a specific wiki from a set of configuration files. + * The configuration is composed of the list of authorised wikis and different configuration + * files, possibly with different permissions. All files are written in YAML syntax. */ -function wvgGetMediaWikiConfig( $myWiki, $mySuffix, $myVersion, &$wgConf, $params ) { +class MediaWikiFarm { - $configDir = $params['configDir']; - $codeDir = $params['codeDir']; - $cacheFile = $params['cacheFile']; - $generalYamlFilename = $params['generalYamlFilename']; - $suffixedYamlFilename = $params['suffixedYamlFilename']; - $privateYamlFilename = $params['privateYamlFilename']; - - $cacheFile = preg_replace( array( '/\$wiki/', '/\$suffix/', '/\$version/' ), - array( $myWiki, $mySuffix, $myVersion ), - $cacheFile ); - - $suffixedYamlFilename = preg_replace( '/\$suffix/', $mySuffix, $suffixedYamlFilename ); - - $globals = false; - - if( @filemtime( $cacheFile ) >= max( filemtime( $configDir.$generalYamlFilename ), -filemtime( $configDir.$suffixedYamlFilename ), -filemtime( $configDir.$privateYamlFilename ) ) ) - { - $cache = @file_get_contents( $cacheFile ); - if ( $cache !== false ) { - $globals = unserialize( $cache ); - } - } - else { + /** +* Get or compute the configuration (MediaWiki, skins, extensions) for a wiki. +* +* You have to specify the wiki, the suffix, and the version and, as parameters, the configuration +* and code directories and the caching file. This function uses a caching mechanism to avoid +* recompute each time the configuration; it is rebuilt when origin configuration files are changed. +* +* The params argument should have the following keys: +* - 'configDir' (string) Configuration directory where are the various configuration files +* - 'codeDir' (string) Code directory where MediaWiki code is +* - 'cacheFile' (string) Template filename of the caching file +* - 'generalYamlFilename' (string)
[MediaWiki-commits] [Gerrit] Initial commit with working code to manage a MediaWiki farm ... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299356 Change subject: Initial commit with working code to manage a MediaWiki farm with some config files .. Initial commit with working code to manage a MediaWiki farm with some config files This code is working, although it should be better organised, essentially within a class, with an operational config file separated from the code, as a true MediaWiki extension, etc. --- A LocalSettings.php 1 file changed, 412 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/56/299356/1 diff --git a/LocalSettings.php b/LocalSettings.php new file mode 100644 index 000..64c57d2 --- /dev/null +++ b/LocalSettings.php @@ -0,0 +1,412 @@ + array( 'wgSitename' => 'Foo', ... ), + *'skins' => array( '_loading' => 'wfLoadSkin'|'require_once', + * 'wgFlowParsoidTimeout' => 100, ... + *), + *'extensions' => array( '_loading' => 'wfLoadExtension'|'require_once', + * 'wgFlowParsoidTimeout' => 100, ... + * ) + * ) + * + * @param $wiki string Name of the wiki + * @param $suffix string Suffix of the wiki (main family type) + * @param $version string Version of the wiki + * @param $wgConf SiteConfiguration object from MediaWiki + * @param $params array Parameters for this configuration management + * @return array Global parameter variables and loading mechanisms for skins and extensions + */ +function wvgGetMediaWikiConfig( $myWiki, $mySuffix, $myVersion, &$wgConf, $params ) { + + $configDir = $params['configDir']; + $codeDir = $params['codeDir']; + $cacheFile = $params['cacheFile']; + $generalYamlFilename = $params['generalYamlFilename']; + $suffixedYamlFilename = $params['suffixedYamlFilename']; + $privateYamlFilename = $params['privateYamlFilename']; + + $cacheFile = preg_replace( array( '/\$wiki/', '/\$suffix/', '/\$version/' ), + array( $myWiki, $mySuffix, $myVersion ), + $cacheFile ); + + $suffixedYamlFilename = preg_replace( '/\$suffix/', $mySuffix, $suffixedYamlFilename ); + + $globals = false; + + if( @filemtime( $cacheFile ) >= max( filemtime( $configDir.$generalYamlFilename ), +filemtime( $configDir.$suffixedYamlFilename ), +filemtime( $configDir.$privateYamlFilename ) ) ) + { + $cache = @file_get_contents( $cacheFile ); + if ( $cache !== false ) { + $globals = unserialize( $cache ); + } + } + else { + + $globals = array(); + $globals['general'] = array(); + $globals['skins'] = array(); + $globals['extensions'] = array(); + + // Load InitialiseSettings.yml (general) + $generalSettings = Yaml::parse( file_get_contents( $configDir.$generalYamlFilename ) ); + foreach( $generalSettings as $setting => $value ) { + + $wgConf->settings[$setting]['default'] = $value; + } + + // Load InitialiseSettings.yml (client) + $suffixedSettings = Yaml::parse( file_get_contents( $configDir.$suffixedYamlFilename ) ); + foreach( $suffixedSettings as $setting => $values ) { + + foreach( $values as $wiki => $val ) { + + if( $wiki == 'default' ) $wgConf->settings[$setting][$mySuffix] = $val; + else $wgConf->settings[$setting][$wiki.'-'.$mySuffix] = $val; + } + } + + // Load PrivateSettings.yml (general) + $privateSettings = Yaml::parse( file_get_contents( $configDir.$privateYamlFilename ) ); + foreach( $privateSettings as $setting => $value ) { + + foreach( $value as $suffix => $val ) { + + $wgConf->settings[$setting][$suffix] = $val; + } + } + + // 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 + $globals['general'] = $wgConf->getAll( $myWiki.'-'.$mySuffix, $mySuffix ); + + // For the permi
[MediaWiki-commits] [Gerrit] [WIP] A proper class in the directory src, where all the log... - change (mediawiki...MediaWikiFarm)
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299359 Change subject: [WIP] A proper class in the directory src, where all the logic will go .. [WIP] A proper class in the directory src, where all the logic will go --- M MediaWikiFarm.php A src/MediaWikiFarm.php 2 files changed, 467 insertions(+), 328 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/59/299359/1 diff --git a/MediaWikiFarm.php b/MediaWikiFarm.php index a1b3a2d..11e950d 100644 --- a/MediaWikiFarm.php +++ b/MediaWikiFarm.php @@ -8,333 +8,29 @@ } /** - * This class computes the configuration of a specific wiki from a set of configuration files. - * The configuration is composed of the list of authorised wikis and different configuration - * files, possibly with different permissions. All files are written in YAML syntax. + * Configuration directory. + * + * This parameter should be specified in your LocalSettings.php, before the require_once. + * The value must be a readable directory. It is recommended this directory is not readable + * from the Web. */ -class MediaWikiFarm { - - /** -* Get or compute the configuration (MediaWiki, skins, extensions) for a wiki. -* -* You have to specify the wiki, the suffix, and the version and, as parameters, the configuration -* and code directories and the caching file. This function uses a caching mechanism to avoid -* recompute each time the configuration; it is rebuilt when origin configuration files are changed. -* -* The params argument should have the following keys: -* - 'configDir' (string) Configuration directory where are the various configuration files -* - 'codeDir' (string) Code directory where MediaWiki code is -* - 'cacheFile' (string) Template filename of the caching file -* - 'generalYamlFilename' (string) Path for the general YAML file, relative to configDir -* - 'suffixedYamlFilename' (string) Path for the suffixed YAML file, relative to configDir -* - 'privateYamlFilename' (string) Path for the privale YAML file, relative to configDir -* In cacheFile and suffixedYamlFilename, the string '$suffix' will be replaced by the actual -* suffix, and in cacheFile, the strings '$wiki' and '$version' will be replaced by the actual -* wiki identifier and the version. -* -* The returned array has the following format: -* array( 'general' => array( 'wgSitename' => 'Foo', ... ), -*'skins' => array( '_loading' => 'wfLoadSkin'|'require_once', -* 'wgFlowParsoidTimeout' => 100, ... -*), -*'extensions' => array( '_loading' => 'wfLoadExtension'|'require_once', -* 'wgFlowParsoidTimeout' => 100, ... -* ) -* ) -* -* @param string $wiki Name of the wiki. -* @param string $suffix Suffix of the wiki (main family type). -* @param string $version Version of the wiki. -* @param SiteConfiguration $wgConf SiteConfigurat object from MediaWiki. -* @param $array params Parameters for this configuration management. -* @return array Global parameter variables and loading mechanisms for skins and extensions. -*/ - static function getMediaWikiConfig( $myWiki, $mySuffix, $myVersion, &$wgConf, $params ) { - - $configDir = $params['configDir']; - $codeDir = $params['codeDir']; - $cacheFile = $params['cacheFile']; - $generalYamlFilename = $params['generalYamlFilename']; - $suffixedYamlFilename = $params['suffixedYamlFilename']; - $privateYamlFilename = $params['privateYamlFilename']; - - $cacheFile = preg_replace( array( '/\$wiki/', '/\$suffix/', '/\$version/' ), - array( $myWiki, $mySuffix, $myVersion ), - $cacheFile ); - - $suffixedYamlFilename = preg_replace( '/\$suffix/', $mySuffix, $suffixedYamlFilename ); - - $globals = false; - - if( @filemtime( $cacheFile ) >= max( filemtime( $configDir.$generalYamlFilename ), -filemtime( $configDir.$suffixedYamlFilename ), -filemtime( $configDir.$privateYamlFilename ) ) ) - { - $cache = @file_get_contents( $cacheFile ); - if ( $cache !== false ) { - $globals = unserialize( $cache
[MediaWiki-commits] [Gerrit] Filter out the IP addresses from Special:Contributors - change (mediawiki...Contributors)
Devirk has uploaded a new change for review. https://gerrit.wikimedia.org/r/299355 Change subject: Filter out the IP addresses from Special:Contributors .. Filter out the IP addresses from Special:Contributors Bug :T139878 Change-Id: Id1f61370f720e30ee796eeb8da50455bdf88b140 --- M includes/Contributors.php 1 file changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Contributors refs/changes/55/299355/1 diff --git a/includes/Contributors.php b/includes/Contributors.php index 863823e..6b31919 100644 --- a/includes/Contributors.php +++ b/includes/Contributors.php @@ -123,10 +123,11 @@ $dbr = wfGetDB( DB_SLAVE ); $pageId = $this->getTarget()->getArticleID(); $contributors = array(); + $cond = array( 'cn_page_id' => $pageId AND 'cn_user_id' != 0 ); $res = $dbr->select( 'contributors', - array( 'cn_user_text' , 'cn_revision_count' ), - array( 'cn_page_id' => $pageId ), + array( 'cn_user_text' , 'cn_user_id' , 'cn_revision_count' ), + $cond, __METHOD__, array( 'GROUP BY' => 'cn_user_text', -- To view, visit https://gerrit.wikimedia.org/r/299355 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id1f61370f720e30ee796eeb8da50455bdf88b140 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Contributors Gerrit-Branch: master Gerrit-Owner: Devirk ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove unneed permissions from enwiki bureaucrats - change (operations/mediawiki-config)
Kharkiv07 has uploaded a new change for review. https://gerrit.wikimedia.org/r/299354 Change subject: Remove unneed permissions from enwiki bureaucrats .. Remove unneed permissions from enwiki bureaucrats Removed 'move-subpages', 'suppressredirect', and 'tboverride', unneeded remnats of them being able to rename users Bug: T140550 Change-Id: I406fac5f83f40cfc8fa7bae197bd73b9cf7cb0c7 --- M wmf-config/InitialiseSettings.php 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config refs/changes/54/299354/1 diff --git a/wmf-config/InitialiseSettings.php b/wmf-config/InitialiseSettings.php index 80ceeeb..dee015a 100644 --- a/wmf-config/InitialiseSettings.php +++ b/wmf-config/InitialiseSettings.php @@ -7706,7 +7706,6 @@ ], 'oversight' => [ 'browsearchive' => true, 'deletedhistory' => true, 'deletedtext' => true, 'abusefilter-view-private' => true], // T30465, T119446 'checkuser' => [ 'browsearchive' => true, 'deletedhistory' => true, 'deletedtext' => true, 'abusefilter-view-private' => true ], // T30465, T119446 - 'bureaucrat' => [ 'move-subpages' => true, 'suppressredirect' => true, 'tboverride' => true, ], 'templateeditor' => [ 'templateeditor' => true, 'tboverride' => true, ], // T57432 'sysop' => [ 'templateeditor' => true, // T57432 -- To view, visit https://gerrit.wikimedia.org/r/299354 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I406fac5f83f40cfc8fa7bae197bd73b9cf7cb0c7 Gerrit-PatchSet: 1 Gerrit-Project: operations/mediawiki-config Gerrit-Branch: master Gerrit-Owner: Kharkiv07 ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix Wikimedia-logo 1.5x image throwing file not found - change (mediawiki...Kartographer)
MaxSem has uploaded a new change for review. https://gerrit.wikimedia.org/r/299353 Change subject: Fix Wikimedia-logo 1.5x image throwing file not found .. Fix Wikimedia-logo 1.5x image throwing file not found Bug: T140307 Change-Id: I7795d243cd225a37a64b04050176c8f0b9bd762f (cherry picked from commit 38da51de8ac6acebcb3c3ae76ac389b3822be897) --- M modules/wikivoyage/wikivoyage.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer refs/changes/53/299353/1 diff --git a/modules/wikivoyage/wikivoyage.js b/modules/wikivoyage/wikivoyage.js index cb67cb5..ca9cb42 100644 --- a/modules/wikivoyage/wikivoyage.js +++ b/modules/wikivoyage/wikivoyage.js @@ -88,7 +88,7 @@ } else if ( options.wvIsWMF ) { icon = mw.html.element( 'img', { src: pathToKartographerImages + 'Wikimedia-logo.png', - srcset: pathToKartographerImages + 'wikimedia-l...@1.5.png 1.5x, ' + + srcset: pathToKartographerImages + 'wikimedia-l...@1.5x.png 1.5x, ' + pathToKartographerImages + 'wikimedia-l...@2x.png 2x', 'class': 'leaflet-control-layers-wm-icon' } ); -- To view, visit https://gerrit.wikimedia.org/r/299353 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7795d243cd225a37a64b04050176c8f0b9bd762f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Kartographer Gerrit-Branch: wmf/1.28.0-wmf.10 Gerrit-Owner: MaxSem Gerrit-Reviewer: JGirault ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Force bad encodings to approximate UTF-8 - change (mediawiki...DonationInterface)
Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/299352 Change subject: Force bad encodings to approximate UTF-8 .. Force bad encodings to approximate UTF-8 In case the message cannot be json_encoded due to bad Unicode, we do an inexact mapping and may mangle strings in hopes of getting something nearly readable. Bug: T140515 Change-Id: Iff46ad776c528262f1a73320c907ca6daf6a6d34 --- M composer.json M composer.lock M gateway_common/gateway.adapter.php M tests/LoggingTest.php 4 files changed, 127 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/52/299352/1 diff --git a/composer.json b/composer.json index d38cef6..a9de913 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "fusesource/stomp-php": "2.1.*", "minfraud/http": "^1.70", "monolog/monolog": "1.12.0", + "neitanod/forceutf8": "^2.0", "predis/predis": "1.*", "psr/log": "1.0.0", "zordius/lightncandy": "0.18", diff --git a/composer.lock b/composer.lock index 845d450..9b2936b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file";, "This file is @generated automatically" ], -"hash": "f32d8a3c3a03bc107a599b141317d49e", -"content-hash": "47e786eb13a9c848b45f71174ba3c3bc", +"hash": "cb0424bbeedecf9f24660a16f9cbe41d", +"content-hash": "7e35a2a89ccdc99395ea2370c3276527", "packages": [ { "name": "amzn/login-and-pay-with-amazon-sdk-php", @@ -93,27 +93,23 @@ "source": { "type": "git", "url": "https://gerrit.wikimedia.org/r/p/wikimedia/fundraising/php-queue.git";, -"reference": "c5a5200e3b5df3ec5f02ff27e8e6d9a07ce10b5e" +"reference": "9517492e6be44fb7fc48e01e0ee45aeb785f28cc" }, "require": { -"clio/clio": "@stable", +"clio/clio": "0.1.*", "monolog/monolog": "~1.3", "php": ">=5.3.0" }, "require-dev": { -"amazonwebservices/aws-sdk-for-php": "dev-master", -"aws/aws-sdk-php": "dev-master", -"ext-memcache": "*", -"iron-io/iron_mq": "dev-master", -"microsoft/windowsazure": "dev-master", -"mrpoundsign/pheanstalk-5.3": "dev-master", -"predis/predis": "1.*" +"jakub-onderka/php-parallel-lint": "0.9", +"phpunit/phpunit": "4.4.*" }, "suggest": { "Respect/Rest": "For a REST server to post job data", "amazonwebservices/aws-sdk-for-php": "For AWS SQS backend support (legacy version)", "aws/aws-sdk-php": "For AWS SQS backend support", "clio/clio": "Support for daemonizing PHP CLI runner", +"ext-memcache": "*", "fusesource/stomp-php": "For the STOMP backend", "iron-io/iron_mq": "For IronMQ backend support", "microsoft/windowsazure": "For Windows Azure Service Bus backend support", @@ -132,6 +128,12 @@ "PHPQueue": "src/" } }, +"scripts": { +"test": [ +"parallel-lint . --exclude vendor", +"phpunit" +] +}, "license": [ "MIT" ], @@ -147,7 +149,7 @@ "queue", "transaction" ], -"time": "2015-08-25 20:02:50" +"time": "2016-07-15 17:35:10" }, { "name": "fusesource/stomp-php", @@ -312,6 +314,40 @@ "time": "2014-12-29 21:29:35" }, { +"name": "neitanod/forceutf8", +"version": "v2.0", +"source": { +"type": "git", +"url": "https://github.com/neitanod/forceutf8.git";, +"reference": "2c1b21e00ed16b2b083ae4e27901cb5f2856db90" +}, +"dist": { +"type": "zip", +"url": "https://api.github.com/repos/neitanod/forceutf8/zipball/2c1b21e00ed16b2b083ae4e27901cb5f2856db90";, +"reference": "2c1b21e00ed16b2b083ae4e27901cb5f2856db90", +"shasum": "" +}, +"require": { +"php": ">=5.3.0" +}, +"type": "library", +"autoload": { +"psr-0": { +"ForceUTF8\\": "src/" +} +}, +"notification-url": "https://packagist.org/downl
[MediaWiki-commits] [Gerrit] Don't oversize the font on arrow steps - change (mediawiki...UploadWizard)
Bartosz Dziewoński has uploaded a new change for review. https://gerrit.wikimedia.org/r/299351 Change subject: Don't oversize the font on arrow steps .. Don't oversize the font on arrow steps Change-Id: I0034cd4c64cb50332421d45c8eeb3a5809a9b0b0 --- M resources/uploadWizard.css 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard refs/changes/51/299351/1 diff --git a/resources/uploadWizard.css b/resources/uploadWizard.css index a2ba7de..fd3a520 100644 --- a/resources/uploadWizard.css +++ b/resources/uploadWizard.css @@ -16,7 +16,6 @@ #mwe-upwiz-steps li { color: #666; - font-size: 1.2em; margin-right: -1px; border-top: solid 1px #a7d7f9; border-bottom: solid 1px #a7d7f9; -- To view, visit https://gerrit.wikimedia.org/r/299351 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0034cd4c64cb50332421d45c8eeb3a5809a9b0b0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/UploadWizard Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] [WIP] Reproduce Ingenico name encoding bug - change (mediawiki...DonationInterface)
Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/299350 Change subject: [WIP] Reproduce Ingenico name encoding bug .. [WIP] Reproduce Ingenico name encoding bug Bug: T140515 Change-Id: I846c3560d3f54c264360d605b3b309100ad922c2 --- M tests/LoggingTest.php 1 file changed, 64 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/50/299350/1 diff --git a/tests/LoggingTest.php b/tests/LoggingTest.php index 2ff51be..7de921c 100644 --- a/tests/LoggingTest.php +++ b/tests/LoggingTest.php @@ -103,4 +103,68 @@ $this->assertEquals( $expectedObject, $actualObject, 'Completion message is as expected' ); } + + /** +* Test how we react to a bad Unicode string. Bad Unicode should be passed through... [?] +*/ + public function testBadUnicode() { + $init = $this->getDonorTestData(); + $init['payment_method'] = 'cc'; + $init['payment_submethod'] = 'visa'; + $init['fname'] = 'Алексан�'; + $init['email'] = 'innoc...@manichean.com'; + $init['ffname'] = 'cc-vmad'; + $init['unusual_key'] = mt_rand(); + unset( $init['order_id'] ); + + $expectedObject = array( + 'amount' => 23.45, + 'appeal' => 'JimmyQuote', + 'attempt_id' => '2', + 'avs_result' => 'M', + 'city' => 'San Francisco', + //'contribution_tracking_id' => '1', + 'country' => 'US', + 'currency_code' => 'EUR', + 'cvv_result' => 'P', + 'effort_id' => '1', + 'email' => 'innoc...@manichean.com', + 'ffname' => 'cc-vmad', + 'fname' => 'Алексан�', + 'full_name' => 'Firstname Surname', + 'gateway' => 'globalcollect', + 'language' => 'en', + 'lname' => 'Surname', + //'order_id' => 'ORDER_ID', + 'payment_method' => 'cc', + 'payment_product' => 1, + 'payment_submethod' => 'visa', + 'recurring' => '', + 'referrer' => 'www.yourmom.com', + //'returnto' => 'http =>//payments.dev/index.php/Special =>GlobalCollectGatewayResult?order_id=ORDER_ID', + 'server_ip' => '127.0.0.1', + 'state' => 'CA', + 'street' => '123 Fake Street', + 'unusual_key' => ( string ) $init['unusual_key'], + 'user_ip' => '127.0.0.1', + 'utm_source' => '..cc', + 'zip' => '94105', + ); + + $gateway = $this->getFreshGatewayObject( $init ); + $gateway->setDummyGatewayResponseCode( '200' ); + $gateway->do_transaction( 'Confirm_CreditCard' ); + $preface_pattern = '/' . preg_quote( GatewayAdapter::COMPLETED_PREFACE ) . '/'; + $matches = $this->getLogMatches( LogLevel::INFO, $preface_pattern ); + $this->assertTrue( $matches !== false, + 'Should log a completion message' ); + + $json = str_replace( GatewayAdapter::COMPLETED_PREFACE, '', $matches[0] ); + $actualObject = json_decode( $json, true ); + unset( $actualObject['order_id'] ); + unset( $actualObject['returnto'] ); + unset( $actualObject['contribution_tracking_id'] ); + $this->assertEquals( $expectedObject, $actualObject, + 'Completion message is as expected' ); + } } -- To view, visit https://gerrit.wikimedia.org/r/299350 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I846c3560d3f54c264360d605b3b309100ad922c2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] CheckboxMultiselectWidget: When Shift-clicking, check and up... - change (oojs/ui)
Bartosz Dziewoński has uploaded a new change for review. https://gerrit.wikimedia.org/r/299349 Change subject: CheckboxMultiselectWidget: When Shift-clicking, check and update each checkbox, not all at once .. CheckboxMultiselectWidget: When Shift-clicking, check and update each checkbox, not all at once Use case: a CheckboxMultiselectWidget that only allows selecting a number of options (e.g. at most 5 out of 10). Such a restriction could previously be easily cheated by Shift-clicking. Change-Id: I87a1abaf566fe3d7f7a62119cb607697c279494a --- M src/widgets/CheckboxMultiselectWidget.js 1 file changed, 6 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/49/299349/1 diff --git a/src/widgets/CheckboxMultiselectWidget.js b/src/widgets/CheckboxMultiselectWidget.js index 9b220ad..a0efbad 100644 --- a/src/widgets/CheckboxMultiselectWidget.js +++ b/src/widgets/CheckboxMultiselectWidget.js @@ -111,11 +111,12 @@ Math.max( $options.index( $lastClicked ), $options.index( $nowClicked ) ) + 1 ) .find( 'input' ) - .filter( function () { - return !this.disabled; - } ) - .prop( 'checked', checked ) - .trigger( 'change' ); + .each( function () { + if ( !this.disabled ) { + this.checked = checked; + $( this ).trigger( 'change' ); + } + } ); } if ( $nowClicked.length ) { -- To view, visit https://gerrit.wikimedia.org/r/299349 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I87a1abaf566fe3d7f7a62119cb607697c279494a Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Syncronize VisualEditor: c075a17..e9c281b - change (mediawiki/extensions)
Jenkins-mwext-sync has submitted this change and it was merged. Change subject: Syncronize VisualEditor: c075a17..e9c281b .. Syncronize VisualEditor: c075a17..e9c281b Change-Id: Ibfddebb8e149f31aa7bac1e6f97d08a81a5676dc --- M VisualEditor 1 file changed, 0 insertions(+), 0 deletions(-) Approvals: Jenkins-mwext-sync: Verified; Looks good to me, approved diff --git a/VisualEditor b/VisualEditor index c075a17..e9c281b 16 --- a/VisualEditor +++ b/VisualEditor -Subproject commit c075a17ff7412dd23fbc5c00763399ecd098d40b +Subproject commit e9c281b88833dd6c91af4e3505732529d089 -- To view, visit https://gerrit.wikimedia.org/r/299348 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibfddebb8e149f31aa7bac1e6f97d08a81a5676dc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions Gerrit-Branch: master Gerrit-Owner: Jenkins-mwext-sync Gerrit-Reviewer: Jenkins-mwext-sync ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Syncronize VisualEditor: c075a17..e9c281b - change (mediawiki/extensions)
Jenkins-mwext-sync has uploaded a new change for review. https://gerrit.wikimedia.org/r/299348 Change subject: Syncronize VisualEditor: c075a17..e9c281b .. Syncronize VisualEditor: c075a17..e9c281b Change-Id: Ibfddebb8e149f31aa7bac1e6f97d08a81a5676dc --- M VisualEditor 1 file changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions refs/changes/48/299348/1 diff --git a/VisualEditor b/VisualEditor index c075a17..e9c281b 16 --- a/VisualEditor +++ b/VisualEditor -Subproject commit c075a17ff7412dd23fbc5c00763399ecd098d40b +Subproject commit e9c281b88833dd6c91af4e3505732529d089 -- To view, visit https://gerrit.wikimedia.org/r/299348 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibfddebb8e149f31aa7bac1e6f97d08a81a5676dc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions Gerrit-Branch: master Gerrit-Owner: Jenkins-mwext-sync ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Update interwiki map - change (operations/mediawiki-config)
jenkins-bot has submitted this change and it was merged. Change subject: Update interwiki map .. Update interwiki map Some links were still protocol-relative. We switch them to HTTPS, as now required by the API. That will resume transwiki for these wikis. Map URL: https://meta.wikimedia.org/w/index.php?title=Interwiki_map&oldid=15770915 This is a follow-up for 4d933e86. Thanks to Stryn for their assistance to update the map on meta, and Legoktm to have analyzed the issue. Bug: T140206 Change-Id: I7fb82ed3571970f5f8a9c84c7d2a54f0979cb5c1 --- M wmf-config/interwiki.php 1 file changed, 69 insertions(+), 69 deletions(-) Approvals: 20after4: Looks good to me, approved jenkins-bot: Verified diff --git a/wmf-config/interwiki.php b/wmf-config/interwiki.php index fd6ded0..ab428da 100644 --- a/wmf-config/interwiki.php +++ b/wmf-config/interwiki.php @@ -1,8 +1,8 @@ '0 http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1', - '__global:advisory' => '1 //advisory.wikimedia.org/wiki/$1', + '__global:advisory' => '1 https://advisory.wikimedia.org/wiki/$1', '__global:advogato' => '0 http://www.advogato.org/$1', '__global:aew' => '0 http://wiki.arabeyes.org/$1', '__global:appropedia' => '0 http://www.appropedia.org/$1', @@ -23,7 +23,7 @@ '__global:brickwiki' => '0 http://www.brickwiki.info/wiki/$1', '__global:bugzilla' => '1 https://bugzilla.wikimedia.org/show_bug.cgi?id=$1', '__global:bulba' => '0 http://bulbapedia.bulbagarden.net/wiki/$1', - '__global:c' => '1 //commons.wikimedia.org/wiki/$1', + '__global:c' => '1 https://commons.wikimedia.org/wiki/$1', '__global:c2' => '0 http://c2.com/cgi/wiki?$1', '__global:c2find' => '0 http://c2.com/cgi/wiki?FindPage&value=$1', '__global:cache' => '0 //www.google.com/search?q=cache:$1', @@ -35,7 +35,7 @@ '__global:citizendium' => '0 http://en.citizendium.org/wiki/$1', '__global:ckwiss' => '0 http://www.ck-wissen.de/ckwiki/index.php?title=$1', '__global:comixpedia' => '0 http://www.comixpedia.org/index.php?title=$1', - '__global:commons' => '1 //commons.wikimedia.org/wiki/$1', + '__global:commons' => '1 https://commons.wikimedia.org/wiki/$1', '__global:communityscheme' => '0 http://community.schemewiki.org/?c=s&key=$1', '__global:communitywiki' => '0 http://www.communitywiki.org/$1', '__global:comune' => '0 http://rete.comuni-italiani.it/wiki/$1', @@ -179,9 +179,9 @@ '__global:mediawikiwiki' => '1 //www.mediawiki.org/wiki/$1', '__global:mediazilla' => '1 https://bugzilla.wikimedia.org/$1', '__global:memoryalpha' => '0 http://memory-alpha.org/wiki/$1', - '__global:metawiki' => '1 //meta.wikimedia.org/wiki/$1', - '__global:metawikimedia' => '1 //meta.wikimedia.org/wiki/$1', - '__global:metawikipedia' => '1 //meta.wikimedia.org/wiki/$1', + '__global:metawiki' => '1 https://meta.wikimedia.org/wiki/$1', + '__global:metawikimedia' => '1 https://meta.wikimedia.org/wiki/$1', + '__global:metawikipedia' => '1 https://meta.wikimedia.org/wiki/$1', '__global:metawikisearch' => '0 http://sunir.org/apps/meta.pl?$1', '__global:mineralienatlas' => '0 http://www.mineralienatlas.de/lexikon/index.php/$1', '__global:moinmoin' => '0 http://moinmo.in/$1', @@ -197,8 +197,8 @@ '__global:nkcells' => '0 http://www.nkcells.info/index.php?title=$1', '__global:nara' => '0 http://research.archives.gov/description/$1', '__global:nosmoke' => '0 http://no-smok.net/nsmk/$1', - '__global:nost' => '1 //nostalgia.wikipedia.org/wiki/$1', - '__global:nostalgia' => '1 //nostalgia.wikipedia.org/wiki/$1', + '__global:nost' => '1 https://nostalgia.wikipedia.org/wiki/$1', + '__global:nostalgia' => '1 https://nostalgia.wikipedia.org/wiki/$1', '__global:oeis' => '0 //oeis.org/$1', '__global:oldwikisource' => '1 //wikisource.org/wiki/$1', '__global:olpc' => '0 http://wiki.laptop.org/go/$1', @@ -215,8 +215,8 @@ '__global:otrs' => '1 https://ticket.wikimedia.org/otrs/index.pl?Action=AgentTicketZoom&TicketID=$1', '__global:otrswiki' => '1 //otrs-wiki.wikimedia.org/wiki/$1', '__global:ourmedia' => '0 https://www.socialtext.net/ourmedia/index.cgi?$1', - '__global:outreach' => '1 //outreach.wikimedia.org/wiki/$1', - '__global:outreachwiki' => '1 //outreach.wikimedia.org/wiki/$1', + '__global:outreach' => '1 https://outreach.wikimedia.org/wiki/$1', + '__global:outreachwiki' => '1 https://outreach.wikimedia.org/wiki/$1', '__global:owasp' => '0 https://www.owasp.org/index.php/$1', '__global:panawiki' => '0 http://wiki.alairelibre.net/index.php?title=$1', '__global:patwiki' => '0 http://gauss.ffii.org/$1', @@ -237,9 +237,9 @@ '__global:pythonwiki' =>
[MediaWiki-commits] [Gerrit] update DonationInterface submodule - change (mediawiki/core)
jenkins-bot has submitted this change and it was merged. Change subject: update DonationInterface submodule .. update DonationInterface submodule Change-Id: I17f6b3db05fa05b59bfac949d9fde765f7bff75d --- M extensions/DonationInterface 1 file changed, 0 insertions(+), 0 deletions(-) Approvals: Awight: Looks good to me, approved jenkins-bot: Verified diff --git a/extensions/DonationInterface b/extensions/DonationInterface index 0b05d75..0524dca 16 --- a/extensions/DonationInterface +++ b/extensions/DonationInterface -Subproject commit 0b05d75e6f744b8208e23bad29a82b894abdbc84 +Subproject commit 0524dcac6c85a9db8cacd8b079387e2a6601270a -- To view, visit https://gerrit.wikimedia.org/r/299303 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I17f6b3db05fa05b59bfac949d9fde765f7bff75d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: fundraising/REL1_25 Gerrit-Owner: Awight Gerrit-Reviewer: Awight Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Log json_encode errors - change (mediawiki...DonationInterface)
jenkins-bot has submitted this change and it was merged. Change subject: Log json_encode errors .. Log json_encode errors When completed donation logging fails, we want to know what's up. TODO: Write a test for this. Bug: T140515 Change-Id: I38a330f3f324f9a0a6b072b43d4e841b0d483128 --- M gateway_common/gateway.adapter.php 1 file changed, 5 insertions(+), 0 deletions(-) Approvals: Awight: Looks good to me, approved jenkins-bot: Verified diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index f294885..a90be82 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -3723,6 +3723,11 @@ // as getStompTransaction, but I'm currently debugging that // function, so dump it all: $dump = json_encode( $this->getData_Unstaged_Escaped() ); + if ( $dump === false ) { + // Encoding failed. Why? + // TODO: Reuse this in logPaymentDetails. + $dump = json_encode( array( 'json_encode_error' => json_last_error() . ': ' . json_last_error_msg() ) ); + } $this->logger->info( self::COMPLETED_PREFACE . $dump ); } } -- To view, visit https://gerrit.wikimedia.org/r/299302 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I38a330f3f324f9a0a6b072b43d4e841b0d483128 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Awight Gerrit-Reviewer: AndyRussG Gerrit-Reviewer: Awight Gerrit-Reviewer: Cdentinger Gerrit-Reviewer: Ejegg Gerrit-Reviewer: Ssmith Gerrit-Reviewer: XenoRyet Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] update DonationInterface submodule - change (mediawiki/core)
Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/299303 Change subject: update DonationInterface submodule .. update DonationInterface submodule Change-Id: I17f6b3db05fa05b59bfac949d9fde765f7bff75d --- M extensions/DonationInterface 1 file changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/03/299303/1 diff --git a/extensions/DonationInterface b/extensions/DonationInterface index 0b05d75..0524dca 16 --- a/extensions/DonationInterface +++ b/extensions/DonationInterface -Subproject commit 0b05d75e6f744b8208e23bad29a82b894abdbc84 +Subproject commit 0524dcac6c85a9db8cacd8b079387e2a6601270a -- To view, visit https://gerrit.wikimedia.org/r/299303 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I17f6b3db05fa05b59bfac949d9fde765f7bff75d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: fundraising/REL1_25 Gerrit-Owner: Awight ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Log json_encode errors - change (mediawiki...DonationInterface)
Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/299302 Change subject: Log json_encode errors .. Log json_encode errors When completed donation logging fails, we want to know what's up. TODO: Write a test for this. Bug: T140515 Change-Id: I38a330f3f324f9a0a6b072b43d4e841b0d483128 --- M gateway_common/gateway.adapter.php 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/02/299302/1 diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index f294885..a90be82 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -3723,6 +3723,11 @@ // as getStompTransaction, but I'm currently debugging that // function, so dump it all: $dump = json_encode( $this->getData_Unstaged_Escaped() ); + if ( $dump === false ) { + // Encoding failed. Why? + // TODO: Reuse this in logPaymentDetails. + $dump = json_encode( array( 'json_encode_error' => json_last_error() . ': ' . json_last_error_msg() ) ); + } $this->logger->info( self::COMPLETED_PREFACE . $dump ); } } -- To view, visit https://gerrit.wikimedia.org/r/299302 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I38a330f3f324f9a0a6b072b43d4e841b0d483128 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: deployment Gerrit-Owner: Awight ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Wiktionary: Stop restricting language names to those on a st... - change (mediawiki...mobileapps)
Mholloway has uploaded a new change for review. https://gerrit.wikimedia.org/r/299301 Change subject: Wiktionary: Stop restricting language names to those on a static list .. Wiktionary: Stop restricting language names to those on a static list Wiktionary allows users to define languages arbitrarily rather than restricting them to a fixed set. Previously we were discarding these where they weren't on a fixed list derived from the outstanding Wiki languages. This patch stops discarding "unknown" language content and instead includes it in the response. It does this in a strictly additive way without changing the response structure so as to avoid breaking existing clients. The language code "other" is used for languages not on the static list and the language name is included with each definition so that the client can use it if desired. I've also added just "Chinese" (as opposed to "Traditional Chinese" or "Simplified Chinese") to the static list since it was absent before. These changes should eliminate most of the remaining 404s in the mobileapps production logs. Bug: T129229 Bug: T129235 Change-Id: Ic07f729337599ed4038a3930d27b832c70a16a0f --- M lib/parseDefinition.js M static/languages_list.json 2 files changed, 7 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps refs/changes/01/299301/1 diff --git a/lib/parseDefinition.js b/lib/parseDefinition.js index 98efafe..33f1f05 100644 --- a/lib/parseDefinition.js +++ b/lib/parseDefinition.js @@ -135,6 +135,7 @@ function parse(doc, domain, title) { // TODO: update once Parsoid emits section tags, see https://phabricator.wikimedia.org/T114072#1711063 var i, j, +currentLang, definitions = {}, definitionSection, defnList, @@ -157,13 +158,15 @@ Per the English Wiktionary style guide (linked in header above), H2 headings are language names. */ if (currentSectionDiv.className.substring('toclevel_'.length) === "1") { -defnLangCode = getLanguageCode(header, wikiLangCode); +currentLang = header; +defnLangCode = getLanguageCode(header, wikiLangCode) || 'other'; } /* Parse definitions from part-of-speech sections */ -if (defnLangCode && partsOfSpeech[wikiLangCode].indexOf(header) > -1) { +if (partsOfSpeech[wikiLangCode].indexOf(header) > -1) { definitionSection = {}; definitionSection.partOfSpeech = header; +definitionSection.language = currentLang; definitionSection.definitions = []; defnList = getDefnList(doc, currentSectionDiv.id, wikiLangCode); for (i = 0; i < defnList.length; i++) { diff --git a/static/languages_list.json b/static/languages_list.json index 12c0fa4..f4d9356 100644 --- a/static/languages_list.json +++ b/static/languages_list.json @@ -290,5 +290,6 @@ "Esperanto": "eo", "Kirundi": "rn", "Ossetian": "os", - "Gova Konknni": "gom" + "Gova Konknni": "gom", + "Chinese": "zh" } -- To view, visit https://gerrit.wikimedia.org/r/299301 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic07f729337599ed4038a3930d27b832c70a16a0f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/mobileapps Gerrit-Branch: master Gerrit-Owner: Mholloway ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Log json_encode errors - change (mediawiki...DonationInterface)
jenkins-bot has submitted this change and it was merged. Change subject: Log json_encode errors .. Log json_encode errors When completed donation logging fails, we want to know what's up. TODO: Write a test for this. Bug: T140515 Change-Id: I38a330f3f324f9a0a6b072b43d4e841b0d483128 --- M gateway_common/gateway.adapter.php 1 file changed, 5 insertions(+), 0 deletions(-) Approvals: Cdentinger: Looks good to me, approved jenkins-bot: Verified diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index dd991e5..59b8c87 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -3734,6 +3734,11 @@ // as getStompTransaction, but I'm currently debugging that // function, so dump it all: $dump = json_encode( $this->getData_Unstaged_Escaped() ); + if ( $dump === false ) { + // Encoding failed. Why? + // TODO: Reuse this in logPaymentDetails. + $dump = json_encode( array( 'json_encode_error' => json_last_error() . ': ' . json_last_error_msg() ) ); + } $this->logger->info( self::COMPLETED_PREFACE . $dump ); } } -- To view, visit https://gerrit.wikimedia.org/r/299297 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I38a330f3f324f9a0a6b072b43d4e841b0d483128 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight Gerrit-Reviewer: AndyRussG Gerrit-Reviewer: Cdentinger Gerrit-Reviewer: Ejegg Gerrit-Reviewer: Ssmith Gerrit-Reviewer: XenoRyet Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] solve_disambiguation.py: Do not suggest duplicate alternatives - change (pywikibot/core)
jenkins-bot has submitted this change and it was merged. Change subject: solve_disambiguation.py: Do not suggest duplicate alternatives .. solve_disambiguation.py: Do not suggest duplicate alternatives Bug: T138667 Change-Id: I137adebe9a8941db40e84a9785073693a6e3d487 --- M scripts/solve_disambiguation.py 1 file changed, 13 insertions(+), 5 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py index 92d8938..74ad11b 100755 --- a/scripts/solve_disambiguation.py +++ b/scripts/solve_disambiguation.py @@ -71,7 +71,7 @@ # (C) Daniel Herding, 2004 # (C) Andre Engels, 2003-2004 # (C) WikiWichtel, 2004 -# (C) Pywikibot team, 2003-2015 +# (C) Pywikibot team, 2003-2016 # # Distributed under the terms of the MIT license. # @@ -651,9 +651,16 @@ return None def makeAlternativesUnique(self): -"""Remove duplicate entries stable.""" -unique = set(self.alternatives) -self.alternatives = [alt for alt in self.alternatives if alt in unique] +"""Remove duplicate items from self.alternatives. + +Preserve the order of alternatives. +@rtype: None + +""" +seen = set() +self.alternatives = [ +i for i in self.alternatives if i not in seen and not seen.add(i) +] def listAlternatives(self): """Show a list of alternatives.""" @@ -954,7 +961,7 @@ def findAlternatives(self, disambPage): """Extend self.alternatives using correctcap of disambPage.linkedPages. -@param disambPage: the disabiguation page +@param disambPage: the disambiguation page @type disambPage: pywikibot.Page @return: True if everything goes fine, False otherwise @rtype: bool @@ -1002,6 +1009,7 @@ u"The specified page is not a redirect. Skipping.") return False elif self.getAlternatives: +# not disambPage.isRedirectPage() or self.primary try: if self.primary: try: -- To view, visit https://gerrit.wikimedia.org/r/299277 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I137adebe9a8941db40e84a9785073693a6e3d487 Gerrit-PatchSet: 2 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: Dalba Gerrit-Reviewer: Dalba Gerrit-Reviewer: John Vandenberg Gerrit-Reviewer: Xqt Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Update interwiki map - change (operations/mediawiki-config)
Dereckson has uploaded a new change for review. https://gerrit.wikimedia.org/r/299299 Change subject: Update interwiki map .. Update interwiki map Some links were still protocol-relative. We switch them to HTTPS, as now required by the API. That will resume transwiki for these wikis. Map URL: https://meta.wikimedia.org/w/index.php?title=Interwiki_map&oldid=15770915 This is a follow-up for 4d933e86. Thanks to Stryn for their assistance to update the map on meta, and Legoktm to have analyzed the issue. Bug: T140206 Change-Id: I7fb82ed3571970f5f8a9c84c7d2a54f0979cb5c1 --- M wmf-config/interwiki.php 1 file changed, 69 insertions(+), 69 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config refs/changes/99/299299/1 diff --git a/wmf-config/interwiki.php b/wmf-config/interwiki.php index fd6ded0..ab428da 100644 --- a/wmf-config/interwiki.php +++ b/wmf-config/interwiki.php @@ -1,8 +1,8 @@ '0 http://www.acronymfinder.com/af-query.asp?String=exact&Acronym=$1', - '__global:advisory' => '1 //advisory.wikimedia.org/wiki/$1', + '__global:advisory' => '1 https://advisory.wikimedia.org/wiki/$1', '__global:advogato' => '0 http://www.advogato.org/$1', '__global:aew' => '0 http://wiki.arabeyes.org/$1', '__global:appropedia' => '0 http://www.appropedia.org/$1', @@ -23,7 +23,7 @@ '__global:brickwiki' => '0 http://www.brickwiki.info/wiki/$1', '__global:bugzilla' => '1 https://bugzilla.wikimedia.org/show_bug.cgi?id=$1', '__global:bulba' => '0 http://bulbapedia.bulbagarden.net/wiki/$1', - '__global:c' => '1 //commons.wikimedia.org/wiki/$1', + '__global:c' => '1 https://commons.wikimedia.org/wiki/$1', '__global:c2' => '0 http://c2.com/cgi/wiki?$1', '__global:c2find' => '0 http://c2.com/cgi/wiki?FindPage&value=$1', '__global:cache' => '0 //www.google.com/search?q=cache:$1', @@ -35,7 +35,7 @@ '__global:citizendium' => '0 http://en.citizendium.org/wiki/$1', '__global:ckwiss' => '0 http://www.ck-wissen.de/ckwiki/index.php?title=$1', '__global:comixpedia' => '0 http://www.comixpedia.org/index.php?title=$1', - '__global:commons' => '1 //commons.wikimedia.org/wiki/$1', + '__global:commons' => '1 https://commons.wikimedia.org/wiki/$1', '__global:communityscheme' => '0 http://community.schemewiki.org/?c=s&key=$1', '__global:communitywiki' => '0 http://www.communitywiki.org/$1', '__global:comune' => '0 http://rete.comuni-italiani.it/wiki/$1', @@ -179,9 +179,9 @@ '__global:mediawikiwiki' => '1 //www.mediawiki.org/wiki/$1', '__global:mediazilla' => '1 https://bugzilla.wikimedia.org/$1', '__global:memoryalpha' => '0 http://memory-alpha.org/wiki/$1', - '__global:metawiki' => '1 //meta.wikimedia.org/wiki/$1', - '__global:metawikimedia' => '1 //meta.wikimedia.org/wiki/$1', - '__global:metawikipedia' => '1 //meta.wikimedia.org/wiki/$1', + '__global:metawiki' => '1 https://meta.wikimedia.org/wiki/$1', + '__global:metawikimedia' => '1 https://meta.wikimedia.org/wiki/$1', + '__global:metawikipedia' => '1 https://meta.wikimedia.org/wiki/$1', '__global:metawikisearch' => '0 http://sunir.org/apps/meta.pl?$1', '__global:mineralienatlas' => '0 http://www.mineralienatlas.de/lexikon/index.php/$1', '__global:moinmoin' => '0 http://moinmo.in/$1', @@ -197,8 +197,8 @@ '__global:nkcells' => '0 http://www.nkcells.info/index.php?title=$1', '__global:nara' => '0 http://research.archives.gov/description/$1', '__global:nosmoke' => '0 http://no-smok.net/nsmk/$1', - '__global:nost' => '1 //nostalgia.wikipedia.org/wiki/$1', - '__global:nostalgia' => '1 //nostalgia.wikipedia.org/wiki/$1', + '__global:nost' => '1 https://nostalgia.wikipedia.org/wiki/$1', + '__global:nostalgia' => '1 https://nostalgia.wikipedia.org/wiki/$1', '__global:oeis' => '0 //oeis.org/$1', '__global:oldwikisource' => '1 //wikisource.org/wiki/$1', '__global:olpc' => '0 http://wiki.laptop.org/go/$1', @@ -215,8 +215,8 @@ '__global:otrs' => '1 https://ticket.wikimedia.org/otrs/index.pl?Action=AgentTicketZoom&TicketID=$1', '__global:otrswiki' => '1 //otrs-wiki.wikimedia.org/wiki/$1', '__global:ourmedia' => '0 https://www.socialtext.net/ourmedia/index.cgi?$1', - '__global:outreach' => '1 //outreach.wikimedia.org/wiki/$1', - '__global:outreachwiki' => '1 //outreach.wikimedia.org/wiki/$1', + '__global:outreach' => '1 https://outreach.wikimedia.org/wiki/$1', + '__global:outreachwiki' => '1 https://outreach.wikimedia.org/wiki/$1', '__global:owasp' => '0 https://www.owasp.org/index.php/$1', '__global:panawiki' => '0 http://wiki.alairelibre.net/index.php?title=$1', '__global:patwiki' => '0 http://gauss.ffii.org/$1',