skin: Use Title::isKnown() / Title::exists() instead of Title::getArticleID()
authorKunal Mehta <legoktm@gmail.com>
Tue, 17 Feb 2015 22:04:36 +0000 (14:04 -0800)
committerKunal Mehta <legoktm@gmail.com>
Tue, 17 Feb 2015 22:24:10 +0000 (14:24 -0800)
Some of these calls pre-date the existence of isKnown() and exists(), which
should be used instead of calling getArticleID() directly. For places where
we're just trying to determine link color, I used isKnown(), and for other
places we're trying to figure out where an article exists, I used exists().

Bug: T85550
Change-Id: I47c8af8485857cc0f3190b4ada1578ab672580af

includes/skins/Skin.php
includes/skins/SkinTemplate.php

index 6cc139b..c858cfa 100644 (file)
@@ -656,7 +656,7 @@ abstract class Skin extends ContextSource {
                $action = $this->getRequest()->getVal( 'action', 'view' );
 
                if ( $this->getTitle()->userCan( 'deletedhistory', $this->getUser() ) &&
-                       ( $this->getTitle()->getArticleID() == 0 || $action == 'history' ) ) {
+                       ( !$this->getTitle()->exists() || $action == 'history' ) ) {
                        $n = $this->getTitle()->isDeleted();
 
                        if ( $n ) {
@@ -1166,7 +1166,7 @@ abstract class Skin extends ContextSource {
 
                return array(
                        'href' => $title->getLocalURL( $urlaction ),
-                       'exists' => $title->getArticleID() != 0,
+                       'exists' => $title->isKnown(),
                );
        }
 
index 45a1a8b..8136d8e 100644 (file)
@@ -743,17 +743,20 @@ class SkinTemplate extends Skin {
                self::checkTitle( $title, $name );
                return array(
                        'href' => $title->getLocalURL( $urlaction ),
-                       'exists' => $title->getArticleID() != 0,
+                       'exists' => $title->isKnown(),
                );
        }
 
+       /**
+        * @todo is this even used?
+        */
        function makeArticleUrlDetails( $name, $urlaction = '' ) {
                $title = Title::newFromText( $name );
                $title = $title->getSubjectPage();
                self::checkTitle( $title, $name );
                return array(
                        'href' => $title->getLocalURL( $urlaction ),
-                       'exists' => $title->getArticleID() != 0,
+                       'exists' => $title->exists(),
                );
        }
 
@@ -1213,7 +1216,7 @@ class SkinTemplate extends Skin {
                                'href' => $this->getTitle()->getLocalURL( "action=info" )
                        );
 
-                       if ( $this->getTitle()->getArticleID() ) {
+                       if ( $this->getTitle()->exists() ) {
                                $nav_urls['recentchangeslinked'] = array(
                                        'href' => SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage )->getLocalURL()
                                );