r75812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75811‎ | r75812 | r75813 >
Date:18:48, 1 November 2010
Author:mah
Status:ok
Tags:
Comment:
* Switch to $wgMemc from $parserMemc re 75799
* Change last_modified member var to lastModified re Pre-commit Checklist
Modified paths:
  • /trunk/extensions/RSS/RSS.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RSS/RSS.php
@@ -65,7 +65,7 @@
6666 protected $itemTemplate;
6767 protected $url;
6868 protected $etag;
69 - protected $last_modified;
 69+ protected $lastModified;
7070 protected $xml;
7171 protected $ERROR;
7272
@@ -200,36 +200,42 @@
201201 }
202202
203203 function loadFromCache( $key ) {
204 - global $parserMemc;
 204+ global $wgMemc;
205205
206 - $data = $parserMemc->get( $key );
 206+ $data = $wgMemc->get( $key );
207207 if ( $data === false ) {
208208 return false;
209209 }
210210
211 - list( $etag, $last_modified, $rss ) =
 211+ list( $etag, $lastModified, $rss ) =
212212 unserialize( $data );
213213
214214 if ( !isset( $rss->items ) ) {
215215 return false;
216216 }
217217
 218+ wfDebugLog( 'RSS', "Got '$key' from cache" );
 219+
218220 # Now that we've verified that we got useful data, keep it around.
219221 $this->rss = $rss;
220222 $this->etag = $etag;
221 - $this->last_modified = $last_modified;
 223+ $this->lastModified = $lastModified;
222224
223225 return true;
224226 }
225227
226228 function storeInCache( $key ) {
227 - global $parserMemc, $wgRSSCacheAge;
 229+ global $wgMemc, $wgRSSCacheAge;
228230
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;
233233 }
 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;
234240 }
235241
236242 /**
@@ -245,9 +251,9 @@
246252 wfDebugLog( 'RSS', 'Used etag: ' . $this->etag );
247253 $headers['If-None-Match'] = $this->etag;
248254 }
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;
252258 }
253259
254260 $client =
@@ -336,8 +342,8 @@
337343 // if RSS parsed successfully
338344 if ( $this->rss && !$this->rss->ERROR ) {
339345 $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 ) . ')!' );
342348 $this->storeInCache( $key );
343349
344350 return Status::newGood();

Status & tagging log