Add $wgDebugRedirects to assist in debugging some problems hidden by
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 5 Mar 2004 03:18:31 +0000 (03:18 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 5 Mar 2004 03:18:31 +0000 (03:18 +0000)
automated http redirects.

includes/DefaultSettings.php
includes/OutputPage.php

index d35ad00..0b4ba98 100644 (file)
@@ -100,6 +100,7 @@ $wgReadOnlyFile         = "{$wgUploadDirectory}/lock_yBgMBwiR";
 # The debug log file should be not be publically accessible if it is
 # used, as it may contain private data.
 $wgDebugLogFile         = "";
+$wgDebugRedirects              = false;
 
 $wgDebugComments        = false;
 $wgReadOnly             = false;
index 1b645df..8aaa8d4 100644 (file)
@@ -228,6 +228,7 @@ class OutputPage {
        {
                global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
                global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
+               global $wgDebugRedirects;
                if( $this->mDoNothing ){
                        return;
                }
@@ -236,25 +237,34 @@ class OutputPage {
                
                $sk = $wgUser->getSkin();
 
-               
                if ( "" != $this->mRedirect ) {
                        if( substr( $this->mRedirect, 0, 4 ) != "http" ) {
                                # Standards require redirect URLs to be absolute
                                global $wgServer;
                                $this->mRedirect = $wgServer . $this->mRedirect;
                        }
-                       if( $this->mRdirectCode == '301') {
-                               header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
+                       if( $this->mRedirectCode == '301') {
+                               if( !$wgDebugRedirects ) {
+                                       header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
+                               }
                                $this->mLastModified = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix(
                                        max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
                        }
                         
                        $this->sendCacheControl();
                        
-                       header( "Location: {$this->mRedirect}" );
+                       if( $wgDebugRedirects ) {
+                               $url = htmlspecialchars( $this->mRedirect );
+                               print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
+                               print "<p>Location: <a href=\"$url\">$url</a></p>\n";
+                               print "</body>\n</html>\n";
+                       } else {
+                               header( "Location: {$this->mRedirect}" );
+                       }
                        return;
                }
                
+               
                $this->sendCacheControl();
                
                header( "Content-type: text/html; charset={$wgOutputEncoding}" );