r2612 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r2611‎ | r2612 | r2613 >
Date:03:18, 5 March 2004
Author:vibber
Status:old
Tags:
Comment:
Add $wgDebugRedirects to assist in debugging some problems hidden by
automated http redirects.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -100,6 +100,7 @@
101101 # The debug log file should be not be publically accessible if it is
102102 # used, as it may contain private data.
103103 $wgDebugLogFile = "";
 104+$wgDebugRedirects = false;
104105
105106 $wgDebugComments = false;
106107 $wgReadOnly = false;
Index: trunk/phase3/includes/OutputPage.php
@@ -228,6 +228,7 @@
229229 {
230230 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
231231 global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
 232+ global $wgDebugRedirects;
232233 if( $this->mDoNothing ){
233234 return;
234235 }
@@ -236,25 +237,34 @@
237238
238239 $sk = $wgUser->getSkin();
239240
240 -
241241 if ( "" != $this->mRedirect ) {
242242 if( substr( $this->mRedirect, 0, 4 ) != "http" ) {
243243 # Standards require redirect URLs to be absolute
244244 global $wgServer;
245245 $this->mRedirect = $wgServer . $this->mRedirect;
246246 }
247 - if( $this->mRdirectCode == '301') {
248 - header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
 247+ if( $this->mRedirectCode == '301') {
 248+ if( !$wgDebugRedirects ) {
 249+ header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
 250+ }
249251 $this->mLastModified = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix(
250252 max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
251253 }
252254
253255 $this->sendCacheControl();
254256
255 - header( "Location: {$this->mRedirect}" );
 257+ if( $wgDebugRedirects ) {
 258+ $url = htmlspecialchars( $this->mRedirect );
 259+ print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
 260+ print "<p>Location: <a href=\"$url\">$url</a></p>\n";
 261+ print "</body>\n</html>\n";
 262+ } else {
 263+ header( "Location: {$this->mRedirect}" );
 264+ }
256265 return;
257266 }
258267
 268+
259269 $this->sendCacheControl();
260270
261271 header( "Content-type: text/html; charset={$wgOutputEncoding}" );

Status & tagging log