Nemo bis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/110924

Change subject: Remove unnecessary exception from Title::getLatestRevID()
......................................................................

Remove unnecessary exception from Title::getLatestRevID()

Bug 37209: An exception was thrown where the data cached in the Title
object was inconsistent with the data in LinkCache. It shouldn't be
surprising that this happens, since there is no guarantee that the data
was derived from the same transaction or even the same DB server.

But I don't think it is a problem worth troubling the user over, since
with $flags=0, the slave DB server will be used, and no special guarantee
of consistency should be expected by callers. If callers do need
consistency, then they should make their own arrangements to get it,
such as clearing the LinkCache.

Since we have to pick a winner, and the choice is mostly arbitrary since
it's not possible to tell which is fresher, I think LinkCache is a better
choice since the lifetime of its cache entries can be controlled.

Change-Id: I0add48463341e56fe8c155b1007487278ad2705d
(cherry picked from commit 22e2e96088d81022cb40e9991683a335029e7565)
---
M includes/Title.php
1 file changed, 13 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/24/110924/1

diff --git a/includes/Title.php b/includes/Title.php
index ca66aae..65a7926 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2960,11 +2960,13 @@
                $linkCache = LinkCache::singleton();
                $cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' );
                if ( $cached === null ) {
-                       // TODO: check the assumption that the cache actually 
knows about this title
-                       // and handle this, such as get the title from the 
database.
-                       // See 
https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
-                       wfDebug( "LinkCache doesn't currently know about this 
title: " . $this->getPrefixedDBkey() );
-                       wfDebug( wfBacktrace() );
+                       # Trust LinkCache's state over our own
+                       # LinkCache is telling us that the page doesn't exist, 
despite there being cached
+                       # data relating to an existing page in 
$this->mArticleID. Updaters should clear
+                       # LinkCache as appropriate, or use $flags = 
Title::GAID_FOR_UPDATE. If that flag is
+                       # set, then LinkCache will definitely be up to date 
here, since getArticleID() forces
+                       # LinkCache to refresh its data from the master.
+                       return $this->mRedirect = false;
                }
 
                $this->mRedirect = (bool)$cached;
@@ -2989,11 +2991,9 @@
                }
                $linkCache = LinkCache::singleton();
                $cached = $linkCache->getGoodLinkFieldObj( $this, 'length' );
-               if ( $cached === null ) { # check the assumption that the cache 
actually knows about this title
-                       # XXX: this does apparently happen, see 
https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
-                       #      as a stop gap, perhaps log this, but don't throw 
an exception?
-                       wfDebug( "LinkCache doesn't currently know about this 
title: " . $this->getPrefixedDBkey() );
-                       wfDebug( wfBacktrace() );
+               if ( $cached === null ) {
+                       # Trust LinkCache's state over our own, as for 
isRedirect()
+                       return $this->mLength = 0;
                }
 
                $this->mLength = intval( $cached );
@@ -3005,7 +3005,6 @@
         * What is the page_latest field for this page?
         *
         * @param int $flags a bit field; may be Title::GAID_FOR_UPDATE to 
select for update
-        * @throws MWException
         * @return Int or 0 if the page doesn't exist
         */
        public function getLatestRevID( $flags = 0 ) {
@@ -3019,10 +3018,9 @@
                $linkCache = LinkCache::singleton();
                $linkCache->addLinkObj( $this );
                $cached = $linkCache->getGoodLinkFieldObj( $this, 'revision' );
-               if ( $cached === null ) { # check the assumption that the cache 
actually knows about this title
-                       # XXX: this does apparently happen, see 
https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
-                       #      as a stop gap, perhaps log this, but don't throw 
an exception?
-                       throw new MWException( "LinkCache doesn't currently 
know about this title: " . $this->getPrefixedDBkey() );
+               if ( $cached === null ) {
+                       # Trust LinkCache's state over our own, as for 
isRedirect()
+                       return $this->mLatestID = 0;
                }
 
                $this->mLatestID = intval( $cached );

-- 
To view, visit https://gerrit.wikimedia.org/r/110924
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0add48463341e56fe8c155b1007487278ad2705d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_21
Gerrit-Owner: Nemo bis <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to