From 4ef1cc76ecc2887323d34bc6b717bd04c6670f1f Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 15 Jan 2012 22:00:04 +0000 Subject: [PATCH] Use the context's WikiPage object if the title of the new revision is the same as context's title; avoids a duplicated database query to load the WikiPage --- includes/diff/DifferenceEngine.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index f645d3b538..439e3204ec 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -502,7 +502,15 @@ class DifferenceEngine extends ContextSource { // Handled by extension } else { // Normal page - $wikiPage = WikiPage::factory( $this->mNewPage ); + if ( $this->getTitle()->equals( $this->mNewPage ) ) { + // If the Title stored in the context is the same as the one + // of the new revision, we can use its associated WikiPage + // object. + $wikiPage = $this->getWikiPage(); + } else { + // Otherwise we need to create our own WikiPage object + $wikiPage = WikiPage::factory( $this->mNewPage ); + } $parserOptions = ParserOptions::newFromContext( $this->getContext() ); $parserOptions->enableLimitReport(); -- 2.20.1