Followup r75334. Change to int == string, rather than int === string (not going to...
authorSam Reed <reedy@users.mediawiki.org>
Sat, 1 Jan 2011 22:35:16 +0000 (22:35 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 1 Jan 2011 22:35:16 +0000 (22:35 +0000)
Attempt to load/save an article object, rather than an title object from the parser cache.

Per Bryan, and per bug 26534 now logged, this really needs refactoring more cleanly. As if latestRevId == oldid set, it's doing exactly the same lookup/parse

includes/api/ApiParse.php

index acb8905..d2e1920 100644 (file)
@@ -94,18 +94,21 @@ class ApiParse extends ApiBase {
                                $wgTitle = $titleObj;
 
                                // If for some reason the "oldid" is actually the current revision, it may be cached
-                               if ( $titleObj->getLatestRevID() === $oldid ) {
+                               if ( $titleObj->getLatestRevID() == $oldid ) {
                                        $p_result = false;
                                        $pcache = ParserCache::singleton();
+
+                                       $articleObj = new Article( $titleObj );
+
                                        if ( $wgEnableParserCache ) {
-                                               $p_result = $pcache->get( $titleObj, $popts );
+                                               $p_result = $pcache->get( $articleObj, $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 );
+                                                       $pcache->save( $p_result, $articleObj, $popts );
                                                }
                                        }
                                } else {
@@ -157,7 +160,9 @@ class ApiParse extends ApiBase {
                                }
 
                                if ( $this->section !== false ) {
-                                       $text = $this->getSectionText( $text, !is_null ( $pageid ) ? 'page id ' . $pageid : $titleObj->getText() );
+                                       $text = $this->getSectionText( $text, !is_null ( $pageid )
+                                                       ? 'page id ' . $pageid : $titleObj->getText() );
+
                                        $p_result = $wgParser->parse( $text, $titleObj, $popts );
                                } else {
                                        // Try the parser cache first