Index: trunk/phase3/includes/Parser.php |
— | — | @@ -3057,7 +3057,7 @@ |
3058 | 3058 | */ |
3059 | 3059 | function fetchTemplateAndTitle( $title ) { |
3060 | 3060 | $templateCb = $this->mOptions->getTemplateCallback(); |
3061 | | - $stuff = call_user_func( $templateCb, $title ); |
| 3061 | + $stuff = call_user_func( $templateCb, $title, $this ); |
3062 | 3062 | $text = $stuff['text']; |
3063 | 3063 | $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title; |
3064 | 3064 | if ( isset( $stuff['deps'] ) ) { |
— | — | @@ -3077,7 +3077,7 @@ |
3078 | 3078 | * Static function to get a template |
3079 | 3079 | * Can be overridden via ParserOptions::setTemplateCallback(). |
3080 | 3080 | */ |
3081 | | - static function statelessFetchTemplate( $title ) { |
| 3081 | + static function statelessFetchTemplate( $title, $parser=false ) { |
3082 | 3082 | $text = $skip = false; |
3083 | 3083 | $finalTitle = $title; |
3084 | 3084 | $deps = array(); |
— | — | @@ -3086,7 +3086,7 @@ |
3087 | 3087 | for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) { |
3088 | 3088 | # Give extensions a chance to select the revision instead |
3089 | 3089 | $id = false; // Assume current |
3090 | | - wfRunHooks( 'BeforeParserFetchTemplateAndtitle', array( false, &$title, &$skip, &$id ) ); |
| 3090 | + wfRunHooks( 'BeforeParserFetchTemplateAndtitle', array( $parser, &$title, &$skip, &$id ) ); |
3091 | 3091 | |
3092 | 3092 | if( $skip ) { |
3093 | 3093 | $text = false; |
Index: trunk/phase3/includes/Parser_OldPP.php |
— | — | @@ -410,6 +410,7 @@ |
411 | 411 | |
412 | 412 | function &getTitle() { return $this->mTitle; } |
413 | 413 | function getOptions() { return $this->mOptions; } |
| 414 | + function getRevisionId() { return $this->mRevisionId; } |
414 | 415 | |
415 | 416 | function getFunctionLang() { |
416 | 417 | global $wgLang, $wgContLang; |
— | — | @@ -3261,7 +3262,7 @@ |
3262 | 3263 | */ |
3263 | 3264 | function fetchTemplateAndTitle( $title ) { |
3264 | 3265 | $templateCb = $this->mOptions->getTemplateCallback(); |
3265 | | - $stuff = call_user_func( $templateCb, $title ); |
| 3266 | + $stuff = call_user_func( $templateCb, $title, $this ); |
3266 | 3267 | $text = $stuff['text']; |
3267 | 3268 | $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title; |
3268 | 3269 | if ( isset( $stuff['deps'] ) ) { |
— | — | @@ -3289,7 +3290,7 @@ |
3290 | 3291 | * page_id: The page_id of the title |
3291 | 3292 | * rev_id: The revision ID loaded |
3292 | 3293 | */ |
3293 | | - static function statelessFetchTemplate( $title ) { |
| 3294 | + static function statelessFetchTemplate( $title, $parser=false ) { |
3294 | 3295 | $text = $skip = false; |
3295 | 3296 | $finalTitle = $title; |
3296 | 3297 | $deps = array(); |
— | — | @@ -3298,7 +3299,7 @@ |
3299 | 3300 | for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) { |
3300 | 3301 | # Give extensions a chance to select the revision instead |
3301 | 3302 | $id = false; // Assume current |
3302 | | - wfRunHooks( 'BeforeParserFetchTemplateAndtitle', array( false, &$title, &$skip, &$id ) ); |
| 3303 | + wfRunHooks( 'BeforeParserFetchTemplateAndtitle', array( $parser, &$title, &$skip, &$id ) ); |
3303 | 3304 | |
3304 | 3305 | if( $skip ) { |
3305 | 3306 | $text = false; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -513,16 +513,17 @@ |
514 | 514 | * Updates the fp_stable and fp_reviewed fields |
515 | 515 | */ |
516 | 516 | public static function updateArticleOn( $article, $revId, $latest=NULL ) { |
517 | | - global $wgMemc; |
518 | | - wfProfileIn( __METHOD__ ); |
| 517 | + if( !$article->getId() ) |
| 518 | + return true; // no bogus entries |
519 | 519 | |
| 520 | + wfProfileIn( __METHOD__ ); |
520 | 521 | $lastID = $latest ? $latest : $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
521 | 522 | |
522 | 523 | $dbw = wfGetDB( DB_MASTER ); |
523 | 524 | # Get the highest quality revision (not necessarily this one). |
524 | 525 | $maxQuality = $dbw->selectField( array('flaggedrevs','revision'), |
525 | 526 | 'fr_quality', |
526 | | - array( 'fr_page_id' => $article->getTitle()->getArticleID(), |
| 527 | + array( 'fr_page_id' => $article->getId(), |
527 | 528 | 'rev_id = fr_rev_id', |
528 | 529 | 'rev_page = fr_page_id', |
529 | 530 | 'rev_deleted & '.Revision::DELETED_TEXT => 0 ), |
— | — | @@ -1250,11 +1251,9 @@ |
1251 | 1252 | * Select the desired templates based on the selected stable revision IDs |
1252 | 1253 | * NOTE: $p comes in false from this hook ... weird |
1253 | 1254 | */ |
1254 | | - public static function parserFetchStableTemplate( $p=false, $title, &$skip, &$id ) { |
1255 | | - global $wgParser; |
| 1255 | + public static function parserFetchStableTemplate( $parser, $title, &$skip, &$id ) { |
1256 | 1256 | # Trigger for stable version parsing only |
1257 | | - $parser =& $wgParser; |
1258 | | - if( !isset($parser->fr_isStable) || !$parser->fr_isStable ) |
| 1257 | + if( !$parser || !isset($parser->fr_isStable) || !$parser->fr_isStable ) |
1259 | 1258 | return true; |
1260 | 1259 | # Special namespace ... ? |
1261 | 1260 | if( $title->getNamespace() < 0 ) { |
— | — | @@ -1265,21 +1264,21 @@ |
1266 | 1265 | # Should be in reviewable namespace, this saves unneeded DB checks as |
1267 | 1266 | # well as enforce site settings if they are later changed. |
1268 | 1267 | global $wgUseStableTemplates; |
1269 | | - if( $wgUseStableTemplates && self::isPageReviewable( $title ) ) { |
| 1268 | + if( $wgUseStableTemplates && self::isPageReviewable($title) && $title->getArticleId() ) { |
1270 | 1269 | $id = $dbr->selectField( 'flaggedpages', 'fp_stable', |
1271 | 1270 | array( 'fp_page_id' => $title->getArticleId() ), |
1272 | 1271 | __METHOD__ ); |
1273 | 1272 | } |
1274 | 1273 | # Check cache before doing another DB hit... |
1275 | 1274 | if( !$id ) { |
1276 | | - $id = self::getTemplateIdFromCache( $parser->mRevisionId, $title->getNamespace(), $title->getDBKey() ); |
| 1275 | + $id = self::getTemplateIdFromCache( $parser->getRevisionId(), $title->getNamespace(), $title->getDBKey() ); |
1277 | 1276 | $id = is_null($id) ? false : $id; |
1278 | 1277 | } |
1279 | 1278 | # If there is no stable version (or that feature is not enabled), use |
1280 | 1279 | # the template revision during review time. |
1281 | 1280 | if( $id === false ) { |
1282 | 1281 | $id = $dbr->selectField( 'flaggedtemplates', 'ft_tmp_rev_id', |
1283 | | - array( 'ft_rev_id' => $parser->mRevisionId, |
| 1282 | + array( 'ft_rev_id' => $parser->getRevisionId(), |
1284 | 1283 | 'ft_namespace' => $title->getNamespace(), |
1285 | 1284 | 'ft_title' => $title->getDBkey() ), |
1286 | 1285 | __METHOD__ ); |
— | — | @@ -1288,7 +1287,7 @@ |
1289 | 1288 | if( !$id ) { |
1290 | 1289 | global $wgUseCurrentTemplates; |
1291 | 1290 | if( $id === false ) { |
1292 | | - $parser->fr_includeErrors[] = $title->getDBKey(); // May want to give an error |
| 1291 | + $parser->fr_includeErrors[] = $title->getPrefixedDBKey(); // May want to give an error |
1293 | 1292 | if( !$wgUseCurrentTemplates ) { |
1294 | 1293 | $skip = true; |
1295 | 1294 | } |
— | — | @@ -1335,7 +1334,7 @@ |
1336 | 1335 | } |
1337 | 1336 | # Check cache before doing another DB hit... |
1338 | 1337 | if( !$time ) { |
1339 | | - $params = self::getFileVersionFromCache( $parser->mRevisionId, $nt->getDBKey() ); |
| 1338 | + $params = self::getFileVersionFromCache( $parser->getRevisionId(), $nt->getDBKey() ); |
1340 | 1339 | if( is_array($params) ) { |
1341 | 1340 | list($time,$sha1) = $params; |
1342 | 1341 | } |
— | — | @@ -1345,7 +1344,7 @@ |
1346 | 1345 | if( $time === false ) { |
1347 | 1346 | $row = $dbr->selectRow( 'flaggedimages', |
1348 | 1347 | array( 'fi_img_timestamp', 'fi_img_sha1' ), |
1349 | | - array( 'fi_rev_id' => $parser->mRevisionId, |
| 1348 | + array( 'fi_rev_id' => $parser->getRevisionId(), |
1350 | 1349 | 'fi_name' => $nt->getDBkey() ), |
1351 | 1350 | __METHOD__ ); |
1352 | 1351 | $time = $row ? $row->fi_img_timestamp : $time; |