Hello Thcipriani, Krinkle, Reedy, 20after4, jenkins-bot,
I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/331673
to review the following change.
Change subject: Fuck you Multiversion
......................................................................
Fuck you Multiversion
Revert "Reinstate "Remove MWVersion, fold its two functions into
MWMultiVersion""
This reverts commit 8fdc87387da62fc131bb48c0260fe311fc6091af.
Change-Id: I575172862e59eaa2a930bbf07ebdf9b7fd292aee
---
M multiversion/MWMinimalScriptInit.php
M multiversion/MWMultiVersion.php
M multiversion/MWScript.php
M multiversion/MWVersion.php
M rpc/RunJobs.php
M w/api.php
M w/auth-api.php
M w/extract2.php
M w/favicon.php
M w/img_auth.php
M w/index.php
M w/load.php
M w/mobilelanding.php
M w/opensearch_desc.php
M w/robots.php
M w/static.php
M w/thumb.php
M w/thumb_handler.php
M w/touch.php
19 files changed, 86 insertions(+), 123 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config
refs/changes/73/331673/1
diff --git a/multiversion/MWMinimalScriptInit.php
b/multiversion/MWMinimalScriptInit.php
index 99d9398..80161f6 100644
--- a/multiversion/MWMinimalScriptInit.php
+++ b/multiversion/MWMinimalScriptInit.php
@@ -6,5 +6,5 @@
die( 1 );
}
} );
-require_once __DIR__ . '/MWMultiVersion.php';
-@require_once MWMultiVersion::getMediaWiki( 'maintenance/commandLine.inc',
getenv( 'MW_WIKI' ) ?: 'testwiki' );
+require_once __DIR__ . '/MWVersion.php';
+@require_once getMediaWiki( 'maintenance/commandLine.inc', getenv( 'MW_WIKI' )
?: 'testwiki' );
diff --git a/multiversion/MWMultiVersion.php b/multiversion/MWMultiVersion.php
index 5ff1c48..521b8a8 100644
--- a/multiversion/MWMultiVersion.php
+++ b/multiversion/MWMultiVersion.php
@@ -367,91 +367,4 @@
trigger_error( $msg, E_USER_ERROR );
exit( 1 ); // sanity
}
-
- /**
- * Get the location of the correct version of a MediaWiki web
- * entry-point file given environmental variables such as the server
name.
- * This function should only be called on web views.
- *
- * If the wiki doesn't exist, then wmf-config/missing.php will
- * be included (and thus displayed) and PHP will exit.
- *
- * If it does, then this function also has some other effects:
- * (a) Sets the $IP global variable (path to MediaWiki)
- * (b) Sets the MW_INSTALL_PATH environmental variable
- * (c) Changes PHP's current directory to the directory of this file.
- *
- * @param $file string File path (relative to MediaWiki dir)
- * @param $wiki string Force the Wiki ID rather than detecting it
- * @return string Absolute file path with proper MW location
- */
- public static function getMediaWiki( $file, $wiki = null ) {
- global $IP;
-
- if ( $wiki === null ) {
- $scriptName = @$_SERVER['SCRIPT_NAME'];
- $serverName = @$_SERVER['SERVER_NAME'];
- # Upload URL hit (to upload.wikimedia.org rather than
wiki of origin)...
- if ( $scriptName === '/w/thumb.php' && $serverName ===
'upload.wikimedia.org' ) {
- $multiVersion = self::initializeForUploadWiki(
$_SERVER['PATH_INFO'] );
- # Regular URL hit (wiki of origin)...
- } else {
- $multiVersion = self::initializeForWiki(
$serverName );
- }
- } else {
- $multiVersion = self::initializeFromDBName( $wiki );
- }
-
- # Wiki doesn't exist yet?
- if ( $multiVersion->isMissing() ) {
- header( "Cache-control: no-cache" ); // same hack as
CommonSettings.php
- include( MEDIAWIKI_DEPLOYMENT_DIR .
'/wmf-config/missing.php' );
- exit;
- }
-
- # Get the MediaWiki version running on this wiki...
- $version = $multiVersion->getVersion();
-
- # Get the correct MediaWiki path based on this version...
- $IP = MEDIAWIKI_DEPLOYMENT_DIR . "/$version";
-
- chdir( $IP );
- putenv( "MW_INSTALL_PATH=$IP" );
-
- return "$IP/$file";
- }
-
- /**
- * Get the location of the correct version of a MediaWiki CLI
- * entry-point file given the --wiki parameter passed in.
- *
- * This also has some other effects:
- * (a) Sets the $IP global variable (path to MediaWiki)
- * (b) Sets the MW_INSTALL_PATH environmental variable
- * (c) Changes PHP's current directory to the directory of this file.
- *
- * @param $file string File path (relative to MediaWiki dir)
- * @return string Absolute file path with proper MW location
- */
- public static function getMediaWikiCli( $file ) {
- global $IP;
-
- $multiVersion = self::getInstance();
- if( !$multiVersion ) {
- $multiVersion = self::initializeForMaintenance();
- }
- if ( $multiVersion->getDatabase() === 'testwiki' ) {
- define( 'TESTWIKI', 1 );
- }
-
- # Get the MediaWiki version running on this wiki...
- $version = $multiVersion->getVersion();
-
- # Get the correct MediaWiki path based on this version...
- $IP = dirname( __DIR__ ) . "/$version";
-
- putenv( "MW_INSTALL_PATH=$IP" );
-
- return "$IP/$file";
- }
}
diff --git a/multiversion/MWScript.php b/multiversion/MWScript.php
index 19d62bc..281d6ea 100644
--- a/multiversion/MWScript.php
+++ b/multiversion/MWScript.php
@@ -83,8 +83,8 @@
}
# MWScript.php should be in common/
- require_once __DIR__ . '/MWMultiVersion.php';
- $file = MWMultiVersion::getMediaWikiCli( $relFile );
+ require_once __DIR__ . '/MWVersion.php';
+ $file = getMediaWikiCli( $relFile );
if ( !file_exists( $file ) ) {
fwrite( STDERR, "The MediaWiki script file \"{$file}\" does not
exist.\n" );
exit( 1 );
diff --git a/multiversion/MWVersion.php b/multiversion/MWVersion.php
index 8e6b735..8c5dcae 100644
--- a/multiversion/MWVersion.php
+++ b/multiversion/MWVersion.php
@@ -17,8 +17,40 @@
* @return string Absolute file path with proper MW location
*/
function getMediaWiki( $file, $wiki = null ) {
+ global $IP;
require_once( __DIR__ . '/MWMultiVersion.php' );
- require MWMultiVersion::getMediaWiki( $file, $wiki );
+
+ if ( $wiki === null ) {
+ $scriptName = @$_SERVER['SCRIPT_NAME'];
+ $serverName = @$_SERVER['SERVER_NAME'];
+ # Upload URL hit (to upload.wikimedia.org rather than wiki of
origin)...
+ if ( $scriptName === '/w/thumb.php' && $serverName ===
'upload.wikimedia.org' ) {
+ $multiVersion =
MWMultiVersion::initializeForUploadWiki( $_SERVER['PATH_INFO'] );
+ # Regular URL hit (wiki of origin)...
+ } else {
+ $multiVersion = MWMultiVersion::initializeForWiki(
$serverName );
+ }
+ } else {
+ $multiVersion = MWMultiVersion::initializeFromDBName( $wiki );
+ }
+
+ # Wiki doesn't exist yet?
+ if ( $multiVersion->isMissing() ) {
+ header( "Cache-control: no-cache" ); // same hack as
CommonSettings.php
+ include( MEDIAWIKI_DEPLOYMENT_DIR . '/wmf-config/missing.php' );
+ exit;
+ }
+
+ # Get the MediaWiki version running on this wiki...
+ $version = $multiVersion->getVersion();
+
+ # Get the correct MediaWiki path based on this version...
+ $IP = MEDIAWIKI_DEPLOYMENT_DIR . "/$version";
+
+ chdir( $IP );
+ putenv( "MW_INSTALL_PATH=$IP" );
+
+ return "$IP/$file";
}
/**
@@ -34,6 +66,24 @@
* @return string Absolute file path with proper MW location
*/
function getMediaWikiCli( $file ) {
+ global $IP;
+
require_once( __DIR__ . '/MWMultiVersion.php' );
- require MWMultiVersion::getMediaWikiCli( $file );
+ $multiVersion = MWMultiVersion::getInstance();
+ if( !$multiVersion ) {
+ $multiVersion = MWMultiVersion::initializeForMaintenance();
+ }
+ if ( $multiVersion->getDatabase() === 'testwiki' ) {
+ define( 'TESTWIKI', 1 );
+ }
+
+ # Get the MediaWiki version running on this wiki...
+ $version = $multiVersion->getVersion();
+
+ # Get the correct MediaWiki path based on this version...
+ $IP = dirname( __DIR__ ) . "/$version";
+
+ putenv( "MW_INSTALL_PATH=$IP" );
+
+ return "$IP/$file";
}
diff --git a/rpc/RunJobs.php b/rpc/RunJobs.php
index 2db74e7..ccc0e6d 100755
--- a/rpc/RunJobs.php
+++ b/rpc/RunJobs.php
@@ -26,9 +26,9 @@
define( 'MEDIAWIKI_JOB_RUNNER', 1 );
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
+require_once __DIR__ . '/../multiversion/MWVersion.php';
$wiki = isset( $_GET['wiki'] ) ? $_GET['wiki'] : '';
-require MWMultiVersion::getMediaWiki( 'includes/WebStart.php', $wiki );
+require getMediaWiki( 'includes/WebStart.php', $wiki );
error_reporting( E_ERROR ); // fatals but not random I/O warnings
ini_set( 'display_errors', 1 );
diff --git a/w/api.php b/w/api.php
index 78ed40b..8802cc8 100644
--- a/w/api.php
+++ b/w/api.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'api.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'api.php' );
diff --git a/w/auth-api.php b/w/auth-api.php
index 2e53f19..03114ba 100644
--- a/w/auth-api.php
+++ b/w/auth-api.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'extensions/SecurePoll/auth-api.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'extensions/SecurePoll/auth-api.php' );
diff --git a/w/extract2.php b/w/extract2.php
index c9895c5..d4448ba 100644
--- a/w/extract2.php
+++ b/w/extract2.php
@@ -2,8 +2,8 @@
$lang = 'meta';
putenv( "MW_LANG={$lang}" ); // notify MWMultiVersion
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'includes/WebStart.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'includes/WebStart.php' );
$allowed_templates = array(
'Www.wikimedia.org_template',
diff --git a/w/favicon.php b/w/favicon.php
index 3e90996..29ce43e 100644
--- a/w/favicon.php
+++ b/w/favicon.php
@@ -1,6 +1,6 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'includes/WebStart.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'includes/WebStart.php' );
function faviconShowError( $text ) {
header( 'Content-Type: text/html; charset=utf-8' );
diff --git a/w/img_auth.php b/w/img_auth.php
index fbabd1a..0c2a848 100644
--- a/w/img_auth.php
+++ b/w/img_auth.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'img_auth.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'img_auth.php' );
diff --git a/w/index.php b/w/index.php
index 04ac45d..ec3d0d3 100644
--- a/w/index.php
+++ b/w/index.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'index.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'index.php' );
diff --git a/w/load.php b/w/load.php
index 8f8c03c..5d0c594 100644
--- a/w/load.php
+++ b/w/load.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'load.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'load.php' );
diff --git a/w/mobilelanding.php b/w/mobilelanding.php
index 6811cb6..27bfd19 100644
--- a/w/mobilelanding.php
+++ b/w/mobilelanding.php
@@ -1,8 +1,8 @@
<?php
putenv( 'MW_LANG=en' ); // notify MWMultiVersion
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'includes/WebStart.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'includes/WebStart.php' );
$code = '302';
$state = ZeroBanner\PageRenderingHooks::getState();
diff --git a/w/opensearch_desc.php b/w/opensearch_desc.php
index eb6a191..57b4789 100644
--- a/w/opensearch_desc.php
+++ b/w/opensearch_desc.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'opensearch_desc.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'opensearch_desc.php' );
diff --git a/w/robots.php b/w/robots.php
index 127efc2..5cf4ab9 100644
--- a/w/robots.php
+++ b/w/robots.php
@@ -1,6 +1,6 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'includes/WebStart.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'includes/WebStart.php' );
$wgTitle = Title::newFromText( 'Mediawiki:robots.txt' );
$page = WikiPage::factory( $wgTitle );
diff --git a/w/static.php b/w/static.php
index 618a6dc..c7afb50 100644
--- a/w/static.php
+++ b/w/static.php
@@ -26,8 +26,8 @@
* - wmfstatic.mismatch
*/
define( 'MW_NO_SESSION', 'warn' );
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'includes/WebStart.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'includes/WebStart.php' );
function wmfStaticShowError( $message, $status, $smaxage = 60 ) {
HttpStatus::header( $status );
diff --git a/w/thumb.php b/w/thumb.php
index e44ef58..d10d668 100644
--- a/w/thumb.php
+++ b/w/thumb.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'thumb.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'thumb.php' );
diff --git a/w/thumb_handler.php b/w/thumb_handler.php
index ee0b6f9..a80876f 100644
--- a/w/thumb_handler.php
+++ b/w/thumb_handler.php
@@ -1,3 +1,3 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'thumb_handler.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'thumb_handler.php' );
diff --git a/w/touch.php b/w/touch.php
index 561f540..322889c 100644
--- a/w/touch.php
+++ b/w/touch.php
@@ -1,6 +1,6 @@
<?php
-require_once __DIR__ . '/../multiversion/MWMultiVersion.php';
-require MWMultiVersion::getMediaWiki( 'includes/WebStart.php' );
+require_once __DIR__ . '/../multiversion/MWVersion.php';
+require getMediaWiki( 'includes/WebStart.php' );
function faviconShowError( $text ) {
header( 'Content-Type: text/html; charset=utf-8' );
--
To view, visit https://gerrit.wikimedia.org/r/331673
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I575172862e59eaa2a930bbf07ebdf9b7fd292aee
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
Gerrit-Reviewer: 20after4 <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Thcipriani <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits