Index: trunk/phase3/includes/parser/ParserCache.php |
— | — | @@ -37,14 +37,14 @@ |
38 | 38 | } |
39 | 39 | $this->mMemc = $memCached; |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | protected function getParserOutputKey( $article, $hash ) { |
43 | 43 | global $wgRequest; |
44 | | - |
| 44 | + |
45 | 45 | // idhash seem to mean 'page id' + 'rendering hash' (r3710) |
46 | 46 | $pageid = $article->getID(); |
47 | 47 | $renderkey = (int)($wgRequest->getVal('action') == 'render'); |
48 | | - |
| 48 | + |
49 | 49 | $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" ); |
50 | 50 | return $key; |
51 | 51 | } |
— | — | @@ -55,17 +55,17 @@ |
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | | - * Provides an E-Tag suitable for the whole page. Note that $article |
60 | | - * is just the main wikitext. The E-Tag has to be unique to the whole |
61 | | - * page, even if the article itself is the same, so it uses the |
62 | | - * complete set of user options. We don't want to use the preference |
63 | | - * of a different user on a message just because it wasn't used in |
64 | | - * $article. For example give a Chinese interface to a user with |
65 | | - * English preferences. That's why we take into account *all* user |
| 59 | + * Provides an E-Tag suitable for the whole page. Note that $article |
| 60 | + * is just the main wikitext. The E-Tag has to be unique to the whole |
| 61 | + * page, even if the article itself is the same, so it uses the |
| 62 | + * complete set of user options. We don't want to use the preference |
| 63 | + * of a different user on a message just because it wasn't used in |
| 64 | + * $article. For example give a Chinese interface to a user with |
| 65 | + * English preferences. That's why we take into account *all* user |
66 | 66 | * options. (r70809 CR) |
67 | 67 | */ |
68 | 68 | function getETag( $article, $popts ) { |
69 | | - return 'W/"' . $this->getParserOutputKey( $article, |
| 69 | + return 'W/"' . $this->getParserOutputKey( $article, |
70 | 70 | $popts->optionsHash( ParserOptions::legacyOptions() ) ) . |
71 | 71 | "--" . $article->mTouched . '"'; |
72 | 72 | } |
— | — | @@ -80,19 +80,19 @@ |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Used to provide a unique id for the PoolCounter. |
84 | | - * It would be preferable to have this code in get() |
| 84 | + * It would be preferable to have this code in get() |
85 | 85 | * instead of having Article looking in our internals. |
86 | | - * |
| 86 | + * |
87 | 87 | * Precondition: $article->checkTouched() has been called. |
88 | 88 | */ |
89 | 89 | public function getKey( $article, $popts, $useOutdated = true ) { |
90 | 90 | global $wgCacheEpoch; |
91 | | - |
| 91 | + |
92 | 92 | if( $popts instanceof User ) { |
93 | 93 | wfWarn( "Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n" ); |
94 | 94 | $popts = ParserOptions::newFromUser( $popts ); |
95 | 95 | } |
96 | | - |
| 96 | + |
97 | 97 | // Determine the options which affect this article |
98 | 98 | $optionsKey = $this->mMemc->get( $this->getOptionsKey( $article ) ); |
99 | 99 | if ( $optionsKey != false ) { |
— | — | @@ -102,12 +102,12 @@ |
103 | 103 | wfDebug( "Parser options key expired, touched {$article->mTouched}, epoch $wgCacheEpoch, cached $cacheTime\n" ); |
104 | 104 | return false; |
105 | 105 | } |
106 | | - |
| 106 | + |
107 | 107 | $usedOptions = $optionsKey->mUsedOptions; |
108 | 108 | wfDebug( "Parser cache options found.\n" ); |
109 | 109 | } else { |
110 | 110 | # TODO: Fail here $wgParserCacheExpireTime after deployment unless $useOutdated |
111 | | - |
| 111 | + |
112 | 112 | $usedOptions = ParserOptions::legacyOptions(); |
113 | 113 | } |
114 | 114 | |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | |
133 | 133 | // Having called checkTouched() ensures this will be loaded |
134 | 134 | $touched = $article->mTouched; |
135 | | - |
| 135 | + |
136 | 136 | $parserOutputKey = $this->getKey( $article, $popts, $useOutdated ); |
137 | 137 | if ( $parserOutputKey === false ) { |
138 | 138 | wfProfileOut( __METHOD__ ); |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | } |
149 | 149 | |
150 | 150 | wfDebug( "Found.\n" ); |
151 | | - |
| 151 | + |
152 | 152 | if ( !$useOutdated && $value->expired( $touched ) ) { |
153 | 153 | wfIncrStats( "pcache_miss_expired" ); |
154 | 154 | $cacheTime = $value->getCacheTime(); |
— | — | @@ -168,13 +168,13 @@ |
169 | 169 | public function save( $parserOutput, $article, $popts ) { |
170 | 170 | $expire = $parserOutput->getCacheExpiry(); |
171 | 171 | |
172 | | - if( $expire > 0 ) { |
| 172 | + if( $expire > 0 ) { |
173 | 173 | $now = wfTimestampNow(); |
174 | 174 | |
175 | | - $optionsKey = new CacheTime; |
| 175 | + $optionsKey = new CacheTime; |
176 | 176 | $optionsKey->mUsedOptions = $popts->usedOptions(); |
177 | 177 | $optionsKey->updateCacheExpiry( $expire ); |
178 | | - |
| 178 | + |
179 | 179 | $optionsKey->setCacheTime( $now ); |
180 | 180 | $parserOutput->setCacheTime( $now ); |
181 | 181 | |