Add missing wfProfileOut before throwing an exception
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 7 Apr 2013 16:34:58 +0000 (18:34 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 8 Apr 2013 18:37:24 +0000 (18:37 +0000)
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23

24 files changed:
includes/Block.php
includes/EditPage.php
includes/Export.php
includes/Hooks.php
includes/MagicWord.php
includes/Revision.php
includes/StreamFile.php
includes/StubObject.php
includes/UserMailer.php
includes/WikiPage.php
includes/cache/LocalisationCache.php
includes/cache/MessageCache.php
includes/cache/SquidUpdate.php
includes/content/WikitextContent.php
includes/db/Database.php
includes/db/DatabaseMysql.php
includes/db/LoadBalancer.php
includes/filebackend/FileBackendStore.php
includes/filerepo/file/LocalFile.php
includes/filerepo/file/OldLocalFile.php
includes/parser/Parser.php
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
includes/resourceloader/ResourceLoader.php

index 568f4b0..4da0f8f 100644 (file)
@@ -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." );
                }
 
index f88dc90..96a57b4 100644 (file)
@@ -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' );
                }
 
index 085662a..996c14b 100644 (file)
@@ -296,6 +296,7 @@ class WikiExporter {
                                }
 
                                // Inform caller about problem
+                               wfProfileOut( __METHOD__ );
                                throw $e;
                        }
                # For page dumps...
index e3ffb19..740abf7 100644 (file)
@@ -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; " .
index 7b66924..41c7cb9 100644 (file)
@@ -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" );
                }
index 18cd94e..3ea5da4 100644 (file)
@@ -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!" );
                        }
 
index f5e4acf..1ad643a 100644 (file)
@@ -42,6 +42,7 @@ class StreamFile {
                wfProfileIn( __METHOD__ );
 
                if ( FileBackend::isStoragePath( $fname ) ) { // sanity
+                       wfProfileOut( __METHOD__ );
                        throw new MWException( __FUNCTION__ . " given storage path '$fname'." );
                }
 
index f0a3574..5b26d45 100644 (file)
@@ -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" );
index c5dcfc3..2eb8429 100644 (file)
@@ -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!' );
                }
 
index e1e55fd..c016b18 100644 (file)
@@ -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!" );
                                }
 
index b3b0d4d..d093b58 100644 (file)
@@ -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.' );
                }
index 6231a61..6cd167c 100644 (file)
@@ -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 {
index 69f0bf7..5f5d257 100644 (file)
@@ -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" );
                                }
 
index 8be4eba..580ec75 100644 (file)
@@ -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." );
index 7392f96..9db2ada 100644 (file)
@@ -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' );
                }
 
index 0f7eb9e..d6f6809 100644 (file)
@@ -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" );
                }
 
index 57d48f4..e2434a0 100644 (file)
@@ -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' );
                }
 
index 1356ebe..18a59fa 100644 (file)
@@ -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." );
                        }
                }
index 6ff898e..f8887cc 100644 (file)
@@ -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()}'." );
                }
 
index 5c50592..2e86ae1 100644 (file)
@@ -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}'." );
                }
 
index 5b14ad2..611eb02 100644 (file)
@@ -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;
                                }
 
index 78ebbbb..7cb91da 100644 (file)
@@ -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' );
                        }
                }
index 9f87ed7..469ce80 100644 (file)
@@ -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;
index 14c75e9..9b02c6c 100644 (file)
@@ -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.' );
                                }