r75811 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:< r75810‎ | r75811 | r75812 >
Date:18:29, 1 November 2010
Author:mah
Status:ok
Tags:
Comment:
stylize, remove error_log
Modified paths:
  • /trunk/extensions/RSS/RSS.php (modified) (history)
  • /trunk/extensions/RSS/RSSData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RSS/RSSData.php
——@@ -5,7 +5,7 @@
66 public $items;
77
88 function __construct( $xml ) {
9 - if( !( $xml instanceOf DOMDocument ) ) {
 9+ if ( !( $xml instanceOf DOMDocument ) ) {
1010 return null;
1111 }
1212 $xpath = new DOMXPath( $xml );
Index: trunk/extensions/RSS/RSS.php
——@@ -84,7 +84,7 @@
8585 }
8686 $parser->disableCache();
8787
88 - $rss = new RSS($input, $args);
 88+ $rss = new RSS( $input, $args );
8989
9090 $status = $rss->fetch();
9191
——@@ -95,7 +95,7 @@
9696 if ( isset( $rss->ERROR ) )
9797 return wfMsg( 'rss-error', $rss->ERROR );
9898
99 - return $rss->renderFeed($parser, $frame);
 99+ return $rss->renderFeed( $parser, $frame );
100100 }
101101
102102 static function explodeOnSpaces( $str ) {
——@@ -103,9 +103,9 @@
104104 return is_array( $found ) ? $found : array();
105105 }
106106
107 - function __construct($url, $args) {
 107+ function __construct( $url, $args ) {
108108
109 - if( isset($url) ) {
 109+ if ( isset( $url ) ) {
110110 $this->url = $url;
111111 }
112112
——@@ -149,9 +149,9 @@
150150 }
151151
152152 if ( isset( $args['template'] ) ) {
153 - $titleObject = Title::newFromText($args['template'], NS_TEMPLATE);
154 - $article = new Article($titleObject, 0);
155 - $this->itemTemplate = $article->fetchContent(0);
 153+ $titleObject = Title::newFromText( $args['template'], NS_TEMPLATE );
 154+ $article = new Article( $titleObject, 0 );
 155+ $this->itemTemplate = $article->fetchContent( 0 );
156156 } else {
157157 $this->itemTemplate = wfMsgNoTrans( 'rss-item' );
158158 }
——@@ -188,29 +188,29 @@
189189 // 3. if cached obj fails freshness check, fetch remote
190190 // 4. if remote fails, return stale object, or error
191191 $key = wfMemcKey( $this->url );
192 - $cachedFeed = $this->loadFromCache($key);
193 - if( $cachedFeed !== false ) {
194 - wfDebugLog( 'RSS', 'Outputting cached feed for '.$this->url );
 192+ $cachedFeed = $this->loadFromCache( $key );
 193+ if ( $cachedFeed !== false ) {
 194+ wfDebugLog( 'RSS', 'Outputting cached feed for ' . $this->url );
195195 return true;
196196 }
197 - wfDebugLog( 'RSS', 'Cache Failed '.$this->url );
 197+ wfDebugLog( 'RSS', 'Cache Failed ' . $this->url );
198198
199 - $status = $this->fetchRemote($key);
 199+ $status = $this->fetchRemote( $key );
200200 return $status;
201201 }
202202
203203 function loadFromCache( $key ) {
204204 global $parserMemc;
205205
206 - $data = $parserMemc->get($key);
207 - if ($data === false) {
 206+ $data = $parserMemc->get( $key );
 207+ if ( $data === false ) {
208208 return false;
209209 }
210210
211 - list($etag, $last_modified, $rss) =
212 - unserialize($data);
 211+ list( $etag, $last_modified, $rss ) =
 212+ unserialize( $data );
213213
214 - if( !isset( $rss->items ) ) {
 214+ if ( !isset( $rss->items ) ) {
215215 return false;
216216 }
217217
——@@ -242,11 +242,11 @@
243243 global $wgRSSFetchTimeout, $wgRSSUseGzip;
244244
245245 if ( $this->etag ) {
246 - wfDebugLog( 'RSS', 'Used etag: '.$this->etag );
 246+ wfDebugLog( 'RSS', 'Used etag: ' . $this->etag );
247247 $headers['If-None-Match'] = $this->etag;
248248 }
249249 if ( $this->last_modified ) {
250 - wfDebugLog( 'RSS', 'Used last modified: '.$this->last_modified );
 250+ wfDebugLog( 'RSS', 'Used last modified: ' . $this->last_modified );
251251 $headers['If-Last-Modified'] = $this->last_modified;
252252 }
253253
——@@ -266,11 +266,11 @@
267267 $this->client = $client;
268268
269269 if ( !$fetch->isGood() ) {
270 - wfDebug( 'RSS', 'Request Failed: '.$fetch->getWikiText() );
 270+ wfDebug( 'RSS', 'Request Failed: ' . $fetch->getWikiText() );
271271 return $fetch;
272272 }
273273
274 - $ret = $this->responseToXML($key);
 274+ $ret = $this->responseToXML( $key );
275275 return $ret;
276276 }
277277
——@@ -278,7 +278,7 @@
279279 $output = "";
280280 if ( $this->itemTemplate ) {
281281 $headcnt = 0;
282 - if ($this->reversed) {
 282+ if ( $this->reversed ) {
283283 $this->rss->items = array_reverse( $this->rss->items );
284284 }
285285
——@@ -300,9 +300,9 @@
301301 $parts = explode( '|', $this->itemTemplate );
302302
303303 $output = "";
304 - if( count( $parts ) > 1 && isset( $parser ) && isset( $frame ) ) {
 304+ if ( count( $parts ) > 1 && isset( $parser ) && isset( $frame ) ) {
305305 $rendered = array();
306 - foreach( $parts as $part ) {
 306+ foreach ( $parts as $part ) {
307307 $bits = explode( '=', $part );
308308 $left = null;
309309
——@@ -311,13 +311,13 @@
312312 }
313313
314314 if ( isset( $item[$left] ) ) {
315 - $leftValue = preg_replace( '#{{{'.$left.'}}}#', $item[$left], $bits[1] );
 315+ $leftValue = preg_replace( '#{{{' . $left . '}}}#', $item[$left], $bits[1] );
316316 $rendered[] = implode( '=', array( $left, $leftValue ) );
317317 } else {
318318 $rendered[] = $part;
319319 }
320320 }
321 - $rssTemp = implode(" | ", $rendered);
 321+ $rssTemp = implode( " | ", $rendered );
322322 $output .= $parser->recursiveTagParse( $rssTemp, $frame );
323323 }
324324 return $output;
——@@ -335,9 +335,9 @@
336336
337337 // if RSS parsed successfully
338338 if ( $this->rss && !$this->rss->ERROR ) {
339 - $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).')!' );
 339+ $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 ) . ')!' );
342342 $this->storeInCache( $key );
343343
344344 return Status::newGood();
——@@ -347,15 +347,14 @@
348348 }
349349
350350 function canDisplay( $item ) {
351 - if($this->filter($item['description'], 'filterOut')) {
352 - error_log($item['description']);
 351+ if ( $this->filter( $item['description'], 'filterOut' ) ) {
353352 return true;
354353 }
355354 return false;
356355 }
357356
358357 function filter( $text, $filterType ) {
359 - if($filterType === 'filterOut') {
 358+ if ( $filterType === 'filterOut' ) {
360359 $keep = false;
361360 $filter = $this->filterOut;
362361 } else {
——@@ -363,9 +362,9 @@
364363 $filter = $this->filter;
365364 }
366365
367 - if( count($filter) == 0 ) return !$keep;
 366+ if ( count( $filter ) == 0 ) return !$keep;
368367
369 - foreach( $filter as $term ) {
 368+ foreach ( $filter as $term ) {
370369 if ( $term ) {
371370 $match = preg_match( "|$term|i", $text );
372371 if ( $match ) {

Status & tagging log