From f16c92bdff44794dd698a691b6ad25dcaa059c90 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 17 Feb 2015 14:04:36 -0800 Subject: [PATCH] skin: Use Title::isKnown() / Title::exists() instead of Title::getArticleID() 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 | 4 ++-- includes/skins/SkinTemplate.php | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 6cc139bfb5..c858cfa696 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -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(), ); } diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 45a1a8ba8e..8136d8e9dc 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -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() ); -- 2.20.1