From 286d7be039d0711289bac7f0743cb67b91a4e174 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 26 Dec 2011 15:54:10 +0000 Subject: [PATCH] In EditPage::showDiff(): * Group global declarations * Only get 'currentrev' and 'yourtext' messages if needed --- includes/EditPage.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 8358cc56bc..a443f6dd17 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2163,7 +2163,7 @@ HTML * save and then make a comparison. */ function showDiff() { - global $wgUser, $wgContLang, $wgParser; + global $wgUser, $wgContLang, $wgParser, $wgOut; if ( $this->section == 'new' ) { $oldtext = $this->mArticle->getRawText(); @@ -2177,9 +2177,11 @@ HTML $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); $newtext = $wgParser->preSaveTransform( $newtext, $this->mTitle, $wgUser, $popts ); - $oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) ); - $newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) ); + if ( $oldtext !== false || $newtext != '' ) { + $oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) ); + $newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) ); + $de = new DifferenceEngine( $this->mArticle->getContext() ); $de->setText( $oldtext, $newtext ); $difftext = $de->getDiff( $oldtitle, $newtitle ); @@ -2188,7 +2190,6 @@ HTML $difftext = ''; } - global $wgOut; $wgOut->addHTML( '
' . $difftext . '
' ); } -- 2.20.1