Removed remaining profile calls
[lhc/web/wiklou.git] / includes / diff / DifferenceEngine.php
index dd5f3c7..90a2785 100644 (file)
@@ -232,7 +232,6 @@ class DifferenceEngine extends ContextSource {
        }
 
        public function showDiffPage( $diffOnly = false ) {
-               wfProfileIn( __METHOD__ );
 
                # Allow frames except in certain special cases
                $out = $this->getOutput();
@@ -241,7 +240,6 @@ class DifferenceEngine extends ContextSource {
 
                if ( !$this->loadRevisionData() ) {
                        $this->showMissingRevision();
-                       wfProfileOut( __METHOD__ );
 
                        return;
                }
@@ -253,7 +251,6 @@ class DifferenceEngine extends ContextSource {
                                $this->mOldPage->getUserPermissionsErrors( 'read', $user ) );
                }
                if ( count( $permErrors ) ) {
-                       wfProfileOut( __METHOD__ );
                        throw new PermissionsError( 'read', $permErrors );
                }
 
@@ -283,7 +280,7 @@ class DifferenceEngine extends ContextSource {
                        $samePage = true;
                        $oldHeader = '';
                } else {
-                       wfRunHooks( 'DiffViewHeader', array( $this, $this->mOldRev, $this->mNewRev ) );
+                       Hooks::run( 'DiffViewHeader', array( $this, $this->mOldRev, $this->mNewRev ) );
 
                        if ( $this->mNewPage->equals( $this->mOldPage ) ) {
                                $out->setPageTitle( $this->msg( 'difference-title', $this->mNewPage->getPrefixedText() ) );
@@ -387,7 +384,7 @@ class DifferenceEngine extends ContextSource {
                $rdel = $this->revisionDeleteLink( $this->mNewRev );
 
                # Allow extensions to define their own revision tools
-               wfRunHooks( 'DiffRevisionTools', array( $this->mNewRev, &$revisionTools, $this->mOldRev ) );
+               Hooks::run( 'DiffRevisionTools', array( $this->mNewRev, &$revisionTools, $this->mOldRev ) );
                $formattedRevisionTools = array();
                // Put each one in parentheses (poor man's button)
                foreach ( $revisionTools as $key => $tool ) {
@@ -454,7 +451,6 @@ class DifferenceEngine extends ContextSource {
                                $this->renderNewRevision();
                        }
                }
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -547,7 +543,6 @@ class DifferenceEngine extends ContextSource {
         * Show the new revision of the page.
         */
        public function renderNewRevision() {
-               wfProfileIn( __METHOD__ );
                $out = $this->getOutput();
                $revHeader = $this->getRevisionHeader( $this->mNewRev );
                # Add "current version as of X" title
@@ -555,7 +550,7 @@ class DifferenceEngine extends ContextSource {
                <h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
                # Page content may be handled by a hooked call instead...
                # @codingStandardsIgnoreStart Ignoring long lines.
-               if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
+               if ( Hooks::run( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
                        $this->loadNewText();
                        $out->setRevisionId( $this->mNewid );
                        $out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
@@ -575,7 +570,7 @@ class DifferenceEngine extends ContextSource {
                                                $out->addParserOutputContent( $po );
                                        }
                                }
-                       } elseif ( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+                       } elseif ( !Hooks::run( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // Handled by extension
                        } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // NOTE: deprecated hook, B/C only
@@ -605,7 +600,6 @@ class DifferenceEngine extends ContextSource {
                # Add redundant patrol link on bottom...
                $out->addHTML( $this->markPatrolledLink() );
 
-               wfProfileOut( __METHOD__ );
        }
 
        protected function getParserOutput( WikiPage $page, Revision $rev ) {
@@ -684,23 +678,19 @@ class DifferenceEngine extends ContextSource {
         */
        public function getDiffBody() {
                global $wgMemc;
-               wfProfileIn( __METHOD__ );
                $this->mCacheHit = true;
                // Check if the diff should be hidden from this user
                if ( !$this->loadRevisionData() ) {
-                       wfProfileOut( __METHOD__ );
 
                        return false;
                } elseif ( $this->mOldRev &&
                        !$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
                ) {
-                       wfProfileOut( __METHOD__ );
 
                        return false;
                } elseif ( $this->mNewRev &&
                        !$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
                ) {
-                       wfProfileOut( __METHOD__ );
 
                        return false;
                }
@@ -708,7 +698,6 @@ class DifferenceEngine extends ContextSource {
                if ( $this->mOldRev === false || ( $this->mOldRev && $this->mNewRev
                        && $this->mOldRev->getID() == $this->mNewRev->getID() )
                ) {
-                       wfProfileOut( __METHOD__ );
 
                        return '';
                }
@@ -724,7 +713,6 @@ class DifferenceEngine extends ContextSource {
                                        wfIncrStats( 'diff_cache_hit' );
                                        $difftext = $this->localiseLineNumbers( $difftext );
                                        $difftext .= "\n<!-- diff cache key $key -->\n";
-                                       wfProfileOut( __METHOD__ );
 
                                        return $difftext;
                                }
@@ -734,7 +722,6 @@ class DifferenceEngine extends ContextSource {
 
                // Loadtext is permission safe, this just clears out the diff
                if ( !$this->loadText() ) {
-                       wfProfileOut( __METHOD__ );
 
                        return false;
                }
@@ -742,7 +729,7 @@ class DifferenceEngine extends ContextSource {
                $difftext = $this->generateContentDiffBody( $this->mOldContent, $this->mNewContent );
 
                // Save to cache for 7 days
-               if ( !wfRunHooks( 'AbortDiffCache', array( &$this ) ) ) {
+               if ( !Hooks::run( 'AbortDiffCache', array( &$this ) ) ) {
                        wfIncrStats( 'diff_uncacheable' );
                } elseif ( $key !== false && $difftext !== false ) {
                        wfIncrStats( 'diff_cache_miss' );
@@ -754,7 +741,6 @@ class DifferenceEngine extends ContextSource {
                if ( $difftext !== false ) {
                        $difftext = $this->localiseLineNumbers( $difftext );
                }
-               wfProfileOut( __METHOD__ );
 
                return $difftext;
        }
@@ -840,8 +826,6 @@ class DifferenceEngine extends ContextSource {
        public function generateTextDiffBody( $otext, $ntext ) {
                global $wgExternalDiffEngine, $wgContLang;
 
-               wfProfileIn( __METHOD__ );
-
                $otext = str_replace( "\r\n", "\n", $otext );
                $ntext = str_replace( "\r\n", "\n", $ntext );
 
@@ -850,7 +834,6 @@ class DifferenceEngine extends ContextSource {
                        # input text to be HTML-escaped already
                        $otext = htmlspecialchars( $wgContLang->segmentForDiff( $otext ) );
                        $ntext = htmlspecialchars( $wgContLang->segmentForDiff( $ntext ) );
-                       wfProfileOut( __METHOD__ );
 
                        return $wgContLang->unsegmentForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) ) .
                        $this->debug( 'wikidiff1' );
@@ -859,11 +842,8 @@ class DifferenceEngine extends ContextSource {
                if ( $wgExternalDiffEngine == 'wikidiff2' && function_exists( 'wikidiff2_do_diff' ) ) {
                        # Better external diff engine, the 2 may some day be dropped
                        # This one does the escaping and segmenting itself
-                       wfProfileIn( 'wikidiff2_do_diff' );
                        $text = wikidiff2_do_diff( $otext, $ntext, 2 );
                        $text .= $this->debug( 'wikidiff2' );
-                       wfProfileOut( 'wikidiff2_do_diff' );
-                       wfProfileOut( __METHOD__ );
 
                        return $text;
                }
@@ -875,13 +855,11 @@ class DifferenceEngine extends ContextSource {
 
                        $tempFile1 = fopen( $tempName1, "w" );
                        if ( !$tempFile1 ) {
-                               wfProfileOut( __METHOD__ );
 
                                return false;
                        }
                        $tempFile2 = fopen( $tempName2, "w" );
                        if ( !$tempFile2 ) {
-                               wfProfileOut( __METHOD__ );
 
                                return false;
                        }
@@ -890,13 +868,10 @@ class DifferenceEngine extends ContextSource {
                        fclose( $tempFile1 );
                        fclose( $tempFile2 );
                        $cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 );
-                       wfProfileIn( __METHOD__ . "-shellexec" );
                        $difftext = wfShellExec( $cmd );
                        $difftext .= $this->debug( "external $wgExternalDiffEngine" );
-                       wfProfileOut( __METHOD__ . "-shellexec" );
                        unlink( $tempName1 );
                        unlink( $tempName2 );
-                       wfProfileOut( __METHOD__ );
 
                        return $difftext;
                }
@@ -906,8 +881,7 @@ class DifferenceEngine extends ContextSource {
                $nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
                $diffs = new Diff( $ota, $nta );
                $formatter = new TableDiffFormatter();
-               $difftext = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) ) .
-                       wfProfileOut( __METHOD__ );
+               $difftext = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) );
 
                return $difftext;
        }
@@ -1062,7 +1036,7 @@ class DifferenceEngine extends ContextSource {
                        $key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';
                        $msg = $this->msg( $key )->escaped();
                        $editLink = $this->msg( 'parentheses' )->rawParams(
-                               Linker::linkKnown( $title, $msg, array( ), $editQuery ) )->plain();
+                               Linker::linkKnown( $title, $msg, array( ), $editQuery ) )->escaped();
                        $header .= ' ' . Html::rawElement(
                                'span',
                                array( 'class' => 'mw-diff-edit' ),
@@ -1224,7 +1198,7 @@ class DifferenceEngine extends ContextSource {
                        $this->mNewid = 0;
                }
 
-               wfRunHooks(
+               Hooks::run(
                        'NewDifferenceEngine',
                        array( $this->getTitle(), &$this->mOldid, &$this->mNewid, $old, $new )
                );