From: Sam Reed Date: Sun, 24 Oct 2010 19:16:46 +0000 (+0000) Subject: * If a action=parse request provides an oldid that is actually the current revision... X-Git-Tag: 1.31.0-rc.0~34333 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=a14da4533692780e421781129a3c1005cdb023d3;p=lhc%2Fweb%2Fwiklou.git * 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 --- 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 );