Index: branches/wmf/1.16wmf4/extensions/RSS/RSSHooks.php |
— | — | @@ -19,18 +19,11 @@ |
20 | 20 | * @param $frame Frame parser context |
21 | 21 | */ |
22 | 22 | static function renderRss( $input, $args, $parser, $frame ) { |
23 | | - global $wgRSSCacheAge, $wgRSSCacheCompare; |
24 | | - |
25 | 23 | if ( !Http::isValidURI( $input ) ) { |
26 | 24 | return wfMsg( 'rss-invalid-url', htmlspecialchars( $input ) ); |
27 | 25 | } |
28 | | - if ( $wgRSSCacheCompare ) { |
29 | | - $timeout = $wgRSSCacheCompare; |
30 | | - } else { |
31 | | - $timeout = $wgRSSCacheAge; |
32 | | - } |
33 | 26 | |
34 | | - $parser->getOutput()->updateCacheExpiry( $timeout ); |
| 27 | + $parser->getOutput()->setContainsOldMagic( true );; |
35 | 28 | |
36 | 29 | $rss = new RSSParser( $input, $args ); |
37 | 30 | |
Index: branches/wmf/1.16wmf4/extensions/RSS/RSSParser.php |
— | — | @@ -192,12 +192,23 @@ |
193 | 193 | $fetch = $client->execute(); |
194 | 194 | $this->client = $client; |
195 | 195 | |
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 | + } |
199 | 210 | } |
200 | 211 | |
201 | | - $ret = $this->responseToXML( $key ); |
| 212 | + $ret = $this->responseToXML( $key, $status ); |
202 | 213 | return $ret; |
203 | 214 | } |
204 | 215 | |
— | — | @@ -309,9 +320,9 @@ |
310 | 321 | * @param $key String: the key to use to store the parsed response in the cache |
311 | 322 | * @return parsed RSS object (see RSSParse) or false |
312 | 323 | */ |
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' ) { |
316 | 327 | # Not modified, update cache |
317 | 328 | wfDebugLog( 'RSS', "Got 304, updating cache for $key" ); |
318 | 329 | $this->storeInCache( $key ); |