->params( $this->getLanguage()->listToText( $missing ) )
->numParams( count( $missing ) )
->parseAsBlock();
- $out->addHtml( $msg );
+ $out->addHTML( $msg );
}
public function showDiffPage( $diffOnly = false ) {
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
# Page content may be handled by a hooked call instead...
# @codingStandardsIgnoreStart Ignoring long lines.
- if ( Hooks::run( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
+ if ( Hooks::run( 'ArticleContentOnDiff', [ $this, $out ] ) ) {
$this->loadNewText();
$out->setRevisionId( $this->mNewid );
$out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
// This needs to be synchronised with Article::showCssOrJsPage(), which sucks
// Give hooks a chance to customise the output
// @todo standardize this crap into one function
- if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+ if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', [ $this->mNewContent, $this->mNewPage, $out ] ) ) {
// NOTE: deprecated hook, B/C only
// use the content object's own rendering
$cnt = $this->mNewRev->getContent();
$out->addParserOutputContent( $po );
}
}
- } elseif ( !Hooks::run( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+ } elseif ( !Hooks::run( 'ArticleContentViewCustom', [ $this->mNewContent, $this->mNewPage, $out ] ) ) {
// Handled by extension
- } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+ } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', [ $this->mNewContent, $this->mNewPage, $out ] ) ) {
// NOTE: deprecated hook, B/C only
// Handled by extension
} else {
}
// Short-circuit
if ( $this->mOldRev === false || ( $this->mOldRev && $this->mNewRev
- && $this->mOldRev->getID() == $this->mNewRev->getID() )
+ && $this->mOldRev->getId() == $this->mNewRev->getId() )
) {
return '';
}
* @return bool|string
*/
public function generateTextDiffBody( $otext, $ntext ) {
+ $time = microtime( true );
+
+ $result = $this->textDiff( $otext, $ntext );
+
+ $time = intval( ( microtime( true ) - $time ) * 1000 );
+ $this->getStats()->timing( 'diff_time', $time );
+ // Log requests slower than 99th percentile
+ if ( $time > 100 && $this->mOldPage && $this->mNewPage ) {
+ wfDebugLog( 'diff',
+ "$time ms diff: {$this->mOldid} -> {$this->mNewid} {$this->mNewPage}" );
+ }
+
+ return $result;
+ }
+
+ /**
+ * Generates diff, to be wrapped internally in a logging/instrumentation
+ *
+ * @param string $otext Old text, must be already segmented
+ * @param string $ntext New text, must be already segmented
+ * @return bool|string
+ */
+ protected function textDiff( $otext, $ntext ) {
global $wgExternalDiffEngine, $wgContLang;
$otext = str_replace( "\r\n", "\n", $otext );
$ntext = str_replace( "\r\n", "\n", $ntext );
- if ( $wgExternalDiffEngine == 'wikidiff' && function_exists( 'wikidiff_do_diff' ) ) {
- # For historical reasons, external diff engine expects
- # input text to be HTML-escaped already
- $otext = htmlspecialchars( $wgContLang->segmentForDiff( $otext ) );
- $ntext = htmlspecialchars( $wgContLang->segmentForDiff( $ntext ) );
-
- return $wgContLang->unsegmentForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) ) .
- $this->debug( 'wikidiff1' );
+ if ( $wgExternalDiffEngine == 'wikidiff' ) {
+ wfDeprecated( 'wikidiff support', '1.27' );
+ $wgExternalDiffEngine = false;
}
- 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
- $text = wikidiff2_do_diff( $otext, $ntext, 2 );
- $text .= $this->debug( 'wikidiff2' );
+ if ( $wgExternalDiffEngine == 'wikidiff2' ) {
+ if ( function_exists( 'wikidiff2_do_diff' ) ) {
+ # Better external diff engine, the 2 may some day be dropped
+ # This one does the escaping and segmenting itself
+ $text = wikidiff2_do_diff( $otext, $ntext, 2 );
+ $text .= $this->debug( 'wikidiff2' );
- return $text;
- }
- if ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) {
+ return $text;
+ }
+ } elseif ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) {
# Diff via the shell
$tmpDir = wfTempDir();
$tempName1 = tempnam( $tmpDir, 'diff_' );
$title = $rev->getTitle();
$header = Linker::linkKnown( $title, $header, [],
- [ 'oldid' => $rev->getID() ] );
+ [ 'oldid' => $rev->getId() ] );
if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
$editQuery = [ 'action' => 'edit' ];
if ( !$rev->isCurrent() ) {
- $editQuery['oldid'] = $rev->getID();
+ $editQuery['oldid'] = $rev->getId();
}
$key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';