More helpful error message if PHP_SELF isn't set
authorAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 25 Jan 2009 01:31:48 +0000 (01:31 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 25 Jan 2009 01:31:48 +0000 (01:31 +0000)
Raw page access was failing in some server configurations with CGI (or
in my case, FastCGI).  This gives a nicer and more correct error
message.  Possibly better solutions:

1) Figure out how to do this without PHP_SELF.

2) Give a warning or error on installation, or even on every page view,
since this will break all raw page viewing.

I ran into this when doing a file copy of my wiki install to another
site, FWIW.  Even with the new error message, I'd have had to look at
the CSS files to figure out what the problem was (the user-visible
symptom was that custom styles didn't work).

RELEASE-NOTES
includes/RawPage.php

index b1ac48c..24c52b4 100644 (file)
@@ -59,6 +59,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Added optional alternative Search form look - Go button & Advanced search
   link instead of Go button & Search button
 * (bug 2314) Add links to user custom CSS and JS to Special:Preferences
+* More helpful error message on raw page access if PHP_SELF isn't set
 
 === Bug fixes in 1.15 ===
 * (bug 16968) Special:Upload no longer throws useless warnings.
index b16b8fa..b422d49 100644 (file)
@@ -127,6 +127,15 @@ class RawPage {
                        $url = $_SERVER['PHP_SELF'];
                }
 
+               if( $url == '' ) {
+                       # This will make the next check fail with a confusing error
+                       # message, so we should mention it separately.
+                       wfHttpError( 500, 'Internal Server Error',
+                               "\$_SERVER['PHP_SELF'] is not set.  Perhaps you're using CGI" .
+                               " and haven't set cgi.fix_pathinfo = 1 in php.ini?" );
+                       return;
+               }
+
                if( strcmp( $wgScript, $url ) ) {
                        # Internet Explorer will ignore the Content-Type header if it
                        # thinks it sees a file extension it recognizes. Make sure that