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

Change subject: Allow absolute script path for getMediaWikiCli()
......................................................................


Allow absolute script path for getMediaWikiCli()

This patch makes mwscript to use absolute path if given.
This enables to run scripts that are not in mediawiki repo via
mwscript.

This does not add security concerns since a) it's command-line only
and b) you could always do it with adding ../../../.. etc. but
with this patch you can do it with just providing absolute path.

Change-Id: I1a72aab4b2fa0580ae3603cbf4e18c8da4f66c6c
---
M multiversion/MWMultiVersion.php
1 file changed, 7 insertions(+), 3 deletions(-)

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



diff --git a/multiversion/MWMultiVersion.php b/multiversion/MWMultiVersion.php
index 4fafd6b..9a0f10d 100644
--- a/multiversion/MWMultiVersion.php
+++ b/multiversion/MWMultiVersion.php
@@ -442,14 +442,14 @@
         * (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 $file string File path (relative to MediaWiki dir or absolute)
         * @return string Absolute file path with proper MW location
         */
        public static function getMediaWikiCli( $file ) {
                global $IP;
 
                $multiVersion = self::getInstance();
-               if( !$multiVersion ) {
+               if ( !$multiVersion ) {
                        $multiVersion = self::initializeForMaintenance();
                }
                if ( $multiVersion->getDatabase() === 'testwiki' ) {
@@ -464,6 +464,10 @@
 
                putenv( "MW_INSTALL_PATH=$IP" );
 
-               return "$IP/$file";
+               if ( $file !== "" && $file[0] === '/' ) {
+                       return $file;
+               } else {
+                       return "$IP/$file";
+               }
        }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1a72aab4b2fa0580ae3603cbf4e18c8da4f66c6c
Gerrit-PatchSet: 4
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to