Use WebRequest instead of $_SERVER in OutputPage.
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 19 Jul 2012 16:35:25 +0000 (18:35 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Thu, 19 Jul 2012 16:46:39 +0000 (18:46 +0200)
Also moved debug string generation a bit lower so that
it's executed only when it will actually be used.

Change-Id: Ia01e7fb1dba1f2f55c156d3ac097acf2a68dca70

includes/OutputPage.php

index 1b4bc49..bf70467 100644 (file)
@@ -647,24 +647,16 @@ class OutputPage extends ContextSource {
                $maxModified = max( $modifiedTimes );
                $this->mLastModified = wfTimestamp( TS_RFC2822, $maxModified );
 
-               if( empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
+               $clientHeader = $this->getRequest()->getHeader( 'If-Modified-Since' );
+               if ( $clientHeader === false ) {
                        wfDebug( __METHOD__ . ": client did not send If-Modified-Since header\n", false );
                        return false;
                }
 
-               # Make debug info
-               $info = '';
-               foreach ( $modifiedTimes as $name => $value ) {
-                       if ( $info !== '' ) {
-                               $info .= ', ';
-                       }
-                       $info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
-               }
-
                # IE sends sizes after the date like this:
                # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
                # this breaks strtotime().
-               $clientHeader = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
+               $clientHeader = preg_replace( '/;.*$/', '', $clientHeader );
 
                wfSuppressWarnings(); // E_STRICT system time bitching
                $clientHeaderTime = strtotime( $clientHeader );
@@ -675,6 +667,15 @@ class OutputPage extends ContextSource {
                }
                $clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime );
 
+               # Make debug info
+               $info = '';
+               foreach ( $modifiedTimes as $name => $value ) {
+                       if ( $info !== '' ) {
+                               $info .= ', ';
+                       }
+                       $info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
+               }
+
                wfDebug( __METHOD__ . ": client sent If-Modified-Since: " .
                        wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", false );
                wfDebug( __METHOD__ . ": effective Last-Modified: " .