Updated some try-catch statements: MWException -> Exception
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 9 Jan 2015 23:44:47 +0000 (15:44 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 10 Jan 2015 01:20:22 +0000 (17:20 -0800)
Change-Id: I76601a86e30f4984e3b1a8c8ec5ef5a0f652433a

42 files changed:
includes/CategoryViewer.php
includes/FileDeleteForm.php
includes/GlobalFunctions.php
includes/api/ApiImport.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryWatchlist.php
includes/api/ApiUpload.php
includes/cache/bloom/BloomCache.php
includes/db/Database.php
includes/db/DatabaseError.php
includes/deferred/DeferredUpdates.php
includes/exception/MWExceptionHandler.php
includes/externalstore/ExternalStore.php
includes/filebackend/SwiftFileBackend.php
includes/filebackend/lockmanager/DBLockManager.php
includes/htmlform/HTMLFormField.php
includes/installer/DatabaseInstaller.php
includes/installer/Installer.php
includes/jobqueue/JobQueue.php
includes/jobqueue/JobRunner.php
includes/jobqueue/jobs/AssembleUploadChunksJob.php
includes/jobqueue/jobs/PublishStashedFileJob.php
includes/media/BMP.php
includes/media/BitmapMetadataHandler.php
includes/media/Jpeg.php
includes/media/SVG.php
includes/media/Tiff.php
includes/media/XCF.php
includes/media/XMP.php
includes/page/Article.php
includes/page/WikiPage.php
includes/parser/Parser.php
includes/specials/SpecialContributions.php
includes/specials/SpecialImport.php
includes/specials/SpecialNewimages.php
includes/specials/SpecialRandomInCategory.php
includes/specials/SpecialUpload.php
includes/utils/UIDGenerator.php
maintenance/doMaintenance.php
maintenance/language/checkLanguage.php
maintenance/populateRevisionSha1.php
maintenance/preprocessorFuzzTest.php

index 4d23ed2..1a09d44 100644 (file)
@@ -152,7 +152,7 @@ class CategoryViewer extends ContextSource {
                        $mode = $this->getRequest()->getVal( 'gallerymode', null );
                        try {
                                $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // User specified something invalid, fallback to default.
                                $this->gallery = ImageGalleryBase::factory( false, $this->getContext() );
                        }
index 1c709e6..c1d14db 100644 (file)
@@ -201,7 +201,7 @@ class FileDeleteForm {
                                                $dbw->rollback( __METHOD__ );
                                        }
                                }
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // Rollback before returning to prevent UI from displaying
                                // incorrect "View or restore N deleted edits?"
                                $dbw->rollback( __METHOD__ );
index f516759..a1c39fb 100644 (file)
@@ -1328,7 +1328,7 @@ function wfLogProfilingData() {
        // any knowledge about an URL and throw an exception instead.
        try {
                $ctx['url'] = urldecode( $wgRequest->getRequestURL() );
-       } catch ( MWException $ignored ) {
+       } catch ( Exception $ignored ) {
                // no-op
        }
 
index a134074..c7dcce8 100644 (file)
@@ -79,7 +79,7 @@ class ApiImport extends ApiBase {
 
                try {
                        $importer->doImport();
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $this->dieUsageMsg( array( 'import-unknownerror', $e->getMessage() ) );
                }
 
index cdc61cd..b6ef604 100644 (file)
@@ -178,7 +178,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                if ( !is_null( $params['type'] ) ) {
                        try {
                                $this->addWhereFld( 'rc_type', RecentChange::parseToRCType( $params['type'] ) );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                ApiBase::dieDebug( __METHOD__, $e->getMessage() );
                        }
                }
index 4059ff8..6e60fe4 100644 (file)
@@ -199,7 +199,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                if ( !is_null( $params['type'] ) ) {
                        try {
                                $this->addWhereFld( 'rc_type', RecentChange::parseToRCType( $params['type'] ) );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                ApiBase::dieDebug( __METHOD__, $e->getMessage() );
                        }
                }
index 43e4c61..d6ad7f3 100644 (file)
@@ -161,7 +161,7 @@ class ApiUpload extends ApiBase {
                        }
                } catch ( UploadStashException $e ) {
                        $this->handleStashException( $e );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $this->dieUsage( $e->getMessage(), 'stashfailed' );
                }
 
@@ -182,7 +182,7 @@ class ApiUpload extends ApiBase {
                try {
                        $result['filekey'] = $this->performStash();
                        $result['sessionkey'] = $result['filekey']; // backwards compatibility
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $result['warnings']['stashfailed'] = $e->getMessage();
                }
 
@@ -209,7 +209,7 @@ class ApiUpload extends ApiBase {
                                $filekey = $this->performStash();
                        } catch ( UploadStashException $e ) {
                                $this->handleStashException( $e );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // FIXME: Error handling here is wrong/different from rest of this
                                $this->dieUsage( $e->getMessage(), 'stashfailed' );
                        }
@@ -283,7 +283,7 @@ class ApiUpload extends ApiBase {
                                throw new MWException( 'Invalid stashed file' );
                        }
                        $fileKey = $stashFile->getFileKey();
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $message = 'Stashing temporary file failed: ' . get_class( $e ) . ' ' . $e->getMessage();
                        wfDebug( __METHOD__ . ' ' . $message . "\n" );
                        $className = get_class( $e );
@@ -306,7 +306,7 @@ class ApiUpload extends ApiBase {
                try {
                        $data['filekey'] = $this->performStash();
                        $data['sessionkey'] = $data['filekey'];
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $data['stashfailed'] = $e->getMessage();
                }
                $data['invalidparameter'] = $parameter;
index 2720933..6ecaacb 100644 (file)
@@ -114,7 +114,7 @@ abstract class BloomCache {
                                if ( $useFilter ) {
                                        return ( $this->isHit( 'shared', "$virtualKey:$member" ) !== false );
                                }
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                MWExceptionHandler::logException( $e );
                                return true;
                        }
@@ -143,7 +143,7 @@ abstract class BloomCache {
                                }
 
                                return $this->add( 'shared', $prefixedMembers );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                MWExceptionHandler::logException( $e );
                                return false;
                        }
index 0b022d1..054f27a 100644 (file)
@@ -3962,7 +3962,7 @@ abstract class DatabaseBase implements IDatabase {
 
                try {
                        $error = $this->sourceStream( $fp, $lineCallback, $resultCallback, $fname, $inputCallback );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        fclose( $fp );
                        throw $e;
                }
index 2393bbb..86950a8 100644 (file)
@@ -229,7 +229,7 @@ class DBConnectionError extends DBExpectedError {
 
                                        return;
                                }
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // Do nothing, just use the default page
                        }
                }
index 93c53ad..42816dd 100644 (file)
@@ -107,7 +107,7 @@ class DeferredUpdates {
                                        if ( $doCommit && $dbw->trxLevel() ) {
                                                $dbw->commit( __METHOD__, 'flush' );
                                        }
-                               } catch ( MWException $e ) {
+                               } catch ( Exception $e ) {
                                        // We don't want exceptions thrown during deferred updates to
                                        // be reported to the user since the output is already sent.
                                        // Instead we just log them.
index ad462f2..5ea9359 100644 (file)
@@ -142,7 +142,7 @@ class MWExceptionHandler {
         *
         *   try {
         *       ...
-        *   } catch ( MWException $e ) {
+        *   } catch ( Exception $e ) {
         *       $e->report();
         *   } catch ( Exception $e ) {
         *       echo $e->__toString();
index 688130e..ea04cc8 100644 (file)
@@ -197,7 +197,7 @@ class ExternalStore {
                        }
                        try {
                                $url = $store->store( $path, $data ); // Try to save the object
-                       } catch ( MWException $error ) {
+                       } catch ( Exception $error ) {
                                $url = false;
                        }
                        if ( strlen( $url ) ) {
index 4fde124..2637b5a 100644 (file)
@@ -647,7 +647,7 @@ class SwiftFileBackend extends FileBackendStore {
                        $timestamp = new MWTimestamp( $ts );
 
                        return $timestamp->getTimestamp( $format );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        throw new FileBackendError( $e->getMessage() );
                }
        }
index affcf44..39a5563 100644 (file)
@@ -97,7 +97,7 @@ abstract class DBLockManager extends QuorumLockManager {
                                // connection timeouts. This is useless if each bucket has one peer.
                                try {
                                        $this->statusCache = ObjectCache::newAccelerator( array() );
-                               } catch ( MWException $e ) {
+                               } catch ( Exception $e ) {
                                        trigger_error( __CLASS__ .
                                                " using multiple DB peers without apc, xcache, or wincache." );
                                }
index 11b88b4..a91f331 100644 (file)
@@ -218,7 +218,7 @@ abstract class HTMLFormField {
                                default:
                                        throw new MWException( "Unknown operation" );
                        }
-               } catch ( MWException $ex ) {
+               } catch ( Exception $ex ) {
                        throw new MWException(
                                "Invalid hide-if specification for $this->mName: " .
                                $ex->getMessage() . " in " . var_export( $origParams, true ),
index 31b93c8..f36bac1 100644 (file)
@@ -305,7 +305,7 @@ abstract class DatabaseInstaller {
                $up = DatabaseUpdater::newForDB( $this->db );
                try {
                        $up->doUpdates();
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        echo "\nAn error occurred:\n";
                        echo $e->getText();
                        $ret = false;
index 381f23c..4159c1d 100644 (file)
@@ -1377,7 +1377,7 @@ abstract class Installer {
 
                                try {
                                        $text = Http::get( $url . $file, array( 'timeout' => 3 ) );
-                               } catch ( MWException $e ) {
+                               } catch ( Exception $e ) {
                                        // Http::get throws with allow_url_fopen = false and no curl extension.
                                        $text = null;
                                }
@@ -1753,7 +1753,7 @@ abstract class Installer {
                                false,
                                User::newFromName( 'MediaWiki default' )
                        );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        //using raw, because $wgShowExceptionDetails can not be set yet
                        $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
                }
index 1f99b1e..53fcaee 100644 (file)
@@ -362,7 +362,7 @@ abstract class JobQueue {
                                JobQueue::incrStats( 'job-pop-duplicate', $this->type, 1, $this->wiki );
                                $job = DuplicateJob::newFromJob( $job ); // convert to a no-op
                        }
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        // don't lose jobs over this
                }
 
index ce3b3ff..d99bfab 100644 (file)
@@ -135,7 +135,7 @@ class JobRunner {
                                        $status = $job->run();
                                        $error = $job->getLastError();
                                        wfGetLBFactory()->commitMasterChanges();
-                               } catch ( MWException $e ) {
+                               } catch ( Exception $e ) {
                                        MWExceptionHandler::rollbackMasterChangesAndLog( $e );
                                        $status = false;
                                        $error = get_class( $e ) . ': ' . $e->getMessage();
index cc28a01..b7f09e7 100644 (file)
@@ -94,7 +94,7 @@ class AssembleUploadChunksJob extends Job {
                                        'status' => Status::newGood()
                                )
                        );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        UploadBase::setSessionStatus(
                                $user,
                                $this->params['filekey'],
index 55215b3..3d4cfae 100644 (file)
@@ -108,7 +108,7 @@ class PublishStashedFileJob extends Job {
                                        'status' => Status::newGood()
                                )
                        );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        UploadBase::setSessionStatus(
                                $user,
                                $this->params['filekey'],
index d8b0ba6..52f9518 100644 (file)
@@ -71,7 +71,7 @@ class BmpHandler extends BitmapHandler {
                try {
                        $w = wfUnpack( 'V', $w, 4 );
                        $h = wfUnpack( 'V', $h, 4 );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        return false;
                }
 
index dd41c38..bb7a1e8 100644 (file)
@@ -61,7 +61,7 @@ class BitmapMetadataHandler {
        private function doApp13( $app13 ) {
                try {
                        $this->iptcType = JpegMetadataExtractor::doPSIR( $app13 );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        // Error reading the iptc hash information.
                        // This probably means the App13 segment is something other than what we expect.
                        // However, still try to read it, and treat it as if the hash didn't exist.
index 810b9af..5463922 100644 (file)
@@ -106,7 +106,7 @@ class JpegHandler extends ExifBitmapHandler {
                        $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
 
                        return serialize( $meta );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        // BitmapMetadataHandler throws an exception in certain exceptional
                        // cases like if file does not exist.
                        wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
index 3e8d9e5..53abfef 100644 (file)
@@ -362,7 +362,7 @@ class SvgHandler extends ImageHandler {
                $metadata = array( 'version' => self::SVG_METADATA_VERSION );
                try {
                        $metadata += SVGMetadataExtractor::getMetadata( $filename );
-               } catch ( MWException $e ) { // @todo SVG specific exceptions
+               } catch ( Exception $e ) { // @todo SVG specific exceptions
                        // File not found, broken, etc.
                        $metadata['error'] = array(
                                'message' => $e->getMessage(),
index bea6cab..750528f 100644 (file)
@@ -88,7 +88,7 @@ class TiffHandler extends ExifBitmapHandler {
                                $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
 
                                return serialize( $meta );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // BitmapMetadataHandler throws an exception in certain exceptional
                                // cases like if file does not exist.
                                wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
index 48b7a47..6544d5c 100644 (file)
@@ -130,7 +130,7 @@ class XCFHandler extends BitmapHandler {
                                        "/Nbase_type", # /
                                $binaryHeader
                        );
-               } catch ( MWException $mwe ) {
+               } catch ( Exception $mwe ) {
                        return false;
                }
 
index 5b46af1..0d341aa 100644 (file)
@@ -316,7 +316,7 @@ class XMPReader {
                                $this->results = array(); // blank if error.
                                return false;
                        }
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        wfDebugLog( 'XMP', 'XMP parse error: ' . $e );
                        $this->results = array();
 
index 5a09e65..438a17c 100644 (file)
@@ -1594,7 +1594,7 @@ class Article implements Page {
                if ( !$reason ) {
                        try {
                                $reason = $this->generateReason( $hasHistory );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                # if a page is horribly broken, we still want to be able to
                                # delete it. So be lenient about errors here.
                                wfDebug( "Error while building auto delete summary: $e" );
index 0eeab1c..8373dc0 100644 (file)
@@ -1844,7 +1844,7 @@ class WikiPage implements Page, IDBAccessObject {
                                                }
                                        }
                                        $user->incEditCount();
-                               } catch ( MWException $e ) {
+                               } catch ( Exception $e ) {
                                        $dbw->rollback( __METHOD__ );
                                        // Question: Would it perhaps be better if this method turned all
                                        // exceptions into $status's?
@@ -1947,7 +1947,7 @@ class WikiPage implements Page, IDBAccessObject {
                                }
                                $user->incEditCount();
 
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                $dbw->rollback( __METHOD__ );
                                throw $e;
                        }
index 7703c4b..fc7040a 100644 (file)
@@ -5285,7 +5285,7 @@ class Parser {
 
                try {
                        $ig = ImageGalleryBase::factory( $mode );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        // If invalid type set, fallback to default.
                        $ig = ImageGalleryBase::factory( false );
                }
index c96fd14..c2cd812 100644 (file)
@@ -969,7 +969,7 @@ class ContribsPager extends ReverseChronologicalPager {
                try {
                        $rev = new Revision( $row );
                        $validRevision = (bool)$rev->getId();
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $validRevision = false;
                }
                wfRestoreWarnings();
index 9e9f8c0..aa9b0f4 100644 (file)
@@ -194,7 +194,7 @@ class SpecialImport extends SpecialPage {
                        $reporter->open();
                        try {
                                $importer->doImport();
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                $exception = $e;
                        }
                        $result = $reporter->close();
index bc16925..94e77e3 100644 (file)
@@ -141,7 +141,7 @@ class NewFilesPager extends ReverseChronologicalPager {
                        $mode = $this->getRequest()->getVal( 'gallerymode', null );
                        try {
                                $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // User specified something invalid, fallback to default.
                                $this->gallery = ImageGalleryBase::factory( false, $this->getContext() );
                        }
index b4af7ba..69436bf 100644 (file)
@@ -230,7 +230,7 @@ class SpecialRandomInCategory extends FormSpecialPage {
                if ( !$this->minTimestamp || !$this->maxTimestamp ) {
                        try {
                                list( $this->minTimestamp, $this->maxTimestamp ) = $this->getMinAndMaxForCat( $this->category );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // Possibly no entries in category.
                                return false;
                        }
index d9e3a67..b965b54 100644 (file)
@@ -988,7 +988,7 @@ class UploadForm extends HTMLForm {
                        $stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash();
                        try {
                                $file = $stash->getFile( $this->mSessionKey );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                $file = null;
                        }
                        if ( $file ) {
index 33e9116..9241587 100644 (file)
@@ -281,7 +281,7 @@ class UIDGenerator {
                if ( ( $flags & self::QUICK_VOLATILE ) && PHP_SAPI !== 'cli' ) {
                        try {
                                $cache = ObjectCache::newAccelerator( array() );
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                // not supported
                        }
                }
index 6616057..c93a971 100644 (file)
@@ -114,7 +114,7 @@ try {
        $factory = wfGetLBFactory();
        $factory->commitMasterChanges();
        $factory->shutdown();
-} catch ( MWException $mwe ) {
+} catch ( Exception $mwe ) {
        echo $mwe->getText();
        exit( 1 );
 }
index ec6e122..bd9f9af 100644 (file)
@@ -29,6 +29,6 @@ $cli = new CheckLanguageCLI( $options );
 
 try {
        $cli->execute();
-} catch ( MWException $e ) {
+} catch ( Exception $e ) {
        print 'Error: ' . $e->getMessage() . "\n";
 }
index f06b56b..b401db0 100644 (file)
@@ -153,7 +153,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                                ? Revision::newFromArchiveRow( $row )
                                : new Revision( $row );
                        $text = $rev->getSerializedData();
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
 
                        return false; // bug 22624?
@@ -182,7 +182,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
                $db = $this->getDB( DB_MASTER );
                try {
                        $rev = Revision::newFromArchiveRow( $row );
-               } catch ( MWException $e ) {
+               } catch ( Exception $e ) {
                        $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
 
                        return false; // bug 22624?
index cb55f0f..e1710c1 100644 (file)
@@ -64,7 +64,7 @@ class PPFuzzTester {
                                self::$currentTest = new PPFuzzTest( $this );
                                self::$currentTest->execute();
                                $passed = 'passed';
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                $testReport = self::$currentTest->getReport();
                                $exceptionReport = $e->getText();
                                $hash = md5( $testReport );