Removed remaining profile calls
[lhc/web/wiklou.git] / includes / EditPage.php
index 7f5a9c0..8e433e4 100644 (file)
@@ -467,13 +467,11 @@ class EditPage {
                        return;
                }
 
-               wfProfileIn( __METHOD__ );
                wfDebug( __METHOD__ . ": enter\n" );
 
                // If they used redlink=1 and the page exists, redirect to the main article
                if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
                        $wgOut->redirect( $this->mTitle->getFullURL() );
-                       wfProfileOut( __METHOD__ );
                        return;
                }
 
@@ -482,7 +480,6 @@ class EditPage {
 
                if ( $this->live ) {
                        $this->livePreview();
-                       wfProfileOut( __METHOD__ );
                        return;
                }
 
@@ -515,11 +512,9 @@ class EditPage {
 
                        $this->displayPermissionsError( $permErrors );
 
-                       wfProfileOut( __METHOD__ );
                        return;
                }
 
-               wfProfileIn( __METHOD__ . "-business-end" );
 
                $this->isConflict = false;
                // css / js subpages of user pages get a special treatment
@@ -541,8 +536,6 @@ class EditPage {
 
                if ( 'save' == $this->formtype ) {
                        if ( !$this->attemptSave() ) {
-                               wfProfileOut( __METHOD__ . "-business-end" );
-                               wfProfileOut( __METHOD__ );
                                return;
                        }
                }
@@ -552,8 +545,6 @@ class EditPage {
                if ( 'initial' == $this->formtype || $this->firsttime ) {
                        if ( $this->initialiseForm() === false ) {
                                $this->noSuchSectionPage();
-                               wfProfileOut( __METHOD__ . "-business-end" );
-                               wfProfileOut( __METHOD__ );
                                return;
                        }
 
@@ -566,8 +557,6 @@ class EditPage {
                }
 
                $this->showEditForm();
-               wfProfileOut( __METHOD__ . "-business-end" );
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -732,13 +721,11 @@ class EditPage {
        function importFormData( &$request ) {
                global $wgContLang, $wgUser;
 
-               wfProfileIn( __METHOD__ );
 
                # Section edit can come from either the form or a link
                $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' );
                }
 
@@ -753,13 +740,10 @@ class EditPage {
                                // Skip this if wpTextbox2 has input, it indicates that we came
                                // from a conflict page with raw page text, not a custom form
                                // modified by subclasses
-                               wfProfileIn( get_class( $this ) . "::importContentFormData" );
                                $textbox1 = $this->importContentFormData( $request );
                                if ( $textbox1 !== null ) {
                                        $this->textbox1 = $textbox1;
                                }
-
-                               wfProfileOut( get_class( $this ) . "::importContentFormData" );
                        }
 
                        # Truncate for whole multibyte characters
@@ -931,7 +915,6 @@ class EditPage {
                // Allow extensions to modify form data
                Hooks::run( 'EditPage::importFormData', array( $this, $request ) );
 
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -992,7 +975,6 @@ class EditPage {
        protected function getContentObject( $def_content = null ) {
                global $wgOut, $wgRequest, $wgUser, $wgContLang;
 
-               wfProfileIn( __METHOD__ );
 
                $content = false;
 
@@ -1105,7 +1087,6 @@ class EditPage {
                        }
                }
 
-               wfProfileOut( __METHOD__ );
                return $content;
        }
 
@@ -1538,15 +1519,11 @@ class EditPage {
 
                $status = Status::newGood();
 
-               wfProfileIn( __METHOD__ );
-               wfProfileIn( __METHOD__ . '-checks' );
 
                if ( !Hooks::run( 'EditPage::attemptSave', array( $this ) ) ) {
                        wfDebug( "Hook 'EditPage::attemptSave' aborted article saving\n" );
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
@@ -1563,8 +1540,6 @@ class EditPage {
                        );
                        $status->fatal( 'spamprotectionmatch', false );
                        $status->value = self::AS_SPAM_ERROR;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
@@ -1579,8 +1554,6 @@ class EditPage {
                                $ex->getMessage()
                        );
                        $status->value = self::AS_PARSE_ERROR;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
@@ -1592,8 +1565,6 @@ class EditPage {
                                $code = $wgUser->isAnon() ? self::AS_IMAGE_REDIRECT_ANON : self::AS_IMAGE_REDIRECT_LOGGED;
                                $status->setResult( false, $code );
 
-                               wfProfileOut( __METHOD__ . '-checks' );
-                               wfProfileOut( __METHOD__ );
 
                                return $status;
                }
@@ -1623,8 +1594,6 @@ class EditPage {
                        wfDebugLog( 'SpamRegex', "$ip spam regex hit [[$pdbk]]: \"$match\"" );
                        $status->fatal( 'spamprotectionmatch', $match );
                        $status->value = self::AS_SPAM_ERROR;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
                if ( !Hooks::run(
@@ -1634,15 +1603,11 @@ class EditPage {
                        # Error messages etc. could be handled within the hook...
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                } elseif ( $this->hookError != '' ) {
                        # ...or the hook could be expecting us to produce an error
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR_EXPECTED;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
@@ -1651,8 +1616,6 @@ class EditPage {
                        $wgUser->spreadAnyEditBlock();
                        # Check block state against master, thus 'false'.
                        $status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
@@ -1661,22 +1624,16 @@ class EditPage {
                        // Error will be displayed by showEditForm()
                        $this->tooBig = true;
                        $status->setResult( false, self::AS_CONTENT_TOO_BIG );
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
                if ( !$wgUser->isAllowed( 'edit' ) ) {
                        if ( $wgUser->isAnon() ) {
                                $status->setResult( false, self::AS_READ_ONLY_PAGE_ANON );
-                               wfProfileOut( __METHOD__ . '-checks' );
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        } else {
                                $status->fatal( 'readonlytext' );
                                $status->value = self::AS_READ_ONLY_PAGE_LOGGED;
-                               wfProfileOut( __METHOD__ . '-checks' );
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
                }
@@ -1685,23 +1642,17 @@ class EditPage {
                        && !$wgUser->isAllowed( 'editcontentmodel' )
                ) {
                        $status->setResult( false, self::AS_NO_CHANGE_CONTENT_MODEL );
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
                if ( wfReadOnly() ) {
                        $status->fatal( 'readonlytext' );
                        $status->value = self::AS_READ_ONLY_PAGE;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
                if ( $wgUser->pingLimiter() || $wgUser->pingLimiter( 'linkpurge', 0 ) ) {
                        $status->fatal( 'actionthrottledtext' );
                        $status->value = self::AS_RATE_LIMITED;
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
@@ -1709,12 +1660,9 @@ class EditPage {
                # confirmation
                if ( $this->wasDeletedSinceLastEdit() && !$this->recreate ) {
                        $status->setResult( false, self::AS_ARTICLE_WAS_DELETED );
-                       wfProfileOut( __METHOD__ . '-checks' );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
-               wfProfileOut( __METHOD__ . '-checks' );
 
                # Load the page data from the master. If anything changes in the meantime,
                # we detect it by using page_latest like a token in a 1 try compare-and-swap.
@@ -1727,7 +1675,6 @@ class EditPage {
                                $status->fatal( 'nocreatetext' );
                                $status->value = self::AS_NO_CREATE_PERMISSION;
                                wfDebug( __METHOD__ . ": no create permission\n" );
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
 
@@ -1745,12 +1692,10 @@ class EditPage {
                                $this->blankArticle = true;
                                $status->fatal( 'blankarticle' );
                                $status->setResult( false, self::AS_BLANK_ARTICLE );
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
 
                        if ( !$this->runPostMergeFilters( $textbox_content, $status, $wgUser ) ) {
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
 
@@ -1855,12 +1800,10 @@ class EditPage {
 
                        if ( $this->isConflict ) {
                                $status->setResult( false, self::AS_CONFLICT_DETECTED );
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
 
                        if ( !$this->runPostMergeFilters( $content, $status, $wgUser ) ) {
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
 
@@ -1870,7 +1813,6 @@ class EditPage {
                                        $this->missingSummary = true;
                                        $status->fatal( 'missingsummary' ); // or 'missingcommentheader' if $section == 'new'. Blegh
                                        $status->value = self::AS_SUMMARY_NEEDED;
-                                       wfProfileOut( __METHOD__ );
                                        return $status;
                                }
 
@@ -1879,7 +1821,6 @@ class EditPage {
                                        $this->missingComment = true;
                                        $status->fatal( 'missingcommenttext' );
                                        $status->value = self::AS_TEXTBOX_EMPTY;
-                                       wfProfileOut( __METHOD__ );
                                        return $status;
                                }
                        } elseif ( !$this->allowBlankSummary
@@ -1890,12 +1831,10 @@ class EditPage {
                                $this->missingSummary = true;
                                $status->fatal( 'missingsummary' );
                                $status->value = self::AS_SUMMARY_NEEDED;
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
 
                        # All's well
-                       wfProfileIn( __METHOD__ . '-sectionanchor' );
                        $sectionanchor = '';
                        if ( $this->section == 'new' ) {
                                $this->summary = $this->newSectionSummary( $sectionanchor );
@@ -1912,7 +1851,6 @@ class EditPage {
                                }
                        }
                        $result['sectionanchor'] = $sectionanchor;
-                       wfProfileOut( __METHOD__ . '-sectionanchor' );
 
                        // Save errors may fall down to the edit form, but we've now
                        // merged the section into full text. Clear the section field
@@ -1934,7 +1872,6 @@ class EditPage {
                                $this->selfRedirect = true;
                                $status->fatal( 'selfredirect' );
                                $status->value = self::AS_SELF_REDIRECT;
-                               wfProfileOut( __METHOD__ );
                                return $status;
                        }
                }
@@ -1944,7 +1881,6 @@ class EditPage {
                if ( $this->kblength > $wgMaxArticleSize ) {
                        $this->tooBig = true;
                        $status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED );
-                       wfProfileOut( __METHOD__ );
                        return $status;
                }
 
@@ -1974,7 +1910,6 @@ class EditPage {
                                // Destroys data doEdit() put in $status->value but who cares
                                $doEditStatus->value = self::AS_END;
                        }
-                       wfProfileOut( __METHOD__ );
                        return $doEditStatus;
                }
 
@@ -1985,7 +1920,6 @@ class EditPage {
                }
                $result['redirect'] = $content->isRedirect();
                $this->updateWatchlist();
-               wfProfileOut( __METHOD__ );
                return $status;
        }
 
@@ -2022,7 +1956,6 @@ class EditPage {
         * @return bool
         */
        private function mergeChangesIntoContent( &$editContent ) {
-               wfProfileIn( __METHOD__ );
 
                $db = wfGetDB( DB_MASTER );
 
@@ -2031,7 +1964,6 @@ class EditPage {
                $baseContent = $baseRevision ? $baseRevision->getContent() : null;
 
                if ( is_null( $baseContent ) ) {
-                       wfProfileOut( __METHOD__ );
                        return false;
                }
 
@@ -2040,7 +1972,6 @@ class EditPage {
                $currentContent = $currentRevision ? $currentRevision->getContent() : null;
 
                if ( is_null( $currentContent ) ) {
-                       wfProfileOut( __METHOD__ );
                        return false;
                }
 
@@ -2050,11 +1981,9 @@ class EditPage {
 
                if ( $result ) {
                        $editContent = $result;
-                       wfProfileOut( __METHOD__ );
                        return true;
                }
 
-               wfProfileOut( __METHOD__ );
                return false;
        }
 
@@ -2373,7 +2302,6 @@ class EditPage {
        function showEditForm( $formCallback = null ) {
                global $wgOut, $wgUser;
 
-               wfProfileIn( __METHOD__ );
 
                # need to parse the preview early so that we know which templates are used,
                # otherwise users with "show preview after edit box" will get a blank list
@@ -2389,7 +2317,6 @@ class EditPage {
                $this->setHeaders();
 
                if ( $this->showHeader() === false ) {
-                       wfProfileOut( __METHOD__ );
                        return;
                }
 
@@ -2593,7 +2520,6 @@ class EditPage {
                        $this->displayPreviewArea( $previewOutput, false );
                }
 
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -3250,7 +3176,6 @@ HTML
                        return '';
                }
 
-               wfProfileIn( __METHOD__ );
 
                $limitReport = Html::rawElement( 'div', array( 'class' => 'mw-limitReportExplanation' ),
                        wfMessage( 'limitreport-title' )->parseAsBlock()
@@ -3286,7 +3211,6 @@ HTML
                        Html::closeElement( 'table' ) .
                        Html::closeElement( 'div' );
 
-               wfProfileOut( __METHOD__ );
 
                return $limitReport;
        }
@@ -3473,7 +3397,6 @@ HTML
                global $wgOut, $wgUser, $wgRawHtml, $wgLang;
                global $wgAllowUserCss, $wgAllowUserJs;
 
-               wfProfileIn( __METHOD__ );
 
                if ( $wgRawHtml && !$this->mTokenOk ) {
                        // Could be an offsite preview attempt. This is very unsafe if
@@ -3486,7 +3409,6 @@ HTML
                                $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
                                        wfMessage( 'session_fail_preview_html' )->text() . "</div>", true, /* interface */true );
                        }
-                       wfProfileOut( __METHOD__ );
                        return $parsedNote;
                }
 
@@ -3500,7 +3422,6 @@ HTML
                                'AlternateEditPreview',
                                array( $this, &$content, &$previewHTML, &$this->mParserOutput ) )
                        ) {
-                               wfProfileOut( __METHOD__ );
                                return $previewHTML;
                        }
 
@@ -3573,6 +3494,8 @@ HTML
                        # But it's now deprecated, so never mind
 
                        $pstContent = $content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
+                       $scopedCallback = $parserOptions->setupFakeRevision(
+                               $this->mTitle, $pstContent, $wgUser );
                        $parserOutput = $pstContent->getParserOutput( $this->mTitle, null, $parserOptions );
 
                        # Try to stash the edit for the final submission step
@@ -3617,7 +3540,6 @@ HTML
                        'class' => 'mw-content-' . $pageViewLang->getDir() );
                $previewHTML = Html::rawElement( 'div', $attribs, $previewHTML );
 
-               wfProfileOut( __METHOD__ );
                return $previewhead . $previewHTML . $this->previewTextAfterContent;
        }