jenkins-bot has submitted this change and it was merged.

Change subject: Title: Always add title to LinkCache when necessary (in 3 
methods)
......................................................................


Title: Always add title to LinkCache when necessary (in 3 methods)

Unless Title::GAID_FOR_UPDATE is specified, Title::getArticleID() will not
use the link cache if the Title already has the ID of the page. Account for
this by directly calling LinkCache::addLinkObj() in three other methods of
Title: getContentModel(), isRedirect(), and getLength().

Follows-up r33008 (aed9d4b91218) and dd5c1b7fb7ff, and reapplies part of
388b14a15de6.

Bug: T86974
Change-Id: I7eff0bffd4f632ceb8d2124af317d684dbcaf2cb
---
M RELEASE-NOTES-1.25
M includes/Title.php
2 files changed, 6 insertions(+), 5 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index f0c00f3..aa421cb 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -131,6 +131,8 @@
 * (T85192) Captcha position modified in Usercreate template. As a result:
 ** extrafields parameter added to Usercreate.php to insert additional data
 ** 'extend' method added to QuickTemplate to append additional values to any 
field of data array
+* (T86974) Several Title methods now load from the database when necessary
+  (instead of returning incorrect results) even when the page ID is known.
 
 === Action API changes in 1.25 ===
 * (T67403) XML tag highlighting is now only performed for formats
diff --git a/includes/Title.php b/includes/Title.php
index 2d0cfda..463f75e 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -942,9 +942,9 @@
         * @return string Content model id
         */
        public function getContentModel( $flags = 0 ) {
-               # Calling getArticleID() loads the field from cache as needed
                if ( !$this->mContentModel && $this->getArticleID( $flags ) ) {
                        $linkCache = LinkCache::singleton();
+                       $linkCache->addLinkObj( $this ); # in case we already 
had an article ID
                        $this->mContentModel = $linkCache->getGoodLinkFieldObj( 
$this, 'model' );
                }
 
@@ -3185,13 +3185,13 @@
                if ( !is_null( $this->mRedirect ) ) {
                        return $this->mRedirect;
                }
-               # Calling getArticleID() loads the field from cache as needed
                if ( !$this->getArticleID( $flags ) ) {
                        $this->mRedirect = false;
                        return $this->mRedirect;
                }
 
                $linkCache = LinkCache::singleton();
+               $linkCache->addLinkObj( $this ); # in case we already had an 
article ID
                $cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' );
                if ( $cached === null ) {
                        # Trust LinkCache's state over our own
@@ -3220,12 +3220,12 @@
                if ( $this->mLength != -1 ) {
                        return $this->mLength;
                }
-               # Calling getArticleID() loads the field from cache as needed
                if ( !$this->getArticleID( $flags ) ) {
                        $this->mLength = 0;
                        return $this->mLength;
                }
                $linkCache = LinkCache::singleton();
+               $linkCache->addLinkObj( $this ); # in case we already had an 
article ID
                $cached = $linkCache->getGoodLinkFieldObj( $this, 'length' );
                if ( $cached === null ) {
                        # Trust LinkCache's state over our own, as for 
isRedirect()
@@ -3248,13 +3248,12 @@
                if ( !( $flags & Title::GAID_FOR_UPDATE ) && $this->mLatestID 
!== false ) {
                        return intval( $this->mLatestID );
                }
-               # Calling getArticleID() loads the field from cache as needed
                if ( !$this->getArticleID( $flags ) ) {
                        $this->mLatestID = 0;
                        return $this->mLatestID;
                }
                $linkCache = LinkCache::singleton();
-               $linkCache->addLinkObj( $this );
+               $linkCache->addLinkObj( $this ); # in case we already had an 
article ID
                $cached = $linkCache->getGoodLinkFieldObj( $this, 'revision' );
                if ( $cached === null ) {
                        # Trust LinkCache's state over our own, as for 
isRedirect()

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7eff0bffd4f632ceb8d2124af317d684dbcaf2cb
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to