]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/parser/ParserCache.php
MediaWiki 1.15.0
[autoinstallsdev/mediawiki.git] / includes / parser / ParserCache.php
index 7e61157a7d8ceaeb7c291821ba3fe1c8ccce891e..d17214c321648eef6d3799e59d9a9574421df88b 100644 (file)
@@ -26,8 +26,14 @@ class ParserCache {
                $this->mMemc =& $memCached;
        }
 
-       function getKey( &$article, &$user ) {
-               global $action;
+       function getKey( &$article, $popts ) {
+               global $wgRequest;
+
+               if( $popts instanceof User )    // It used to be getKey( &$article, &$user )
+                       $popts = ParserOptions::newFromUser( $popts );
+
+               $user = $popts->mUser;
+               $printable = ( $popts->getIsPrintable() ) ? '!printable=1' : '';
                $hash = $user->getPageRenderingHash();
                if( !$article->mTitle->quickUserCan( 'edit' ) ) {
                        // section edit links are suppressed even if the user has them on
@@ -36,21 +42,21 @@ class ParserCache {
                        $edit = '';
                }
                $pageid = $article->getID();
-               $renderkey = (int)($action == 'render');
-               $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}{$edit}" );
+               $renderkey = (int)($wgRequest->getVal('action') == 'render');
+               $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}{$edit}{$printable}" );
                return $key;
        }
 
-       function getETag( &$article, &$user ) {
-               return 'W/"' . $this->getKey($article, $user) . "--" . $article->mTouched. '"';
+       function getETag( &$article, $popts ) {
+               return 'W/"' . $this->getKey($article, $popts) . "--" . $article->mTouched. '"';
        }
 
-       function get( &$article, &$user ) {
+       function get( &$article, $popts ) {
                global $wgCacheEpoch;
                $fname = 'ParserCache::get';
                wfProfileIn( $fname );
 
-               $key = $this->getKey( $article, $user );
+               $key = $this->getKey( $article, $popts );
 
                wfDebug( "Trying parser cache $key\n" );
                $value = $this->mMemc->get( $key );
@@ -86,9 +92,9 @@ class ParserCache {
                return $value;
        }
 
-       function save( $parserOutput, &$article, &$user ){
+       function save( $parserOutput, &$article, $popts ){
                global $wgParserCacheExpireTime;
-               $key = $this->getKey( $article, $user );
+               $key = $this->getKey( $article, $popts );
 
                if( $parserOutput->getCacheTime() != -1 ) {