r77278 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77277‎ | r77278 | r77279 >
Date:12:16, 25 November 2010
Author:tstarling
Status:ok
Tags:
Comment:
* Replaced call to ParserOutput::updateCacheExpiry() with ParserOutput::setContainsOldMagic(), since the former does not exist in 1.16.
* Replaced call to HttpRequest::getStatus() with processing of the Status object, since it does not exist in 1.16. Tested with and without $wgRSSCacheCompare.
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/RSS/RSSHooks.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/RSS/RSSParser.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/RSS/RSSHooks.php
@@ -19,18 +19,11 @@
2020 * @param $frame Frame parser context
2121 */
2222 static function renderRss( $input, $args, $parser, $frame ) {
23 - global $wgRSSCacheAge, $wgRSSCacheCompare;
24 -
2523 if ( !Http::isValidURI( $input ) ) {
2624 return wfMsg( 'rss-invalid-url', htmlspecialchars( $input ) );
2725 }
28 - if ( $wgRSSCacheCompare ) {
29 - $timeout = $wgRSSCacheCompare;
30 - } else {
31 - $timeout = $wgRSSCacheAge;
32 - }
3326
34 - $parser->getOutput()->updateCacheExpiry( $timeout );
 27+ $parser->getOutput()->setContainsOldMagic( true );;
3528
3629 $rss = new RSSParser( $input, $args );
3730
Index: branches/wmf/1.16wmf4/extensions/RSS/RSSParser.php
@@ -192,12 +192,23 @@
193193 $fetch = $client->execute();
194194 $this->client = $client;
195195
196 - if ( !$fetch->isGood() ) {
197 - wfDebug( 'RSS', 'Request Failed: ' . $fetch->getWikiText() );
198 - return $fetch;
 196+ if ( $fetch->isGood() ) {
 197+ $status = 200;
 198+ } else {
 199+ $status = 0;
 200+ foreach ( $fetch->errors as $error ) {
 201+ if ( $error['message'] == 'http-bad-status' ) {
 202+ $status = $error['params'][0];
 203+ break;
 204+ }
 205+ }
 206+ if ( $status != '304' ) {
 207+ wfDebug( 'RSS', 'Request Failed: ' . $fetch->getWikiText() );
 208+ return $fetch;
 209+ }
199210 }
200211
201 - $ret = $this->responseToXML( $key );
 212+ $ret = $this->responseToXML( $key, $status );
202213 return $ret;
203214 }
204215
@@ -309,9 +320,9 @@
310321 * @param $key String: the key to use to store the parsed response in the cache
311322 * @return parsed RSS object (see RSSParse) or false
312323 */
313 - protected function responseToXML( $key ) {
314 - wfDebugLog( 'RSS', "Got '" . $this->client->getStatus() . "', updating cache for $key" );
315 - if ( $this->client->getStatus() === 304 ) {
 324+ protected function responseToXML( $key, $status ) {
 325+ wfDebugLog( 'RSS', "Got $status, updating cache for $key" );
 326+ if ( $status == '304' ) {
316327 # Not modified, update cache
317328 wfDebugLog( 'RSS', "Got 304, updating cache for $key" );
318329 $this->storeInCache( $key );

Status & tagging log