Don't use isset to check for null
authorAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Fri, 4 Jul 2014 19:20:22 +0000 (21:20 +0200)
committerAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Fri, 4 Jul 2014 19:20:22 +0000 (21:20 +0200)
Change isset() checks for variables that are always defined.

Change-Id: Ic96b9661d94742909c0d6b62a8eb2f6a038a774f

includes/Setup.php
includes/SiteConfiguration.php
includes/Skin.php
includes/Title.php
includes/User.php

index 67d8da3..fd4465b 100644 (file)
@@ -114,7 +114,7 @@ if ( isset( $wgFooterIcons['copyright'] )
        && isset( $wgFooterIcons['copyright']['copyright'] )
        && $wgFooterIcons['copyright']['copyright'] === array()
 ) {
-       if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
+       if ( $wgCopyrightIcon ) {
                $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
        } elseif ( $wgRightsIcon || $wgRightsText ) {
                $wgFooterIcons['copyright']['copyright'] = array(
index b99840f..b7fa6ec 100644 (file)
@@ -207,14 +207,14 @@ class SiteConfiguration {
                                // Do tag settings
                                foreach ( $params['tags'] as $tag ) {
                                        if ( array_key_exists( $tag, $thisSetting ) ) {
-                                               if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$tag] ) ) {
+                                               if ( is_array( $retval ) && is_array( $thisSetting[$tag] ) ) {
                                                        $retval = self::arrayMerge( $retval, $thisSetting[$tag] );
                                                } else {
                                                        $retval = $thisSetting[$tag];
                                                }
                                                break 2;
                                        } elseif ( array_key_exists( "+$tag", $thisSetting ) && is_array( $thisSetting["+$tag"] ) ) {
-                                               if ( !isset( $retval ) ) {
+                                               if ( $retval === null ) {
                                                        $retval = array();
                                                }
                                                $retval = self::arrayMerge( $retval, $thisSetting["+$tag"] );
@@ -224,7 +224,7 @@ class SiteConfiguration {
                                $suffix = $params['suffix'];
                                if ( !is_null( $suffix ) ) {
                                        if ( array_key_exists( $suffix, $thisSetting ) ) {
-                                               if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) {
+                                               if ( is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) {
                                                        $retval = self::arrayMerge( $retval, $thisSetting[$suffix] );
                                                } else {
                                                        $retval = $thisSetting[$suffix];
@@ -233,7 +233,7 @@ class SiteConfiguration {
                                        } elseif ( array_key_exists( "+$suffix", $thisSetting )
                                                && is_array( $thisSetting["+$suffix"] )
                                        ) {
-                                               if ( !isset( $retval ) ) {
+                                               if ( $retval === null ) {
                                                        $retval = array();
                                                }
                                                $retval = self::arrayMerge( $retval, $thisSetting["+$suffix"] );
index 177e2b1..14cd7af 100644 (file)
@@ -875,7 +875,7 @@ abstract class Skin extends ContextSource {
 
                $out = '';
 
-               if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
+               if ( $wgCopyrightIcon ) {
                        $out = $wgCopyrightIcon;
                } elseif ( $wgRightsIcon ) {
                        $icon = htmlspecialchars( $wgRightsIcon );
index e038cc7..22511b0 100644 (file)
@@ -2569,7 +2569,7 @@ class Title {
                        return false;
                }
 
-               if ( !isset( $this->mTitleProtection ) ) {
+               if ( $this->mTitleProtection === null ) {
                        $dbr = wfGetDB( DB_SLAVE );
                        $res = $dbr->select(
                                'protected_titles',
@@ -2722,7 +2722,7 @@ class Title {
         * @since 1.23
         */
        public function areCascadeProtectionSourcesLoaded( $getPages = true ) {
-               return $getPages ? isset( $this->mCascadeSources ) : isset( $this->mHasCascadingRestrictions );
+               return $getPages ? $this->mCascadeSources !== null : $this->mHasCascadingRestrictions !== null;
        }
 
        /**
@@ -2742,9 +2742,9 @@ class Title {
                global $wgContLang;
                $pagerestrictions = array();
 
-               if ( isset( $this->mCascadeSources ) && $getPages ) {
+               if ( $this->mCascadeSources !== null && $getPages ) {
                        return array( $this->mCascadeSources, $this->mCascadingRestrictions );
-               } elseif ( isset( $this->mHasCascadingRestrictions ) && !$getPages ) {
+               } elseif ( $this->mHasCascadingRestrictions !== null && !$getPages ) {
                        return array( $this->mHasCascadingRestrictions, $pagerestrictions );
                }
 
@@ -3090,7 +3090,7 @@ class Title {
                # alone to cache the result.  There's no point in having it hanging
                # around uninitialized in every Title object; therefore we only add it
                # if needed and don't declare it statically.
-               if ( !isset( $this->mHasSubpages ) ) {
+               if ( $this->mHasSubpages === null ) {
                        $this->mHasSubpages = false;
                        $subpages = $this->getSubpages( 1 );
                        if ( $subpages instanceof TitleArray ) {
@@ -4779,7 +4779,9 @@ class Title {
         * @return string Last-touched timestamp
         */
        public function getTouched( $db = null ) {
-               $db = isset( $db ) ? $db : wfGetDB( DB_SLAVE );
+               if ( $db === null ) {
+                       $db = wfGetDB( DB_SLAVE );
+               }
                $touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ );
                return $touched;
        }
index 67ee7f9..5a117bd 100644 (file)
@@ -2946,7 +2946,7 @@ class User implements IDBAccessObject {
                        return null;
                }
 
-               if ( !isset( $this->mEditCount ) ) {
+               if ( $this->mEditCount === null ) {
                        /* Populate the count, if it has not been populated yet */
                        wfProfileIn( __METHOD__ );
                        $dbr = wfGetDB( DB_SLAVE );