From: Sam Reed Date: Fri, 5 Aug 2011 13:07:09 +0000 (+0000) Subject: Some annotation for (bug 29907) action=parse only fetches from the parser cache,... X-Git-Tag: 1.31.0-rc.0~28416 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=492c772fe700fff3199f97a8ee8e95762f01f354;p=lhc%2Fweb%2Fwiklou.git Some annotation for (bug 29907) action=parse only fetches from the parser cache, it does not store to it --- diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 6450917ffc..40b90cff90 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -110,9 +110,10 @@ class ApiParse extends ApiBase { $this->text = $this->getSectionText( $this->text, 'r' . $rev->getId() ); } + // Do we want to save old revision parses to the parser cache? $p_result = $wgParser->parse( $this->text, $titleObj, $popts ); } - } else { // Not $oldid + } else { // Not $oldid, but $pageid or $page if ( $params['redirects'] ) { $reqParams = array( 'action' => 'query', @@ -159,6 +160,7 @@ class ApiParse extends ApiBase { $oldid = $articleObj->getRevIdFetched(); } + // Potentially cached $p_result = $this->getParsedSectionOrText( $articleObj, $titleObj, $popts, $pageid, isset( $prop['wikitext'] ) ) ; } @@ -189,6 +191,7 @@ class ApiParse extends ApiBase { $result->addValue( null, $this->getModuleName(), $result_array ); return; } + // Not cached (save or load) $p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts ); } @@ -321,9 +324,11 @@ class ApiParse extends ApiBase { $this->text = $this->getSectionText( $articleObj->getRawText(), !is_null ( $pageId ) ? 'page id ' . $pageId : $titleObj->getText() ); + // Not cached (save or load) return $wgParser->parse( $this->text, $titleObj, $popts ); } else { // Try the parser cache first + // getParserOutput will save to Parser cache if able $pout = $articleObj->getParserOutput(); if ( $getWikitext ) { $rev = Revision::newFromTitle( $titleObj ); @@ -337,6 +342,7 @@ class ApiParse extends ApiBase { private function getSectionText( $text, $what ) { global $wgParser; + // Not cached (save or load) $text = $wgParser->getSection( $text, $this->section, false ); if ( $text === false ) { $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );