Added explicit DB flags for Revision loading calls.
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 30 Aug 2012 03:04:30 +0000 (20:04 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 30 Aug 2012 03:04:30 +0000 (20:04 -0700)
Change-Id: Ie90d4197ad7a16009c96273eeae1a658678a8200

includes/Title.php
includes/api/ApiEditPage.php
includes/cache/MessageCache.php
includes/job/DoubleRedirectJob.php
includes/resourceloader/ResourceLoaderWikiModule.php

index b01c00b..94ae062 100644 (file)
@@ -3820,7 +3820,7 @@ class Title {
                        return false;
                }
                # Get the article text
-               $rev = Revision::newFromTitle( $nt );
+               $rev = Revision::newFromTitle( $nt, false, Revision::READ_LATEST );
                if( !is_object( $rev ) ){
                        return false;
                }
@@ -4113,11 +4113,11 @@ class Title {
                if ( in_array( 'include_old', $options ) ) {
                        $old_cmp = '>=';
                }
-               if ( in_array( 'include_new', $options ) ) {\r
-                       $new_cmp = '<=';\r
-               }\r
-               if ( in_array( 'include_both', $options ) ) {\r
-                       $old_cmp = '>=';\r
+               if ( in_array( 'include_new', $options ) ) {
+                       $new_cmp = '<=';
+               }
+               if ( in_array( 'include_both', $options ) ) {
+                       $old_cmp = '>=';
                        $new_cmp = '<=';
                }
                // No DB query needed if $old and $new are the same or successive revisions:
@@ -4128,7 +4128,7 @@ class Title {
                                return ( $old_cmp === '>' && $new_cmp === '<' ) ? 0 : 1;
                        }
                        return ( $old->getRawUserText() === $new->getRawUserText() ) ? 1 : 2;
-               }\r
+               }
                $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( 'revision', 'DISTINCT rev_user_text',
                        array(
index 3be4b00..0963fe7 100644 (file)
@@ -60,7 +60,11 @@ class ApiEditPage extends ApiBase {
                        if ( $titleObj->isRedirect() ) {
                                $oldTitle = $titleObj;
 
-                               $titles = Title::newFromRedirectArray( Revision::newFromTitle( $oldTitle )->getText( Revision::FOR_THIS_USER ) );
+                               $titles = Title::newFromRedirectArray(
+                                       Revision::newFromTitle(
+                                               $oldTitle, false, Revision::READ_LATEST
+                                       )->getText( Revision::FOR_THIS_USER )
+                               );
                                // array_shift( $titles );
 
                                $redirValues = array();
@@ -182,7 +186,7 @@ class ApiEditPage extends ApiBase {
                if ( !is_null( $params['summary'] ) ) {
                        $requestArray['wpSummary'] = $params['summary'];
                }
-               
+
                if ( !is_null( $params['sectiontitle'] ) ) {
                        $requestArray['wpSectionTitle'] = $params['sectiontitle'];
                }
index 24f32d6..b854a2e 100644 (file)
@@ -766,7 +766,9 @@ class MessageCache {
                }
 
                # Try loading it from the database
-               $revision = Revision::newFromTitle( Title::makeTitle( NS_MEDIAWIKI, $title ) );
+               $revision = Revision::newFromTitle(
+                       Title::makeTitle( NS_MEDIAWIKI, $title ), false, Revision::READ_LATEST
+               );
                if ( $revision ) {
                        $message = $revision->getText();
                        if ($message === false) {
index 5b86a90..08af997 100644 (file)
@@ -89,7 +89,7 @@ class DoubleRedirectJob extends Job {
                        return false;
                }
 
-               $targetRev = Revision::newFromTitle( $this->title );
+               $targetRev = Revision::newFromTitle( $this->title, false, Revision::READ_LATEST );
                if ( !$targetRev ) {
                        wfDebug( __METHOD__.": target redirect already deleted, ignoring\n" );
                        return true;
index 9dd6939..623a269 100644 (file)
@@ -77,7 +77,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
                if ( !$title->isCssJsSubpage() && !$title->isCssOrJsPage() ) {
                        return null;
                }
-               $revision = Revision::newFromTitle( $title );
+               $revision = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
                if ( !$revision ) {
                        return null;
                }
@@ -182,7 +182,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        // We're dealing with a subclass that doesn't have a DB
                        return array();
                }
-               
+
                $hash = $context->getHash();
                if ( isset( $this->titleMtimes[$hash] ) ) {
                        return $this->titleMtimes[$hash];