From 978bb31c5ec29c3e4788ea83735c88dd66e98844 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 7 Apr 2013 18:34:58 +0200 Subject: [PATCH] Add missing wfProfileOut before throwing an exception Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23 --- includes/Block.php | 1 + includes/EditPage.php | 1 + includes/Export.php | 1 + includes/Hooks.php | 5 +++++ includes/MagicWord.php | 1 + includes/Revision.php | 2 ++ includes/StreamFile.php | 1 + includes/StubObject.php | 1 + includes/UserMailer.php | 1 + includes/WikiPage.php | 2 ++ includes/cache/LocalisationCache.php | 2 ++ includes/cache/MessageCache.php | 2 ++ includes/cache/SquidUpdate.php | 2 ++ includes/content/WikitextContent.php | 1 + includes/db/Database.php | 4 ++++ includes/db/DatabaseMysql.php | 1 + includes/db/LoadBalancer.php | 3 +++ includes/filebackend/FileBackendStore.php | 4 ++++ includes/filerepo/file/LocalFile.php | 1 + includes/filerepo/file/OldLocalFile.php | 1 + includes/parser/Parser.php | 3 +++ includes/parser/Preprocessor_DOM.php | 9 +++++++++ includes/parser/Preprocessor_Hash.php | 10 ++++++++++ includes/resourceloader/ResourceLoader.php | 3 +++ 24 files changed, 62 insertions(+) diff --git a/includes/Block.php b/includes/Block.php index 568f4b083f..4da0f8f7e6 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -1252,6 +1252,7 @@ class Block { } elseif ( $blocksList['auto'] ) { $chosenBlock = $blocksList['auto']; } else { + wfProfileOut( __METHOD__ ); throw new MWException( "Proxy block found, but couldn't be classified." ); } diff --git a/includes/EditPage.php b/includes/EditPage.php index f88dc90c15..96a57b4e59 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -621,6 +621,7 @@ class EditPage { $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) ); if ( $this->section !== null && $this->section !== '' && !$this->isSectionEditSupported() ) { + wfProfileOut( __METHOD__ ); throw new ErrorPageError( 'sectioneditnotsupported-title', 'sectioneditnotsupported-text' ); } diff --git a/includes/Export.php b/includes/Export.php index 085662ac60..996c14bd1c 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -296,6 +296,7 @@ class WikiExporter { } // Inform caller about problem + wfProfileOut( __METHOD__ ); throw $e; } # For page dumps... diff --git a/includes/Hooks.php b/includes/Hooks.php index e3ffb19f85..740abf7578 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -168,6 +168,7 @@ class Hooks { */ if ( is_array( $hook ) ) { if ( count( $hook ) < 1 ) { + wfProfileOut( 'hook: ' . $event ); throw new MWException( 'Empty array in hooks for ' . $event . "\n" ); } elseif ( is_object( $hook[0] ) ) { $object = $hook[0]; @@ -195,6 +196,7 @@ class Hooks { $have_data = true; } } else { + wfProfileOut( 'hook: ' . $event ); throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" ); } } elseif ( is_string( $hook ) ) { # functions look like strings, too @@ -207,6 +209,7 @@ class Hooks { $method = "on" . $event; } } else { + wfProfileOut( 'hook: ' . $event ); throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" ); } @@ -276,11 +279,13 @@ class Hooks { $prettyFunc = strval( $callback ); } if ( $badhookmsg ) { + wfProfileOut( 'hook: ' . $event ); throw new MWException( 'Detected bug in an extension! ' . "Hook $prettyFunc has invalid call signature; " . $badhookmsg ); } else { + wfProfileOut( 'hook: ' . $event ); throw new MWException( 'Detected bug in an extension! ' . "Hook $prettyFunc failed to return a value; " . diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 7b66924904..41c7cb9242 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -309,6 +309,7 @@ class MagicWord { $wgContLang->getMagic( $this ); if ( !$this->mSynonyms ) { $this->mSynonyms = array( 'dkjsagfjsgashfajsh' ); + wfProfileOut( __METHOD__ ); throw new MWException( "Error: invalid magic word '$id'" ); #wfDebugLog( 'exception', "Error: invalid magic word '$id'\n" ); } diff --git a/includes/Revision.php b/includes/Revision.php index 18cd94e5af..3ea5da4666 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1278,6 +1278,7 @@ class Revision implements IDBAccessObject { // Store and get the URL $data = ExternalStore::insertToDefault( $data ); if( !$data ) { + wfProfileOut( __METHOD__ ); throw new MWException( "Unable to store text to external storage" ); } if( $flags ) { @@ -1334,6 +1335,7 @@ class Revision implements IDBAccessObject { $title = $this->getTitle(); if ( $title === null ) { + wfProfileOut( __METHOD__ ); throw new MWException( "Insufficient information to determine the title of the revision's page!" ); } diff --git a/includes/StreamFile.php b/includes/StreamFile.php index f5e4acff46..1ad643ac98 100644 --- a/includes/StreamFile.php +++ b/includes/StreamFile.php @@ -42,6 +42,7 @@ class StreamFile { wfProfileIn( __METHOD__ ); if ( FileBackend::isStoragePath( $fname ) ) { // sanity + wfProfileOut( __METHOD__ ); throw new MWException( __FUNCTION__ . " given storage path '$fname'." ); } diff --git a/includes/StubObject.php b/includes/StubObject.php index f0a3574009..5b26d45fb1 100644 --- a/includes/StubObject.php +++ b/includes/StubObject.php @@ -122,6 +122,7 @@ class StubObject { wfProfileIn( $fname ); $caller = wfGetCaller( $level ); if ( ++$recursionLevel > 2 ) { + wfProfileOut( $fname ); throw new MWException( "Unstub loop detected on call of \${$this->mGlobal}->$name from $caller\n" ); } wfDebug( "Unstubbing \${$this->mGlobal} on call of \${$this->mGlobal}::$name from $caller\n" ); diff --git a/includes/UserMailer.php b/includes/UserMailer.php index c5dcfc3a75..2eb8429bae 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -605,6 +605,7 @@ class EmailNotification { wfRunHooks( 'UpdateUserMailerFormattedPageStatus', array( &$formattedPageStatus ) ); if ( !in_array( $this->pageStatus, $formattedPageStatus ) ) { + wfProfileOut( __METHOD__ ); throw new MWException( 'Not a valid page status!' ); } diff --git a/includes/WikiPage.php b/includes/WikiPage.php index e1e55fd69c..c016b18cf3 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1481,6 +1481,7 @@ class WikiPage implements Page, IDBAccessObject { $newContent = $sectionContent; } else { if ( !$this->supportsSections() ) { + wfProfileOut( __METHOD__ ); throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() ); } @@ -1746,6 +1747,7 @@ class WikiPage implements Page, IDBAccessObject { if ( $changed ) { if ( !$content->isValid() ) { + wfProfileOut( __METHOD__ ); throw new MWException( "New content failed validity check!" ); } diff --git a/includes/cache/LocalisationCache.php b/includes/cache/LocalisationCache.php index b3b0d4d755..d093b586e0 100644 --- a/includes/cache/LocalisationCache.php +++ b/includes/cache/LocalisationCache.php @@ -723,6 +723,7 @@ class LocalisationCache { wfProfileIn( __METHOD__ ); if ( !$code ) { + wfProfileOut( __METHOD__ ); throw new MWException( "Invalid language code requested" ); } $this->recachedLangs[$code] = true; @@ -852,6 +853,7 @@ class LocalisationCache { wfRunHooks( 'LocalisationCacheRecache', array( $this, $code, &$allData ) ); if ( is_null( $allData['namespaceNames'] ) ) { + wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . ': Localisation data failed sanity check! ' . 'Check that your languages/messages/MessagesEn.php file is intact.' ); } diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 6231a618dc..6cd167ca4b 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -369,8 +369,10 @@ class MessageCache { // effects like gadgets and sidebar getting cached with their // default content if ( $exception instanceof Exception ) { + wfProfileOut( __METHOD__ ); throw $exception; } else { + wfProfileOut( __METHOD__ ); throw new MWException( "MessageCache failed to load messages" ); } } else { diff --git a/includes/cache/SquidUpdate.php b/includes/cache/SquidUpdate.php index 69f0bf7e4c..5f5d25714f 100644 --- a/includes/cache/SquidUpdate.php +++ b/includes/cache/SquidUpdate.php @@ -190,6 +190,7 @@ class SquidUpdate { $urlArr = array_unique( $urlArr ); // Remove duplicates foreach ( $urlArr as $url ) { if( !is_string( $url ) ) { + wfProfileOut( __METHOD__ ); throw new MWException( 'Bad purge URL' ); } $url = SquidUpdate::expand( $url ); @@ -199,6 +200,7 @@ class SquidUpdate { continue; } if ( !isset( $conf['host'] ) || !isset( $conf['port'] ) ) { + wfProfileOut( __METHOD__ ); throw new MWException( "Invalid HTCP rule for URL $url\n" ); } diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index 8be4ebabaf..580ec75056 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -62,6 +62,7 @@ class WikitextContent extends TextContent { $sectionModelId = $with->getModel(); if ( $sectionModelId != $myModelId ) { + wfProfileOut( __METHOD__ ); throw new MWException( "Incompatible content model for section: " . "document uses $myModelId but " . "section uses $sectionModelId." ); diff --git a/includes/db/Database.php b/includes/db/Database.php index 7392f964cd..9db2ada392 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -945,6 +945,10 @@ abstract class DatabaseBase implements DatabaseType { } if ( istainted( $sql ) & TC_MYSQL ) { + if ( !Profiler::instance()->isStub() ) { + wfProfileOut( $queryProf ); + wfProfileOut( $totalProf ); + } throw new MWException( 'Tainted query found' ); } diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 0f7eb9eed9..d6f6809ca4 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -68,6 +68,7 @@ class DatabaseMysql extends DatabaseBase { # Fail now # Otherwise we get a suppressed fatal error, which is very hard to track down if ( !function_exists( 'mysql_connect' ) ) { + wfProfileOut( __METHOD__ ); throw new DBConnectionError( $this, "MySQL functions missing, have you compiled PHP with the --with-mysql option?\n" ); } diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 57d48f41a9..e2434a0329 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -219,6 +219,7 @@ class LoadBalancer { } if ( !$nonErrorLoads ) { + wfProfileOut( __METHOD__ ); throw new MWException( "Empty server array given to LoadBalancer" ); } @@ -443,8 +444,10 @@ class LoadBalancer { wfProfileIn( __METHOD__ ); if ( $i == DB_LAST ) { + wfProfileOut( __METHOD__ ); throw new MWException( 'Attempt to call ' . __METHOD__ . ' with deprecated server index DB_LAST' ); } elseif ( $i === null || $i === false ) { + wfProfileOut( __METHOD__ ); throw new MWException( 'Attempt to call ' . __METHOD__ . ' with invalid server index' ); } diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 1356ebe8f0..18a59fa420 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -1252,8 +1252,12 @@ abstract class FileBackendStore extends FileBackend { wfProfileIn( __METHOD__ . '-' . $this->name ); foreach ( $fileOpHandles as $fileOpHandle ) { if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) { + wfProfileOut( __METHOD__ . '-' . $this->name ); + wfProfileOut( __METHOD__ ); throw new MWException( "Given a non-FileBackendStoreOpHandle object." ); } elseif ( $fileOpHandle->backend->getName() !== $this->getName() ) { + wfProfileOut( __METHOD__ . '-' . $this->name ); + wfProfileOut( __METHOD__ ); throw new MWException( "Given a FileBackendStoreOpHandle for the wrong backend." ); } } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 6ff898e2ef..f8887cc349 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -382,6 +382,7 @@ class LocalFile extends File { $this->$name = $value; } } else { + wfProfileOut( $fname ); throw new MWException( "Could not find data for image '{$this->getName()}'." ); } diff --git a/includes/filerepo/file/OldLocalFile.php b/includes/filerepo/file/OldLocalFile.php index 5c505928a2..2e86ae15f6 100644 --- a/includes/filerepo/file/OldLocalFile.php +++ b/includes/filerepo/file/OldLocalFile.php @@ -218,6 +218,7 @@ class OldLocalFile extends LocalFile { $this->$name = $value; } } else { + wfProfileOut( __METHOD__ ); throw new MWException( "Could not find data for image '{$this->archive_name}'." ); } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 5b14ad21b9..611eb02a4b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1533,6 +1533,7 @@ class Parser { $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); if ( $bits === false ) { + wfProfileOut( __METHOD__ ); throw new MWException( "PCRE needs to be compiled with --enable-unicode-properties in order for MediaWiki to function" ); } $s = array_shift( $bits ); @@ -2606,6 +2607,7 @@ class Parser { } break; default: + wfProfileOut( __METHOD__ ); throw new MWException( "State machine error in " . __METHOD__ ); } } @@ -3245,6 +3247,7 @@ class Parser { $result = $this->callParserFunction( $frame, $func, $funcArgs ); } catch ( Exception $ex ) { wfProfileOut( __METHOD__ . '-pfunc' ); + wfProfileOut( __METHOD__ ); throw $ex; } diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 78ebbbb82d..7cb91da588 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -169,6 +169,10 @@ class Preprocessor_DOM implements Preprocessor { $this->parser->mGeneratedPPNodeCount += substr_count( $xml, '<' ); $max = $this->parser->mOptions->getMaxGeneratedPPNodeCount(); if ( $this->parser->mGeneratedPPNodeCount > $max ) { + if ( $cacheable ) { + wfProfileOut( __METHOD__ . '-cacheable' ); + } + wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . ': generated node count limit exceeded' ); } @@ -183,6 +187,11 @@ class Preprocessor_DOM implements Preprocessor { // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep $result = $dom->loadXML( $xml, 1 << 19 ); if ( !$result ) { + wfProfileOut( __METHOD__ . '-loadXML' ); + if ( $cacheable ) { + wfProfileOut( __METHOD__ . '-cacheable' ); + } + wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . ' generated invalid XML' ); } } diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 9f87ed73fb..469ce807d8 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -591,9 +591,19 @@ class Preprocessor_Hash implements Preprocessor { $lastNode = $node; } if ( !$node ) { + if ( $cacheable ) { + wfProfileOut( __METHOD__ . '-cache-miss' ); + wfProfileOut( __METHOD__ . '-cacheable' ); + } + wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . ': eqpos not found' ); } if ( $node->name !== 'equals' ) { + if ( $cacheable ) { + wfProfileOut( __METHOD__ . '-cache-miss' ); + wfProfileOut( __METHOD__ . '-cacheable' ); + } + wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . ': eqpos is not equals' ); } $equalsNode = $node; diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 14c75e9cab..9b02c6c86e 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -234,6 +234,7 @@ class ResourceLoader { foreach ( $registrations as $name => $info ) { // Disallow duplicate registrations if ( isset( $this->moduleInfos[$name] ) ) { + wfProfileOut( __METHOD__ ); // A module has already been registered by this name throw new MWException( 'ResourceLoader duplicate registration error. ' . @@ -243,6 +244,7 @@ class ResourceLoader { // Check $name for validity if ( !self::isValidModuleName( $name ) ) { + wfProfileOut( __METHOD__ ); throw new MWException( "ResourceLoader module name '$name' is invalid, see ResourceLoader::isValidModuleName()" ); } @@ -251,6 +253,7 @@ class ResourceLoader { // Old calling convention // Validate the input if ( !( $info instanceof ResourceLoaderModule ) ) { + wfProfileOut( __METHOD__ ); throw new MWException( 'ResourceLoader invalid module error. ' . 'Instances of ResourceLoaderModule expected.' ); } -- 2.20.1