jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/332651 )

Change subject: Copy getMediaWiki() to MWMultiVersion, test usage
......................................................................


Copy getMediaWiki() to MWMultiVersion, test usage

MWMinimalScriptInit is only used by mwrepl, so makes it easy to test
the code moving without impacting much else

Change-Id: I37cba74c69516165ff989b44daf9626294e53ecd
---
M multiversion/MWMinimalScriptInit.php
M multiversion/MWMultiVersion.php
2 files changed, 55 insertions(+), 2 deletions(-)

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



diff --git a/multiversion/MWMinimalScriptInit.php 
b/multiversion/MWMinimalScriptInit.php
index 80161f6..99d9398 100644
--- a/multiversion/MWMinimalScriptInit.php
+++ b/multiversion/MWMinimalScriptInit.php
@@ -6,5 +6,5 @@
                die( 1 );
        }
 } );
-require_once __DIR__ . '/MWVersion.php';
-@require_once getMediaWiki( 'maintenance/commandLine.inc', getenv( 'MW_WIKI' ) 
?: 'testwiki' );
+require_once __DIR__ . '/MWMultiVersion.php';
+@require_once MWMultiVersion::getMediaWiki( 'maintenance/commandLine.inc', 
getenv( 'MW_WIKI' ) ?: 'testwiki' );
diff --git a/multiversion/MWMultiVersion.php b/multiversion/MWMultiVersion.php
index 44fdb58..e6e3c75 100644
--- a/multiversion/MWMultiVersion.php
+++ b/multiversion/MWMultiVersion.php
@@ -369,6 +369,59 @@
        }
 
        /**
+        * 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 = 
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";
+       }
+
+       /**
         * Get the location of the correct version of a MediaWiki CLI
         * entry-point file given the --wiki parameter passed in.
         *

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I37cba74c69516165ff989b44daf9626294e53ecd
Gerrit-PatchSet: 2
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to