Don't use isset() to check whether an existing variable is null
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Sun, 10 Mar 2013 15:23:46 +0000 (16:23 +0100)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Sun, 10 Mar 2013 15:23:46 +0000 (16:23 +0100)
Change-Id: Ie63f060fb7928fd51a8ad71293955f923f6a18c3

includes/ImagePage.php
includes/Import.php
includes/Linker.php
includes/MimeMagic.php

index 998d607..086b4dd 100644 (file)
@@ -108,7 +108,7 @@ class ImagePage extends Article {
                $diff = $request->getVal( 'diff' );
                $diffOnly = $request->getBool( 'diffonly', $this->getContext()->getUser()->getOption( 'diffonly' ) );
 
-               if ( $this->getTitle()->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) {
+               if ( $this->getTitle()->getNamespace() != NS_FILE || ( $diff !== null && $diffOnly ) ) {
                        parent::view();
                        return;
                }
@@ -116,7 +116,7 @@ class ImagePage extends Article {
                $this->loadFile();
 
                if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) {
-                       if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || isset( $diff ) ) {
+                       if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) {
                                // mTitle is the same as the redirect target so ask Article
                                // to perform the redirect for us.
                                $request->setVal( 'diffonly', 'true' );
index 15e6620..78f77a1 100644 (file)
@@ -1646,7 +1646,7 @@ class ImportStreamSource {
        static function newFromUpload( $fieldname = "xmlimport" ) {
                $upload =& $_FILES[$fieldname];
 
-               if( !isset( $upload ) || !$upload['name'] ) {
+               if( $upload === null || !$upload['name'] ) {
                        return Status::newFatal( 'importnofile' );
                }
                if( !empty( $upload['error'] ) ) {
index a9bf934..d5b3b2f 100644 (file)
@@ -616,7 +616,7 @@ class Linker {
 
                        if ( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
                                global $wgThumbLimits, $wgThumbUpright;
-                               if ( !isset( $widthOption ) || !isset( $wgThumbLimits[$widthOption] ) ) {
+                               if ( $widthOption === null || !isset( $wgThumbLimits[$widthOption] ) ) {
                                        $widthOption = User::getDefaultOption( 'thumbsize' );
                                }
 
index 226b0b1..72bb4c6 100644 (file)
@@ -346,7 +346,7 @@ class MimeMagic {
         * @return MimeMagic
         */
        public static function &singleton() {
-               if ( !isset( self::$instance ) ) {
+               if ( self::$instance === null ) {
                        self::$instance = new MimeMagic;
                }
                return self::$instance;