Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -540,7 +540,8 @@ |
541 | 541 | viewing. |
542 | 542 | &$article: the article |
543 | 543 | &$pcache: whether to try the parser cache or not |
544 | | -&$outputDone: whether the output for this page finished or not |
| 544 | +&$outputDone: whether the output for this page finished or not. Set to a ParserOutput |
| 545 | +object to both indicate that the output is done and what parser output was used. |
545 | 546 | |
546 | 547 | 'ArticleViewRedirect': before setting "Redirected from ..." subtitle when |
547 | 548 | follwed an redirect |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -548,13 +548,15 @@ |
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | | - # Adjust the title if it was set by displaytitle, -{T|}- or language conversion |
553 | | - if ( $this->mParserOutput ) { |
554 | | - $titleText = $this->mParserOutput->getTitleText(); |
| 552 | + # Get the ParserOutput actually *displayed* here. |
| 553 | + # Note that $this->mParserOutput is the *current* version output. |
| 554 | + $pOutput = ( $outputDone instanceof ParserOutput ) |
| 555 | + ? $outputDone // object fetched by hook |
| 556 | + : $this->mParserOutput; |
555 | 557 | |
556 | | - if ( strval( $titleText ) !== '' ) { |
557 | | - $wgOut->setPageTitle( $titleText ); |
558 | | - } |
| 558 | + # Adjust title for main page & pages with displaytitle |
| 559 | + if ( $pOutput ) { |
| 560 | + $this->adjustDisplayTitle( $pOutput ); |
559 | 561 | } |
560 | 562 | |
561 | 563 | # For the main page, overwrite the <title> element with the con- |
— | — | @@ -568,17 +570,30 @@ |
569 | 571 | } |
570 | 572 | } |
571 | 573 | |
572 | | - # Now that we've filled $this->mParserOutput, we know whether |
573 | | - # there are any __NOINDEX__ tags on the page |
574 | | - $policy = $this->getRobotPolicy( 'view' ); |
| 574 | + # Check for any __NOINDEX__ tags on the page using $pOutput |
| 575 | + $policy = $this->getRobotPolicy( 'view', $pOutput ); |
575 | 576 | $wgOut->setIndexPolicy( $policy['index'] ); |
576 | 577 | $wgOut->setFollowPolicy( $policy['follow'] ); |
577 | 578 | |
578 | 579 | $this->showViewFooter(); |
579 | 580 | $this->mPage->viewUpdates(); |
| 581 | + |
580 | 582 | wfProfileOut( __METHOD__ ); |
581 | 583 | } |
582 | 584 | |
| 585 | + /* |
| 586 | + * Adjust title for pages with displaytitle, -{T|}- or language conversion |
| 587 | + * @param $pOutput ParserOutput |
| 588 | + */ |
| 589 | + public function adjustDisplayTitle( ParserOutput $pOutput ) { |
| 590 | + global $wgOut; |
| 591 | + # Adjust the title if it was set by displaytitle, -{T|}- or language conversion |
| 592 | + $titleText = $pOutput->getTitleText(); |
| 593 | + if ( strval( $titleText ) !== '' ) { |
| 594 | + $wgOut->setPageTitle( $titleText ); |
| 595 | + } |
| 596 | + } |
| 597 | + |
583 | 598 | /** |
584 | 599 | * Show a diff page according to current request variables. For use within |
585 | 600 | * Article::view() only, other callers should use the DifferenceEngine class. |
— | — | @@ -634,10 +649,11 @@ |
635 | 650 | /** |
636 | 651 | * Get the robot policy to be used for the current view |
637 | 652 | * @param $action String the action= GET parameter |
| 653 | + * @param $pOutput ParserOutput |
638 | 654 | * @return Array the policy that should be set |
639 | 655 | * TODO: actions other than 'view' |
640 | 656 | */ |
641 | | - public function getRobotPolicy( $action ) { |
| 657 | + public function getRobotPolicy( $action, $pOutput ) { |
642 | 658 | global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies; |
643 | 659 | global $wgDefaultRobotPolicy, $wgRequest; |
644 | 660 | |
— | — | @@ -685,12 +701,12 @@ |
686 | 702 | self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] ) |
687 | 703 | ); |
688 | 704 | } |
689 | | - if ( $this->getTitle()->canUseNoindex() && is_object( $this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ) { |
| 705 | + if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) { |
690 | 706 | # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates |
691 | 707 | # a final sanity check that we have really got the parser output. |
692 | 708 | $policy = array_merge( |
693 | 709 | $policy, |
694 | | - array( 'index' => $this->mParserOutput->getIndexPolicy() ) |
| 710 | + array( 'index' => $pOutput->getIndexPolicy() ) |
695 | 711 | ); |
696 | 712 | } |
697 | 713 | |