Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -325,11 +325,8 @@ |
326 | 326 | */ |
327 | 327 | public static function parserFetchStableTemplate( $parser, $title, &$skip, &$id ) { |
328 | 328 | # Trigger for stable version parsing only |
329 | | - if( !$parser || empty($parser->fr_isStable) ) |
| 329 | + if( !$parser || empty($parser->fr_isStable) || $title->getNamespace() < 0 ) { |
330 | 330 | return true; |
331 | | - # Special namespace ... ? |
332 | | - if( $title->getNamespace() < 0 ) { |
333 | | - return true; |
334 | 331 | } |
335 | 332 | $dbr = wfGetDB( DB_SLAVE ); |
336 | 333 | # Check for stable version of template if this feature is enabled. |
— | — | @@ -347,7 +344,7 @@ |
348 | 345 | } |
349 | 346 | # If there is no stable version (or that feature is not enabled), use |
350 | 347 | # the template revision during review time. If both, use the newest one. |
351 | | - if( !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) { |
| 348 | + if( $parser->getRevisionId() && !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) { |
352 | 349 | $idP = $dbr->selectField( 'flaggedtemplates', |
353 | 350 | 'ft_tmp_rev_id', |
354 | 351 | array( 'ft_rev_id' => $parser->getRevisionId(), |
— | — | @@ -355,6 +352,7 @@ |
356 | 353 | 'ft_title' => $title->getDBkey() ), |
357 | 354 | __METHOD__ |
358 | 355 | ); |
| 356 | + # Take the newest (or only available) of the two |
359 | 357 | $id = ($id === false || $idP > $id) ? $idP : $id; |
360 | 358 | } |
361 | 359 | # If none specified, see if we are allowed to use the current revision |
— | — | @@ -380,7 +378,7 @@ |
381 | 379 | */ |
382 | 380 | public static function parserMakeStableImageLink( $parser, $nt, &$skip, &$time, &$query=false ) { |
383 | 381 | # Trigger for stable version parsing only |
384 | | - if( empty($parser->fr_isStable) ) { |
| 382 | + if( empty($parser->fr_isStable) || $nt->getNamespace() < 0 ) { |
385 | 383 | return true; |
386 | 384 | } |
387 | 385 | $file = null; |
— | — | @@ -389,6 +387,7 @@ |
390 | 388 | # Normalize NS_MEDIA to NS_FILE |
391 | 389 | if( $nt->getNamespace() == NS_MEDIA ) { |
392 | 390 | $title = Title::makeTitle( NS_FILE, $nt->getDBKey() ); |
| 391 | + $title->resetArticleId( $nt->getArticleId() ); // avoid extra queries |
393 | 392 | } else { |
394 | 393 | $title =& $nt; |
395 | 394 | } |
— | — | @@ -417,7 +416,7 @@ |
418 | 417 | } |
419 | 418 | # If there is no stable version (or that feature is not enabled), use |
420 | 419 | # the image revision during review time. If both, use the newest one. |
421 | | - if( !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) { |
| 420 | + if( $parser->getRevisionId() && !FlaggedRevs::useProcessCache( $parser->getRevisionId() ) ) { |
422 | 421 | $row = $dbr->selectRow( 'flaggedimages', |
423 | 422 | array( 'fi_img_timestamp', 'fi_img_sha1' ), |
424 | 423 | array( 'fi_rev_id' => $parser->getRevisionId(), 'fi_name' => $title->getDBkey() ), |
— | — | @@ -501,7 +500,7 @@ |
502 | 501 | } |
503 | 502 | # If there is no stable version (or that feature is not enabled), use |
504 | 503 | # the image revision during review time. If both, use the newest one. |
505 | | - if( !FlaggedRevs::useProcessCache( $ig->mRevisionId ) ) { |
| 504 | + if( $ig->mRevisionId && !FlaggedRevs::useProcessCache( $ig->mRevisionId ) ) { |
506 | 505 | $row = $dbr->selectRow( 'flaggedimages', |
507 | 506 | array( 'fi_img_timestamp', 'fi_img_sha1' ), |
508 | 507 | array('fi_rev_id' => $ig->mRevisionId, 'fi_name' => $nt->getDBkey() ), |