http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98030

Revision: 98030
Author:   aaron
Date:     2011-09-24 21:12:26 +0000 (Sat, 24 Sep 2011)
Log Message:
-----------
Article refactoring and changes for bug 31144. Dependency inject ParserOutput 
objects in some places and let hooks set $outputDone as the parser output used.

Modified Paths:
--------------
    trunk/phase3/docs/hooks.txt
    trunk/phase3/includes/Article.php

Modified: trunk/phase3/docs/hooks.txt
===================================================================
--- trunk/phase3/docs/hooks.txt 2011-09-24 21:11:41 UTC (rev 98029)
+++ trunk/phase3/docs/hooks.txt 2011-09-24 21:12:26 UTC (rev 98030)
@@ -540,7 +540,8 @@
 viewing.
 &$article: the article
 &$pcache: whether to try the parser cache or not
-&$outputDone: whether the output for this page finished or not
+&$outputDone: whether the output for this page finished or not. Set to a 
ParserOutput
+object to both indicate that the output is done and what parser output was 
used.
 
 'ArticleViewRedirect': before setting "Redirected from ..." subtitle when
 follwed an redirect

Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php   2011-09-24 21:11:41 UTC (rev 98029)
+++ trunk/phase3/includes/Article.php   2011-09-24 21:12:26 UTC (rev 98030)
@@ -548,13 +548,15 @@
                        }
                }
 
-               # Adjust the title if it was set by displaytitle, -{T|}- or 
language conversion
-               if ( $this->mParserOutput ) {
-                       $titleText = $this->mParserOutput->getTitleText();
+               # Get the ParserOutput actually *displayed* here.
+               # Note that $this->mParserOutput is the *current* version 
output.
+               $pOutput = ( $outputDone instanceof ParserOutput )
+                       ? $outputDone // object fetched by hook
+                       : $this->mParserOutput;
 
-                       if ( strval( $titleText ) !== '' ) {
-                               $wgOut->setPageTitle( $titleText );
-                       }
+               # Adjust title for main page & pages with displaytitle
+               if ( $pOutput ) {
+                       $this->adjustDisplayTitle( $pOutput );
                }
 
                # For the main page, overwrite the <title> element with the con-
@@ -568,17 +570,30 @@
                        }
                }
 
-               # Now that we've filled $this->mParserOutput, we know whether
-               # there are any __NOINDEX__ tags on the page
-               $policy = $this->getRobotPolicy( 'view' );
+               # Check for any __NOINDEX__ tags on the page using $pOutput
+               $policy = $this->getRobotPolicy( 'view', $pOutput );
                $wgOut->setIndexPolicy( $policy['index'] );
                $wgOut->setFollowPolicy( $policy['follow'] );
 
                $this->showViewFooter();
                $this->mPage->viewUpdates();
+
                wfProfileOut( __METHOD__ );
        }
 
+       /*
+        * Adjust title for pages with displaytitle, -{T|}- or language 
conversion
+        * @param $pOutput ParserOutput
+        */
+       public function adjustDisplayTitle( ParserOutput $pOutput ) {
+               global $wgOut;
+               # Adjust the title if it was set by displaytitle, -{T|}- or 
language conversion
+               $titleText = $pOutput->getTitleText();
+               if ( strval( $titleText ) !== '' ) {
+                       $wgOut->setPageTitle( $titleText );
+               }
+       }
+
        /**
         * Show a diff page according to current request variables. For use 
within
         * Article::view() only, other callers should use the DifferenceEngine 
class.
@@ -634,10 +649,11 @@
        /**
         * Get the robot policy to be used for the current view
         * @param $action String the action= GET parameter
+        * @param $pOutput ParserOutput
         * @return Array the policy that should be set
         * TODO: actions other than 'view'
         */
-       public function getRobotPolicy( $action ) {
+       public function getRobotPolicy( $action, $pOutput ) {
                global $wgOut, $wgArticleRobotPolicies, 
$wgNamespaceRobotPolicies;
                global $wgDefaultRobotPolicy, $wgRequest;
 
@@ -685,12 +701,12 @@
                                self::formatRobotPolicy( 
$wgNamespaceRobotPolicies[$ns] )
                        );
                }
-               if ( $this->getTitle()->canUseNoindex() && is_object( 
$this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ) {
+               if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput 
) && $pOutput->getIndexPolicy() ) {
                        # __INDEX__ and __NOINDEX__ magic words, if allowed. 
Incorporates
                        # a final sanity check that we have really got the 
parser output.
                        $policy = array_merge(
                                $policy,
-                               array( 'index' => 
$this->mParserOutput->getIndexPolicy() )
+                               array( 'index' => $pOutput->getIndexPolicy() )
                        );
                }
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to