Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -434,7 +434,6 @@ |
435 | 435 | |
436 | 436 | # ######## Parser ######### |
437 | 437 | # Parser hooks, selects the desired images/templates |
438 | | -$wgHooks['ParserClearState'][] = 'FlaggedRevsHooks::parserAddFields'; |
439 | 438 | $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate'; |
440 | 439 | $wgHooks['BeforeParserFetchFileAndTitle'][] = 'FlaggedRevsHooks::parserFetchStableFile'; |
441 | 440 | # ######## |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -476,11 +476,11 @@ |
477 | 477 | # ################ Parsing functions ################# |
478 | 478 | |
479 | 479 | /** |
480 | | - * All included pages/arguments are expanded out |
| 480 | + * All templates and arguments in $text are expanded out |
481 | 481 | * @param Title $title |
482 | | - * @param string $text |
| 482 | + * @param string $text wikitext |
483 | 483 | * @param int $id Source revision Id |
484 | | - * @return array( string, array, array ) |
| 484 | + * @return array( string wikitext, array of template versions ) |
485 | 485 | */ |
486 | 486 | public static function expandText( Title $title, $text, $id ) { |
487 | 487 | global $wgParser; |
— | — | @@ -500,13 +500,13 @@ |
501 | 501 | } |
502 | 502 | $options = self::makeParserOptions(); // default options |
503 | 503 | $outputText = $wgParser->preprocess( $text, $title, $options, $id ); |
504 | | - $out = $wgParser->mOutput; |
| 504 | + $pOutput = $wgParser->getOutput(); |
505 | 505 | # Stable parse done! |
506 | 506 | if ( $resetManager ) { |
507 | 507 | $incManager->clear(); // reset the FRInclusionManager as needed |
508 | 508 | } |
509 | 509 | # Return data array |
510 | | - return array( $outputText, $out->mTemplateIds, $out->fr_includeErrors ); |
| 510 | + return array( $outputText, $pOutput->getTemplateIds() ); |
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -285,14 +285,6 @@ |
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | | - * Add special fields to parser. |
290 | | - */ |
291 | | - public static function parserAddFields( Parser $parser ) { |
292 | | - $parser->getOutput()->fr_includeErrors = array(); |
293 | | - return true; |
294 | | - } |
295 | | - |
296 | | - /** |
297 | 289 | * Select the desired templates based on the selected stable revision IDs |
298 | 290 | * Note: $parser can be false |
299 | 291 | */ |
— | — | @@ -305,12 +297,12 @@ |
306 | 298 | return true; // trigger for stable version parsing only |
307 | 299 | } |
308 | 300 | $id = false; // current |
309 | | - # Check for the version of this template used when reviewed. |
| 301 | + # Check for the version of this template used when reviewed... |
310 | 302 | $maybeId = $incManager->getReviewedTemplateVersion( $title ); |
311 | 303 | if ( $maybeId !== null ) { |
312 | 304 | $id = (int)$maybeId; // use if specified (even 0) |
313 | 305 | } |
314 | | - # Check for stable version of template if this feature is enabled. |
| 306 | + # Check for stable version of template if this feature is enabled... |
315 | 307 | if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) { |
316 | 308 | $maybeId = $incManager->getStableTemplateVersion( $title ); |
317 | 309 | # Take the newest of these two... |
— | — | @@ -318,11 +310,8 @@ |
319 | 311 | $id = (int)$maybeId; |
320 | 312 | } |
321 | 313 | } |
322 | | - # If $id not specified, see if we are allowed to use the current revision |
323 | | - if ( $id === false ) { |
324 | | - $parser->getOutput()->fr_includeErrors[] = $title->getPrefixedDBKey(); // unspecified |
325 | | - # If $id is zero, don't bother loading it |
326 | | - } elseif ( !$id ) { |
| 314 | + # If $id is zero, don't bother loading it (use blue/red link) |
| 315 | + if ( $id === 0 ) { |
327 | 316 | $skip = true; |
328 | 317 | } |
329 | 318 | return true; |
— | — | @@ -335,7 +324,8 @@ |
336 | 325 | if ( !( $parser instanceof Parser ) ) { |
337 | 326 | return true; // nothing to do |
338 | 327 | } |
339 | | - if ( !FRInclusionManager::singleton()->parserOutputIsStabilized() ) { |
| 328 | + $incManager = FRInclusionManager::singleton(); |
| 329 | + if ( !$incManager->parserOutputIsStabilized() ) { |
340 | 330 | return true; // trigger for stable version parsing only |
341 | 331 | } |
342 | 332 | # Normalize NS_MEDIA to NS_FILE |
— | — | @@ -345,30 +335,15 @@ |
346 | 336 | } else { |
347 | 337 | $title =& $nt; |
348 | 338 | } |
349 | | - # Get version, update mImageTimeKeys... |
350 | | - list( $time, $sha1 ) = self::parserFindStableFile( $parser, $title ); |
351 | | - # Stabilize the file link |
352 | | - if ( $time ) { |
353 | | - if ( $query != '' ) $query .= '&'; |
354 | | - $query = "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) ); |
355 | | - } |
356 | | - return true; |
357 | | - } |
358 | | - |
359 | | - /** |
360 | | - * Select the desired images based on the selected stable version time/SHA-1 |
361 | | - */ |
362 | | - protected static function parserFindStableFile( Parser $parser, Title $title ) { |
363 | 339 | $time = false; // current version |
364 | 340 | $sha1 = false; // corresponds to $time |
365 | | - # Check for the version of this file used when reviewed. |
366 | | - $incManager = FRInclusionManager::singleton(); |
| 341 | + # Check for the version of this file used when reviewed... |
367 | 342 | list( $maybeTS, $maybeSha1 ) = $incManager->getReviewedFileVersion( $title ); |
368 | 343 | if ( $maybeTS !== null ) { |
369 | 344 | $time = $maybeTS; // use if specified (even "0") |
370 | 345 | $sha1 = $maybeSha1; |
371 | 346 | } |
372 | | - # Check for stable version of file if this feature is enabled. |
| 347 | + # Check for stable version of file if this feature is enabled... |
373 | 348 | if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE ) { |
374 | 349 | list( $maybeTS, $maybeSha1 ) = $incManager->getStableFileVersion( $title ); |
375 | 350 | # Take the newest of these two... |
— | — | @@ -377,14 +352,12 @@ |
378 | 353 | $sha1 = $maybeSha1; |
379 | 354 | } |
380 | 355 | } |
381 | | - # If $time not specified, see if we are allowed to use the current revision |
382 | | - if ( $time === false ) { |
383 | | - # May want to give an error, so track these... |
384 | | - $parser->getOutput()->fr_includeErrors[] = $title->getPrefixedDBKey(); |
385 | | - } elseif ( !$time ) { |
386 | | - $time = "0"; // make sure this the string '0' |
| 356 | + # Stabilize the file link |
| 357 | + if ( $time ) { |
| 358 | + if ( $query != '' ) $query .= '&'; |
| 359 | + $query = "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) ); |
387 | 360 | } |
388 | | - return array( $time, $sha1 ); |
| 361 | + return true; |
389 | 362 | } |
390 | 363 | |
391 | 364 | public static function onParserFirstCallInit( &$parser ) { |