r46178 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46177‎ | r46178 | r46179 >
Date:01:31, 25 January 2009
Author:simetrical
Status:ok
Tags:
Comment:
More helpful error message if PHP_SELF isn't set

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).
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/RawPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RawPage.php
@@ -127,6 +127,15 @@
128128 $url = $_SERVER['PHP_SELF'];
129129 }
130130
 131+ if( $url == '' ) {
 132+ # This will make the next check fail with a confusing error
 133+ # message, so we should mention it separately.
 134+ wfHttpError( 500, 'Internal Server Error',
 135+ "\$_SERVER['PHP_SELF'] is not set. Perhaps you're using CGI" .
 136+ " and haven't set cgi.fix_pathinfo = 1 in php.ini?" );
 137+ return;
 138+ }
 139+
131140 if( strcmp( $wgScript, $url ) ) {
132141 # Internet Explorer will ignore the Content-Type header if it
133142 # thinks it sees a file extension it recognizes. Make sure that
Index: trunk/phase3/RELEASE-NOTES
@@ -59,6 +59,7 @@
6060 * Added optional alternative Search form look - Go button & Advanced search
6161 link instead of Go button & Search button
6262 * (bug 2314) Add links to user custom CSS and JS to Special:Preferences
 63+* More helpful error message on raw page access if PHP_SELF isn't set
6364
6465 === Bug fixes in 1.15 ===
6566 * (bug 16968) Special:Upload no longer throws useless warnings.

Status & tagging log