testPngNativetZtxt requires zlib extension
[lhc/web/wiklou.git] / includes / Article.php
index 5a887b6..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
         */
@@ -864,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'
+                               );
                        }
                }
 
@@ -988,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 );