* (bug 3000) Fall back to SCRIPT_NAME plus QUERY_STRING when REQUEST_URI is
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 16 Jan 2007 01:45:51 +0000 (01:45 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 16 Jan 2007 01:45:51 +0000 (01:45 +0000)
  not available, as on IIS with PHP-CGI

RELEASE-NOTES
includes/Exception.php
includes/GlobalFunctions.php
includes/Skin.php
includes/WebRequest.php
includes/Wiki.php

index 2ae6787..b25915e 100644 (file)
@@ -76,6 +76,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 8629) Document $wgFilterCallback
 * (bug 1000) Clarify warning about memory_limit in installer
 * Suppress PHP warning about set_time_limit in installer when safe mode is on
+* (bug 3000) Fall back to SCRIPT_NAME plus QUERY_STRING when REQUEST_URI is
+  not available, as on IIS with PHP-CGI
 
 
 == Languages updated ==
index ac9c8a2..ad7ec14 100644 (file)
@@ -54,10 +54,11 @@ class MWException extends Exception
        }
        
        function getLogMessage() {
+               global $wgRequest;
                $file = $this->getFile();
                $line = $this->getLine();
                $message = $this->getMessage();
-               return "{$_SERVER['REQUEST_URI']} Exception from line $line of $file: $message";
+               return $wgRequest->getRequestURL() . " Exception from line $line of $file: $message";
        }
        
        function reportHTML() {
index c52c346..777c02c 100644 (file)
@@ -230,7 +230,7 @@ function wfLogProfilingData() {
                        $forward .= ' anon';
                $log = sprintf( "%s\t%04.3f\t%s\n",
                  gmdate( 'YmdHis' ), $elapsed,
-                 urldecode( $_SERVER['REQUEST_URI'] . $forward ) );
+                 urldecode( $wgRequest->getRequestURL() . $forward ) );
                if ( '' != $wgDebugLogFile && ( $wgRequest->getVal('action') != 'raw' || $wgDebugRawPage ) ) {
                        error_log( $log . $prof, 3, $wgDebugLogFile );
                }
index e7f6df8..0568928 100644 (file)
@@ -782,13 +782,6 @@ END;
        function printableLink() {
                global $wgOut, $wgFeedClasses, $wgRequest;
 
-               $baseurl = $_SERVER['REQUEST_URI'];
-               if( strpos( '?', $baseurl ) == false ) {
-                       $baseurl .= '?';
-               } else {
-                       $baseurl .= '&';
-               }
-               $baseurl = htmlspecialchars( $baseurl );
                $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
 
                $s = "<a href=\"$printurl\">" . wfMsg( 'printableversion' ) . '</a>';
index 3533695..7648b75 100644 (file)
@@ -314,7 +314,20 @@ class WebRequest {
         * @return string
         */
        function getRequestURL() {
-               $base = $_SERVER['REQUEST_URI'];
+               if( isset( $_SERVER['REQUEST_URI'] ) ) {
+                       $base = $_SERVER['REQUEST_URI'];
+               } elseif( isset( $_SERVER['SCRIPT_NAME'] ) ) {
+                       // Probably IIS; doesn't set REQUEST_URI
+                       $base = $_SERVER['SCRIPT_NAME'];
+                       if( isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] != '' ) {
+                               $base .= '?' . $_SERVER['QUERY_STRING'];
+                       }
+               } else {
+                       // This shouldn't happen!
+                       throw new MWException( "Web server doesn't provide either " .
+                               "REQUEST_URI or SCRIPT_NAME. Report details of your " .
+                               "web server configuration to http://bugzilla.wikimedia.org/" );
+               }
                if( $base{0} == '/' ) {
                        return $base;
                } else {
index 4fa421a..06ae8cf 100644 (file)
@@ -118,7 +118,7 @@ class MediaWiki {
         * Initialize the object to be known as $wgArticle for special cases
         */
        function initializeSpecialCases ( &$title, &$output, $request ) {
-
+               global $wgRequest;
                wfProfileIn( 'MediaWiki::initializeSpecialCases' );
                
                $search = $this->getVal('Search');
@@ -151,8 +151,7 @@ class MediaWiki {
                        $targetUrl = $title->getFullURL();
                        // Redirect to canonical url, make it a 301 to allow caching
                        global $wgServer, $wgUsePathInfo;
-                       if( isset( $_SERVER['REQUEST_URI'] ) &&
-                               $targetUrl == $wgServer . $_SERVER['REQUEST_URI'] ) {
+                       if( $targetUrl == $wgRequest->getFullRequestURL() ) {
                                $message = "Redirect loop detected!\n\n" .
                                        "This means the wiki got confused about what page was " .
                                        "requested; this sometimes happens when moving a wiki " .