r103047 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103046‎ | r103047 | r103048 >
Date:21:57, 14 November 2011
Author:dantman
Status:ok (Comments)
Tags:
Comment:
Add isset tests to stuff inside BaseTemplate::getToolbox.
Modified paths:
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -1411,20 +1411,20 @@
14121412 wfProfileIn( __METHOD__ );
14131413
14141414 $toolbox = array();
1415 - if ( $this->data['nav_urls']['whatlinkshere'] ) {
 1415+ if ( isset( $this->data['nav_urls']['whatlinkshere'] ) && $this->data['nav_urls']['whatlinkshere'] ) {
14161416 $toolbox['whatlinkshere'] = $this->data['nav_urls']['whatlinkshere'];
14171417 $toolbox['whatlinkshere']['id'] = 't-whatlinkshere';
14181418 }
1419 - if ( $this->data['nav_urls']['recentchangeslinked'] ) {
 1419+ if ( isset( $this->data['nav_urls']['recentchangeslinked'] ) && $this->data['nav_urls']['recentchangeslinked'] ) {
14201420 $toolbox['recentchangeslinked'] = $this->data['nav_urls']['recentchangeslinked'];
14211421 $toolbox['recentchangeslinked']['msg'] = 'recentchangeslinked-toolbox';
14221422 $toolbox['recentchangeslinked']['id'] = 't-recentchangeslinked';
14231423 }
1424 - if ( $this->data['nav_urls']['trackbacklink'] ) {
 1424+ if ( isset( $this->data['nav_urls']['trackbacklink'] ) && $this->data['nav_urls']['trackbacklink'] ) {
14251425 $toolbox['trackbacklink'] = $this->data['nav_urls']['trackbacklink'];
14261426 $toolbox['trackbacklink']['id'] = 't-trackbacklink';
14271427 }
1428 - if ( $this->data['feeds'] ) {
 1428+ if ( isset( $this->data['feeds'] ) && $this->data['feeds'] ) {
14291429 $toolbox['feeds']['id'] = 'feedlinks';
14301430 $toolbox['feeds']['links'] = array();
14311431 foreach ( $this->data['feeds'] as $key => $feed ) {
@@ -1436,17 +1436,17 @@
14371437 }
14381438 }
14391439 foreach ( array( 'contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages' ) as $special ) {
1440 - if ( $this->data['nav_urls'][$special] ) {
 1440+ if ( isset( $this->data['nav_urls'][$special] ) && $this->data['nav_urls'][$special] ) {
14411441 $toolbox[$special] = $this->data['nav_urls'][$special];
14421442 $toolbox[$special]['id'] = "t-$special";
14431443 }
14441444 }
1445 - if ( $this->data['nav_urls']['print'] ) {
 1445+ if ( isset( $this->data['nav_urls']['print'] ) && $this->data['nav_urls']['print'] ) {
14461446 $toolbox['print'] = $this->data['nav_urls']['print'];
14471447 $toolbox['print']['rel'] = 'alternate';
14481448 $toolbox['print']['msg'] = 'printableversion';
14491449 }
1450 - if( $this->data['nav_urls']['permalink'] ) {
 1450+ if ( isset( $this->data['nav_urls']['permalink'] ) && $this->data['nav_urls']['permalink'] ) {
14511451 $toolbox['permalink'] = $this->data['nav_urls']['permalink'];
14521452 if( $toolbox['permalink']['href'] === '' ) {
14531453 unset( $toolbox['permalink']['href'] );

Comments

#Comment by Hashar (talk | contribs)   12:03, 5 December 2011

Isn't it shorter to use !empty() in this context?

#Comment by Nikerabbit (talk | contribs)   09:38, 16 December 2011

Yes. Unless we want to check that the input is a string.

Status & tagging log