* If a action=parse request provides an oldid that is actually the current revision...
authorSam Reed <reedy@users.mediawiki.org>
Sun, 24 Oct 2010 19:16:46 +0000 (19:16 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 24 Oct 2010 19:16:46 +0000 (19:16 +0000)
RELEASE-NOTES
includes/api/ApiParse.php

index c8e8209..a485050 100644 (file)
@@ -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 ===
 
index c487ca8..de3b371 100644 (file)
@@ -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 );