From a14da4533692780e421781129a3c1005cdb023d3 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 24 Oct 2010 19:16:46 +0000 Subject: [PATCH] * If a action=parse request provides an oldid that is actually the current revision id, try the parser cache, and save it to it if necessary --- RELEASE-NOTES | 2 ++ includes/api/ApiParse.php | 31 ++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c8e82098e8..a48505045f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -444,6 +444,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added iiprop=parsedcomment to prop=imageinfo, similar to prop=revisions * Added rvparse to parse revisions. For performance reasons if this option is used, rvlimit is enforced to 1. +* If a action=parse request provides an oldid that is actually the current revision + id, try the parser cache, and save it to it if necessary === Languages updated in 1.17 === diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index c487ca855f..de3b371e80 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -89,15 +89,36 @@ class ApiParse extends ApiBase { $this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' ); } - $text = $rev->getText( Revision::FOR_THIS_USER ); $titleObj = $rev->getTitle(); + $wgTitle = $titleObj; - if ( $this->section !== false ) { - $text = $this->getSectionText( $text, 'r' . $rev ); - } + //If for some reason the "oldid" is actually the current revision, it may be cached + if ( $titleObj->getLatestRevID() === $oldid ) { + $p_result = false; + $pcache = ParserCache::singleton(); + if ( $wgEnableParserCache ) { + $p_result = $pcache->get( $titleObj, $popts ); + } + if ( !$p_result ) { + $text = $rev->getText( Revision::FOR_THIS_USER ); + $p_result = $wgParser->parse( $text, $titleObj, $popts ); + + if ( $wgEnableParserCache ) { + $pcache->save( $p_result, $titleObj, $popts ); + } + } + } else { + $text = $rev->getText( Revision::FOR_THIS_USER ); + + $wgTitle = $titleObj; - $p_result = $wgParser->parse( $text, $titleObj, $popts ); + if ( $this->section !== false ) { + $text = $this->getSectionText( $text, 'r' . $rev ); + } + + $p_result = $wgParser->parse( $text, $titleObj, $popts ); + } } else { if ( !is_null ( $pageid ) ) { $titleObj = Title::newFromID( $pageid ); -- 2.20.1