Index: trunk/extensions/RSS/RSS.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | protected $itemTemplate; |
67 | 67 | protected $url; |
68 | 68 | protected $etag; |
69 | | - protected $last_modified; |
| 69 | + protected $lastModified; |
70 | 70 | protected $xml; |
71 | 71 | protected $ERROR; |
72 | 72 | |
— | — | @@ -200,36 +200,42 @@ |
201 | 201 | } |
202 | 202 | |
203 | 203 | function loadFromCache( $key ) { |
204 | | - global $parserMemc; |
| 204 | + global $wgMemc; |
205 | 205 | |
206 | | - $data = $parserMemc->get( $key ); |
| 206 | + $data = $wgMemc->get( $key ); |
207 | 207 | if ( $data === false ) { |
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
211 | | - list( $etag, $last_modified, $rss ) = |
| 211 | + list( $etag, $lastModified, $rss ) = |
212 | 212 | unserialize( $data ); |
213 | 213 | |
214 | 214 | if ( !isset( $rss->items ) ) { |
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
| 218 | + wfDebugLog( 'RSS', "Got '$key' from cache" ); |
| 219 | + |
218 | 220 | # Now that we've verified that we got useful data, keep it around. |
219 | 221 | $this->rss = $rss; |
220 | 222 | $this->etag = $etag; |
221 | | - $this->last_modified = $last_modified; |
| 223 | + $this->lastModified = $lastModified; |
222 | 224 | |
223 | 225 | return true; |
224 | 226 | } |
225 | 227 | |
226 | 228 | function storeInCache( $key ) { |
227 | | - global $parserMemc, $wgRSSCacheAge; |
| 229 | + global $wgMemc, $wgRSSCacheAge; |
228 | 230 | |
229 | | - if( isset( $this->rss ) ) { |
230 | | - return $parserMemc->set($key, |
231 | | - serialize( array($this->etag, $this->last_modified, |
232 | | - $this->rss) ), $wgRSSCacheAge); |
| 231 | + if( !isset( $this->rss ) ) { |
| 232 | + return false; |
233 | 233 | } |
| 234 | + $wgMemc->set($key, |
| 235 | + serialize( array($this->etag, $this->lastModified, $this->rss) ), |
| 236 | + $wgRSSCacheAge); |
| 237 | + |
| 238 | + wfDebugLog( 'RSS', "Stored '$key' in cache" ); |
| 239 | + return true; |
234 | 240 | } |
235 | 241 | |
236 | 242 | /** |
— | — | @@ -245,9 +251,9 @@ |
246 | 252 | wfDebugLog( 'RSS', 'Used etag: ' . $this->etag ); |
247 | 253 | $headers['If-None-Match'] = $this->etag; |
248 | 254 | } |
249 | | - if ( $this->last_modified ) { |
250 | | - wfDebugLog( 'RSS', 'Used last modified: ' . $this->last_modified ); |
251 | | - $headers['If-Last-Modified'] = $this->last_modified; |
| 255 | + if ( $this->lastModified ) { |
| 256 | + wfDebugLog( 'RSS', 'Used last modified: ' . $this->lastModified ); |
| 257 | + $headers['If-Last-Modified'] = $this->lastModified; |
252 | 258 | } |
253 | 259 | |
254 | 260 | $client = |
— | — | @@ -336,8 +342,8 @@ |
337 | 343 | // if RSS parsed successfully |
338 | 344 | if ( $this->rss && !$this->rss->ERROR ) { |
339 | 345 | $this->etag = $this->client->getResponseHeader( 'Etag' ); |
340 | | - $this->last_modified = $this->client->getResponseHeader( 'Last-Modified' ); |
341 | | - wfDebugLog( 'RSS', 'Stored etag (' . $this->etag . ') and Last-Modified (' . $this->last_modified . ') and items (' . count( $this->rss->items ) . ')!' ); |
| 346 | + $this->lastModified = $this->client->getResponseHeader( 'Last-Modified' ); |
| 347 | + wfDebugLog( 'RSS', 'Stored etag (' . $this->etag . ') and Last-Modified (' . $this->lastModified . ') and items (' . count( $this->rss->items ) . ')!' ); |
342 | 348 | $this->storeInCache( $key ); |
343 | 349 | |
344 | 350 | return Status::newGood(); |