testPngNativetZtxt requires zlib extension
[lhc/web/wiklou.git] / includes / Article.php
index 8403bc6..10cbac7 100644 (file)
@@ -280,15 +280,13 @@ class Article extends Page {
                                $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
                                $content = new MessageContent( $message, null, 'parsemag' );
                        }
-                       wfProfileOut( __METHOD__ );
-
-                       return $content;
                } else {
                        $this->fetchContentObject();
-                       wfProfileOut( __METHOD__ );
-
-                       return $this->mContentObject;
+                       $content = $this->mContentObject;
                }
+
+               wfProfileOut( __METHOD__ );
+               return $content;
        }
 
        /**
@@ -403,7 +401,7 @@ class Article extends Page {
         *
         * @note code that wants to retrieve page content from the database should use WikiPage::getContent().
         *
-        * @return Content|null
+        * @return Content|null|boolean false
         *
         * @since 1.21
         */
@@ -515,7 +513,7 @@ class Article extends Page {
         * page of the given title.
         */
        public function view() {
-               global $wgParser, $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
+               global $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
 
                wfProfileIn( __METHOD__ );
 
@@ -704,9 +702,8 @@ class Article extends Page {
                                        # Run the parse, protected by a pool counter
                                        wfDebug( __METHOD__ . ": doing uncached parse\n" );
 
-                                       // @todo: shouldn't we be passing $this->getPage() to PoolWorkArticleView instead of plain $this?
-                                       $poolArticleView = new PoolWorkArticleView( $this, $parserOptions,
-                                               $this->getRevIdFetched(), $useParserCache, $this->getContentObject(), $this->getContext() );
+                                       $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
+                                               $this->getRevIdFetched(), $useParserCache, $this->getContentObject() );
 
                                        if ( !$poolArticleView->execute() ) {
                                                $error = $poolArticleView->getError();
@@ -865,15 +862,21 @@ class Article extends Page {
 
                $ns = $this->getTitle()->getNamespace();
 
-               if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
-                       # Don't index user and user talk pages for blocked users (bug 11443)
-                       if ( !$this->getTitle()->isSubpage() ) {
-                               if ( Block::newFromTarget( null, $this->getTitle()->getText() ) instanceof Block ) {
-                                       return array(
-                                               'index'  => 'noindex',
-                                               'follow' => 'nofollow'
-                                       );
-                               }
+               # Don't index user and user talk pages for blocked users (bug 11443)
+               if ( ( $ns == NS_USER || $ns == NS_USER_TALK ) && !$this->getTitle()->isSubpage() ) {
+                       $specificTarget = null;
+                       $vagueTarget = null;
+                       $titleText = $this->getTitle()->getText();
+                       if ( IP::isValid( $titleText ) ) {
+                               $vagueTarget = $titleText;
+                       } else {
+                               $specificTarget = $titleText;
+                       }
+                       if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
+                               return array(
+                                       'index'  => 'noindex',
+                                       'follow' => 'nofollow'
+                               );
                        }
                }
 
@@ -989,9 +992,7 @@ class Article extends Page {
                                }
 
                                // Add a <link rel="canonical"> tag
-                               $outputPage->addLink( array( 'rel' => 'canonical',
-                                       'href' => $this->getTitle()->getLocalURL() )
-                               );
+                               $outputPage->setCanonicalUrl( $this->getTitle()->getLocalURL() );
 
                                // Tell the output object that the user arrived at this article through a redirect
                                $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
@@ -1045,6 +1046,8 @@ class Article extends Page {
         * If patrol is possible, output a patrol UI box. This is called from the
         * footer section of ordinary page views. If patrol is not possible or not
         * desired, does nothing.
+        * Side effect: When the patrol link is build, this method will call
+        * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
         */
        public function showPatrolFooter() {
                $request = $this->getContext()->getRequest();
@@ -1057,7 +1060,9 @@ class Article extends Page {
                }
 
                $token = $user->getEditToken( $rcid );
+
                $outputPage->preventClickjacking();
+               $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
 
                $link = Linker::linkKnown(
                        $this->getTitle(),