diff options
author | Kevin Israel <pleasestand@live.com> | 2015-01-15 17:24:03 -0500 |
---|---|---|
committer | Erik Bernhardson <ebernhardson@wikimedia.org> | 2015-01-23 12:19:32 -0800 |
commit | 50c9bbfbd50e726bf8fe5f5629582e7f71f97dba (patch) | |
tree | e751ca6f0d484ea004847f38fb84eebb538d2e17 | |
parent | 9a0e7169fc059fb7f424c476b99bf686802e974b (diff) | |
download | mediawikicore-50c9bbfbd50e726bf8fe5f5629582e7f71f97dba.tar.gz mediawikicore-50c9bbfbd50e726bf8fe5f5629582e7f71f97dba.zip |
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
-rw-r--r-- | RELEASE-NOTES-1.25 | 2 | ||||
-rw-r--r-- | includes/Title.php | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index f0c00f34b257..aa421cbe17ab 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -131,6 +131,8 @@ production. * (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 2d0cfda6275a..463f75e728d7 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -942,9 +942,9 @@ class Title { * @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 @@ class Title { 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 @@ class Title { 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 @@ class Title { 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() |