https://bugzilla.wikimedia.org/show_bug.cgi?id=10023
--- Comment #4 from Nikola Kovacs <[email protected]> 2009-10-29 01:29:51 UTC --- (From update of attachment 6732) >--- RawPage.php.ori 2009-01-25 02:31:48.000000000 +0100 >+++ RawPage.php 2009-10-29 01:34:21.044675925 +0100 >@@ -197,6 +197,84 @@ > } > } > >+ function checkLastModified( $timestamp ) { >+ global $wgCachePages, $wgCacheEpoch, $wgUser; >+ >+ if ( !$timestamp || $timestamp == '19700101000000' ) { >+ wfDebug( __METHOD__ . ": CACHE DISABLED, NO >TIMESTAMP\n" ); >+ return false; >+ } >+ if( !$wgCachePages ) { >+ wfDebug( __METHOD__ . ": CACHE DISABLED\n", false ); >+ return false; >+ } >+ if( $wgUser->getOption( 'nocache' ) ) { >+ wfDebug( __METHOD__ . ": USER DISABLED CACHE\n", false >); >+ return false; >+ } >+ >+ $timestamp = wfTimestamp( TS_MW, $timestamp ); >+ $modifiedTimes = array( >+ 'page' => $timestamp, >+ 'user' => $wgUser->getTouched(), >+ 'epoch' => $wgCacheEpoch >+ ); >+ >+ $maxModified = max( $modifiedTimes ); >+ $lastmod = wfTimestamp( TS_RFC2822, $maxModified ); >+ header( "Last-modified: $lastmod" ); >+ >+ if( empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { >+ 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"] ); >+ >+ wfSuppressWarnings(); // E_STRICT system time bitching >+ $clientHeaderTime = strtotime( $clientHeader ); >+ wfRestoreWarnings(); >+ if ( !$clientHeaderTime ) { >+ wfDebug( __METHOD__ . ": unable to parse the client's >If-Modified-Since header: $clientHeader\n" ); >+ return false; >+ } >+ $clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime ); >+ >+ wfDebug( __METHOD__ . ": client sent If-Modified-Since: " . >+ wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", >false ); >+ wfDebug( __METHOD__ . ": effective Last-Modified: " . >+ wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", false >); >+ if( $clientHeaderTime < $maxModified ) { >+ wfDebug( __METHOD__ . ": STALE, $info\n", false ); >+ return false; >+ } >+ >+ # Not modified >+ # Give a 304 response code and disable body output >+ wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", false ); >+ ini_set('zlib.output_compression', 0); >+ header( "HTTP/1.1 304 Not Modified" ); >+ >+ // Don't output a compressed blob when using ob_gzhandler; >+ // it's technically against HTTP spec and seems to confuse >+ // Firefox when the response gets split over two packets. >+ wfClearOutputBuffers(); >+ >+ return true; >+ } >+ > function getArticleText() { > $found = false; > $text = ''; >@@ -208,13 +286,23 @@ > # If the message doesn't exist, return a blank > if( wfEmptyMsg( $key, $text ) ) > $text = ''; >+ $rev = Revision::newFromTitle( $this->mTitle, 0 >); >+ if( $rev ) { >+ $lastmod = /*wfTimestamp( TS_RFC2822,*/ >$rev->getTimestamp() /*)*/; >+ if ( $this->checkLastModified( $lastmod >) ) { >+ return ''; >+ } >+ } > $found = true; > } else { > // Get it from the DB > $rev = Revision::newFromTitle( $this->mTitle, > $this->mOldId ); > if( $rev ) { >- $lastmod = wfTimestamp( TS_RFC2822, >$rev->getTimestamp() ); >- header( "Last-modified: $lastmod" ); >+ $lastmod = /*wfTimestamp( TS_RFC2822,*/ >$rev->getTimestamp() /*)*/; >+ //header( "Last-modified: $lastmod" ); >+ if ( $this->checkLastModified( $lastmod >) ) { >+ return ''; >+ } > > if( !is_null($this->mSection ) ) { > global $wgParser; -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
