ApiParse: Replace isCurrent() check with getLatest() comparison
authorRoan Kattouw <roan.kattouw@gmail.com>
Wed, 8 Apr 2015 21:55:44 +0000 (14:55 -0700)
committerCatrope <roan.kattouw@gmail.com>
Wed, 8 Apr 2015 22:34:16 +0000 (22:34 +0000)
Because the $pageObj state is what actually ends up getting used.
If $pageObj thinks an old rev is the latest one, then we are in
trouble, even if $rev knows what's really going on.

Bug: T95466
Change-Id: I4d6ba4f18adaaad052d3bee1a575ba034aaf112b

includes/api/ApiParse.php

index 73bea83..b565dea 100644 (file)
@@ -107,7 +107,10 @@ class ApiParse extends ApiBase {
                                $popts = $this->makeParserOptions( $pageObj, $params );
 
                                // If for some reason the "oldid" is actually the current revision, it may be cached
-                               if ( $rev->isCurrent() ) {
+                               // Deliberately comparing $pageObj->getLatest() with $rev->getId(), rather than
+                               // checking $rev->isCurrent(), because $pageObj is what actually ends up being used,
+                               // and if its ->getLatest() is outdated, $rev->isCurrent() won't tell us that.
+                               if ( $rev->getId() == $pageObj->getLatest() ) {
                                        // May get from/save to parser cache
                                        $p_result = $this->getParsedContent( $pageObj, $popts,
                                                $pageid, isset( $prop['wikitext'] ) );