From 80522a129a31a0f2766eb0e10a01c6c1aeedf8e1 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Mon, 1 Aug 2011 18:03:06 +0000 Subject: [PATCH] Fixes Bug #30061 - Command line installer $wgScriptPath Patch from Edward Z. Yang --- CREDITS | 1 + includes/installer/Installer.php | 21 +-------------------- includes/installer/WebInstaller.php | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/CREDITS b/CREDITS index 50894b9508..5ea87f8441 100644 --- a/CREDITS +++ b/CREDITS @@ -94,6 +94,7 @@ following names for their contribution to the product. * Dan Nessett * Daniel Arnold * Denny Vrandecic +* Edward Z. Yang * Erwin Dokter * FunPika * Gero Scholz diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 4467428330..8615516d0a 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -857,26 +857,7 @@ abstract class Installer { protected function envCheckPath() { global $IP; $IP = dirname( dirname( dirname( __FILE__ ) ) ); - $this->setVar( 'IP', $IP ); - - // PHP_SELF isn't available sometimes, such as when PHP is CGI but - // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME - // to get the path to the current script... hopefully it's reliable. SIGH - if ( !empty( $_SERVER['PHP_SELF'] ) ) { - $path = $_SERVER['PHP_SELF']; - } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) { - $path = $_SERVER['SCRIPT_NAME']; - } elseif ( $this->getVar( 'wgScriptPath' ) ) { - // Some kind soul has set it for us already (e.g. debconf) - return true; - } else { - $this->showError( 'config-no-uri' ); - return false; - } - - $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path ); - $this->setVar( 'wgScriptPath', $uri ); } /** @@ -1252,7 +1233,7 @@ abstract class Installer { require( "$IP/includes/DefaultSettings.php" ); foreach( $exts as $e ) { - require_once( "$IP/extensions/$e/$e.php" ); + require_once( "$IP/extensions/$e/$e.php" ); } $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ? diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 4189ece062..9b6c7da3fa 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -1007,6 +1007,20 @@ class WebInstaller extends Installer { } } + // PHP_SELF isn't available sometimes, such as when PHP is CGI but + // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME + // to get the path to the current script... hopefully it's reliable. SIGH + $path = false; + if ( !empty( $_SERVER['PHP_SELF'] ) ) { + $path = $_SERVER['PHP_SELF']; + } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) { + $path = $_SERVER['SCRIPT_NAME']; + } + if ($path !== false) { + $uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path ); + $this->setVar( 'wgScriptPath', $uri ); + } + return $newValues; } -- 2.20.1