Merge "Display "Printable version" links in toolbox on special pages"
[lhc/web/wiklou.git] / includes / Title.php
index d40d923..56c2ed4 100644 (file)
@@ -2922,11 +2922,13 @@ class Title {
                $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;
@@ -2951,11 +2953,9 @@ class Title {
                }
                $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 );
@@ -2967,7 +2967,6 @@ class Title {
         * 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 ) {
@@ -2981,10 +2980,9 @@ class Title {
                $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 );
@@ -4533,7 +4531,7 @@ class Title {
                if ( array_key_exists( $uid, $this->mNotificationTimestamp ) ) {
                        return $this->mNotificationTimestamp[$uid];
                }
-               if ( !$uid || !$wgShowUpdatedMarker ) {
+               if ( !$uid || !$wgShowUpdatedMarker || !$user->isAllowed( 'viewmywatchlist' ) ) {
                        return $this->mNotificationTimestamp[$uid] = false;
                }
                // Don't cache too much!