* Attempt to detect redirect loops for the canonical title redirect, and
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Jan 2007 09:15:11 +0000 (09:15 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Jan 2007 09:15:11 +0000 (09:15 +0000)
  give some hints to the poor confused administrator.

RELEASE-NOTES
includes/GlobalFunctions.php
includes/Wiki.php

index ecad3c0..813efea 100644 (file)
@@ -454,6 +454,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Reduce config file clutter by setting various script and upload paths
   based on $IP or $wgScriptPath in Setup.php. They can still be explicitly
   overridden in LocalSettings.php if desired...
+* Attempt to detect redirect loops for the canonical title redirect, and
+  give some hints to the poor confused administrator.
 
 
 == Languages updated ==
index d91721b..cb91e54 100644 (file)
@@ -1087,7 +1087,7 @@ function wfHttpError( $code, $label, $desc ) {
                "</title></head><body><h1>" .
                htmlspecialchars( $label ) .
                "</h1><p>" .
-               htmlspecialchars( $desc ) .
+               nl2br( htmlspecialchars( $desc ) ) .
                "</p></body></html>\n";
 }
 
index 1eec5f0..4fa421a 100644 (file)
@@ -148,9 +148,36 @@ class MediaWiki {
                        (!isset( $this->GET['title'] ) || $title->getPrefixedDBKey() != $this->GET['title'] ) &&
                        !count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) )
                {
-                       /* Redirect to canonical url, make it a 301 to allow caching */
-                       $output->setSquidMaxage( 1200 );
-                       $output->redirect( $title->getFullURL(), '301');
+                       $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'] ) {
+                               $message = "Redirect loop detected!\n\n" .
+                                       "This means the wiki got confused about what page was " .
+                                       "requested; this sometimes happens when moving a wiki " .
+                                       "to a new server or changing the server configuration.\n\n";
+                               
+                               if( $wgUsePathInfo ) {
+                                       $message .= "The wiki is trying to interpret the page " .
+                                               "title from the URL path portion (PATH_INFO), which " .
+                                               "sometimes fails depending on the web server. Try " .
+                                               "setting \"\$wgUsePathInfo = false;\" in your " .
+                                               "LocalSettings.php, or check that \$wgArticlePath " .
+                                               "is correct.";
+                               } else {
+                                       $message .= "Your web server was detected as possibly not " .
+                                               "supporting URL path components (PATH_INFO) correctly; " .
+                                               "check your LocalSettings.php for a customized " .
+                                               "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " .
+                                               "to true.";
+                               }
+                               wfHttpError( 500, "Internal error", $message );
+                               return false;
+                       } else {
+                               $output->setSquidMaxage( 1200 );
+                               $output->redirect( $targetUrl, '301');
+                       }
                } else if ( NS_SPECIAL == $title->getNamespace() ) {
                        /* actions that need to be made when we have a special pages */
                        SpecialPage::executePath( $title );