Don't use isset() to check for null
authorAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Sat, 10 May 2014 12:23:50 +0000 (14:23 +0200)
committerAlexandre Emsenhuber <mediawiki@emsenhuber.ch>
Sat, 10 May 2014 12:23:50 +0000 (14:23 +0200)
Fixes in maintenance/

Change-Id: I300a2a0cb240cb3f9c1d0c76d4575f93e9706b59

maintenance/dumpLinks.php
maintenance/fixDoubleRedirects.php
maintenance/generateSitemap.php

index dfd1959..888c2dc 100644 (file)
@@ -59,7 +59,7 @@ class DumpLinks extends Maintenance {
                $lastPage = null;
                foreach ( $result as $row ) {
                        if ( $lastPage != $row->page_id ) {
-                               if ( isset( $lastPage ) ) {
+                               if ( $lastPage !== null ) {
                                        $this->output( "\n" );
                                }
                                $page = Title::makeTitle( $row->page_namespace, $row->page_title );
@@ -69,7 +69,7 @@ class DumpLinks extends Maintenance {
                        $link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
                        $this->output( " " . $link->getPrefixedURL() );
                }
-               if ( isset( $lastPage ) ) {
+               if ( $lastPage !== null ) {
                        $this->output( "\n" );
                }
        }
index 0b3cdba..a678a92 100644 (file)
@@ -44,13 +44,14 @@ class FixDoubleRedirects extends Maintenance {
        public function execute() {
                $async = $this->getOption( 'async', false );
                $dryrun = $this->getOption( 'dry-run', false );
-               $title = $this->getOption( 'title' );
 
-               if ( isset( $title ) ) {
-                       $title = Title::newFromText( $title );
+               if ( $this->hasOption( 'title' ) ) {
+                       $title = Title::newFromText( $this->getOption( 'title' ) );
                        if ( !$title || !$title->isRedirect() ) {
                                $this->error( $title->getPrefixedText() . " is not a redirect!\n", true );
                        }
+               } else {
+                       $title = null;
                }
 
                $dbr = wfGetDB( DB_SLAVE );
@@ -75,7 +76,7 @@ class FixDoubleRedirects extends Maintenance {
                        'pb.page_is_redirect' => 1,
                );
 
-               if ( isset( $title ) ) {
+               if ( $title != null ) {
                        $conds['pb.page_namespace'] = $title->getNamespace();
                        $conds['pb.page_title'] = $title->getDBkey();
                }
index c43851e..1930a22 100644 (file)
@@ -244,9 +244,6 @@ class GenerateSitemap extends Maintenance {
         * @return null|string
         */
        private static function init_path( $fspath ) {
-               if ( !isset( $fspath ) ) {
-                       return null;
-               }
                # Create directory if needed
                if ( $fspath && !is_dir( $fspath ) ) {
                        wfMkdirParents( $fspath, null, __METHOD__ ) or die( "Can not create directory $fspath.\n" );