From 8a012819139e37ddc8f6bd1727e3fdd640e2958d Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 24 Aug 2010 22:03:18 +0000 Subject: [PATCH] Remove some unreachable code (usually returns after throwing exceptions) Fixup call of method after return in DatabaseMssql by using a temp --- includes/Hooks.php | 2 -- includes/MagicWord.php | 1 - includes/Namespace.php | 1 - includes/db/DatabaseMssql.php | 3 ++- includes/filerepo/ArchivedFile.php | 1 - includes/filerepo/ForeignAPIFile.php | 2 +- includes/media/PNGMetadataExtractor.php | 16 ++++++++++++---- includes/specials/SpecialResetpass.php | 1 - maintenance/tests/SearchEngineTest.php | 4 ++-- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index 37e4e41f74..168f4bd9a5 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -46,12 +46,10 @@ function wfRunHooks($event, $args = array()) { if (!is_array($wgHooks)) { throw new MWException("Global hooks array is not an array!\n"); - return false; } if (!is_array($wgHooks[$event])) { throw new MWException("Hooks array for event '$event' is not an array!\n"); - return false; } foreach ($wgHooks[$event] as $index => $hook) { diff --git a/includes/MagicWord.php b/includes/MagicWord.php index a0bcd8caed..cd9769ed87 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -648,7 +648,6 @@ class MagicWordArray { } // This shouldn't happen either throw new MWException( __METHOD__.': parameter not found' ); - return array( false, false ); } /** diff --git a/includes/Namespace.php b/includes/Namespace.php index 87fda8c123..48a93dde91 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -117,7 +117,6 @@ class MWNamespace { return isset( $nslist[$index] ); } - /** * Returns array of all defined namespaces with their canonical * (English) names. diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index c25c4d8f46..67bb353e56 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -286,8 +286,9 @@ class DatabaseMssql extends DatabaseBase { $sql = $this->selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds ); if ( isset( $options['EXPLAIN'] ) ) { sqlsrv_query( $this->mConn, "SET SHOWPLAN_ALL ON;" ); - return $this->query( $sql, $fname ); + $ret = $this->query( $sql, $fname ); sqlsrv_query( $this->mConn, "SET SHOWPLAN_ALL OFF;" ); + return $ret; } return $this->query( $sql, $fname ); } diff --git a/includes/filerepo/ArchivedFile.php b/includes/filerepo/ArchivedFile.php index ffc063038e..368a561edf 100644 --- a/includes/filerepo/ArchivedFile.php +++ b/includes/filerepo/ArchivedFile.php @@ -140,7 +140,6 @@ class ArchivedFile $this->deleted = $row->fa_deleted; } else { throw new MWException( 'This title does not correspond to an image page.' ); - return; } $this->dataLoaded = true; $this->exists = true; diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index c00fcd8ee5..7c33a49809 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -63,7 +63,7 @@ class ForeignAPIFile extends File { $this->getName(), isset( $params['width'] ) ? $params['width'] : -1, isset( $params['height'] ) ? $params['height'] : -1 ); - return $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params );; + return $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params ); } // Info we can get from API... diff --git a/includes/media/PNGMetadataExtractor.php b/includes/media/PNGMetadataExtractor.php index 490abead2d..1c9add9e94 100644 --- a/includes/media/PNGMetadataExtractor.php +++ b/includes/media/PNGMetadataExtractor.php @@ -45,23 +45,31 @@ class PNGMetadataExtractor { // Read chunks while( !feof( $fh ) ) { $buf = fread( $fh, 4 ); - if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; } + if( !$buf ) { + throw new Exception( __METHOD__ . ": Read error" ); + } $chunk_size = unpack( "N", $buf); $chunk_size = $chunk_size[1]; $chunk_type = fread( $fh, 4 ); - if( !$chunk_type ) { throw new Exception( __METHOD__ . ": Read error" ); return; } + if( !$chunk_type ) { + throw new Exception( __METHOD__ . ": Read error" ); + } if ( $chunk_type == "acTL" ) { $buf = fread( $fh, $chunk_size ); - if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; } + if( !$buf ) { + throw new Exception( __METHOD__ . ": Read error" ); + } $actl = unpack( "Nframes/Nplays", $buf ); $frameCount = $actl['frames']; $loopCount = $actl['plays']; } elseif ( $chunk_type == "fcTL" ) { $buf = fread( $fh, $chunk_size ); - if( !$buf ) { throw new Exception( __METHOD__ . ": Read error" ); return; } + if( !$buf ) { + throw new Exception( __METHOD__ . ": Read error" ); + } $buf = substr( $buf, 20 ); $fctldur = unpack( "ndelay_num/ndelay_den", $buf ); diff --git a/includes/specials/SpecialResetpass.php b/includes/specials/SpecialResetpass.php index cf0761fba1..f4893badc3 100644 --- a/includes/specials/SpecialResetpass.php +++ b/includes/specials/SpecialResetpass.php @@ -222,7 +222,6 @@ class SpecialResetpass extends SpecialPage { } catch( PasswordError $e ) { wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) ); throw new PasswordError( $e->getMessage() ); - return; } $user->setCookies(); diff --git a/maintenance/tests/SearchEngineTest.php b/maintenance/tests/SearchEngineTest.php index d155eeb03a..47d03e2eb5 100644 --- a/maintenance/tests/SearchEngineTest.php +++ b/maintenance/tests/SearchEngineTest.php @@ -35,11 +35,11 @@ class SearchEngineTest extends MediaWikiTestSetup { function removeSearchData() { return; - while ( count( $this->pageList ) ) { + /*while ( count( $this->pageList ) ) { list( $title, $id ) = array_pop( $this->pageList ); $article = new Article( $title, $id ); $article->doDeleteArticle( "Search Test" ); - } + }*/ } function fetchIds( $results ) { -- 2.20.1