From 08822b8200ad947fd7ba74e1737c7844ac94f604 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 27 Jun 2016 14:32:02 +0200 Subject: [PATCH] skins: Minor code clean up * Make Skin::initPage visibility explicit. * Make Skin::preloadExistence protected (not used outside this class). * Remove use of empty(). * Avoid empty if-block. Change-Id: I85bac34ded3414af5b998af614d554402ce92f21 --- includes/skins/Skin.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index fce68bba4e..fa46a460e7 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -141,10 +141,8 @@ abstract class Skin extends ContextSource { /** * @param OutputPage $out */ - function initPage( OutputPage $out ) { - + public function initPage( OutputPage $out ) { $this->preloadExistence(); - } /** @@ -199,30 +197,29 @@ abstract class Skin extends ContextSource { /** * Preload the existence of three commonly-requested pages in a single query */ - function preloadExistence() { + protected function preloadExistence() { $titles = []; - $user = $this->getUser(); - $title = $this->getRelevantTitle(); - // User/talk link + $user = $this->getUser(); if ( $user->isLoggedIn() ) { $titles[] = $user->getUserPage(); $titles[] = $user->getTalkPage(); } // Check, if the page can hold some kind of content, otherwise do nothing - if ( !$title->canExist() ) { - // nothing - } elseif ( $title->isTalkPage() ) { - $titles[] = $title->getSubjectPage(); - } else { - $titles[] = $title->getTalkPage(); + $title = $this->getRelevantTitle(); + if ( $title->canExist() ) { + if ( $title->isTalkPage() ) { + $titles[] = $title->getSubjectPage(); + } else { + $titles[] = $title->getTalkPage(); + } } Hooks::run( 'SkinPreloadExistence', [ &$titles, $this ] ); - if ( count( $titles ) ) { + if ( $titles ) { $lb = new LinkBatch( $titles ); $lb->setCaller( __METHOD__ ); $lb->execute(); -- 2.20.1