From: Alexandre Emsenhuber Date: Wed, 14 Mar 2012 09:52:34 +0000 (+0000) Subject: Don't create new Revision and Title object if we can use the ones that we already... X-Git-Tag: 1.31.0-rc.0~24261 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=0d6b594bf22f29ca130b148bc9cb771ff9958e41;p=lhc%2Fweb%2Fwiklou.git Don't create new Revision and Title object if we can use the ones that we already have --- diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index a4d0c65602..39e555e6fe 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -1003,17 +1003,23 @@ class DifferenceEngine extends ContextSource { $this->loadRevisionIds(); // Load the new revision object - $this->mNewRev = $this->mNewid - ? Revision::newFromId( $this->mNewid ) - : Revision::newFromTitle( $this->getTitle() ); + if ( $this->mNewid && ( !$this->canUseWikiPage() + || $this->mNewid !== $this->getWikiPage()->getLatest() ) ) + { + $this->mNewRev = Revision::newFromId( $this->mNewid ); + } else { + $this->mNewRev = $this->getWikiPage()->getRevision(); + $this->mNewPage = $this->getTitle(); + } if ( !$this->mNewRev instanceof Revision ) { return false; } - + if ( !$this->mNewPage instanceof Title ) { + $this->mNewPage = $this->mNewRev->getTitle(); + } // Update the new revision ID in case it was 0 (makes life easier doing UI stuff) $this->mNewid = $this->mNewRev->getId(); - $this->mNewPage = $this->mNewRev->getTitle(); // Load the old revision object $this->mOldRev = false;