PleaseStand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/155453
Change subject: Title::getContentModel(): load from DB if necessary
......................................................................
Title::getContentModel(): load from DB if necessary
Also don't cast $model to int in LinkCache::addGoodLinkObj(); content
model IDs are non-numeric strings, not integers, so that field was
always populated with the value 0. Because 0 is a falsy value, this
caused subsequent calls to Title::getContentModel() to return the
default model rather than the correct one.
Bug: 69789
Change-Id: I94f06baf406afa538cd2b10139598442f9fc6759
---
M RELEASE-NOTES-1.24
M includes/Title.php
M includes/cache/LinkCache.php
3 files changed, 8 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/53/155453/1
diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index 01f8b0a..0952400 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -196,6 +196,8 @@
* (bug 67870) wfShellExec() cuts off stdout at multiples of 8192 bytes.
* $wgRunJobsAsync now works with private wikis (e.g. read requires login).
* (bugs 57238, 65206) Blank pages can now be directly created.
+* (bug 69789) Title::getContentModel() now loads from the database when
+ necessary instead of incorrectly returning the default content model.
=== Web API changes in 1.24 ===
* action=parse API now supports prop=modules, which provides the list of
diff --git a/includes/Title.php b/includes/Title.php
index 15ff216..2bb56ca 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -944,10 +944,12 @@
* Get the page's content model id, see the CONTENT_MODEL_XXX constants.
*
* @throws MWException
+ * @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to
select for update
* @return string Content model id
*/
- public function getContentModel() {
- if ( !$this->mContentModel ) {
+ public function getContentModel( $flags = 0 ) {
+ # Calling getArticleID() loads the field from cache as needed
+ if ( !$this->mContentModel && $this->getArticleID( $flags ) ) {
$linkCache = LinkCache::singleton();
$this->mContentModel = $linkCache->getGoodLinkFieldObj(
$this, 'model' );
}
diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php
index e80dfb3..f6efe55 100644
--- a/includes/cache/LinkCache.php
+++ b/includes/cache/LinkCache.php
@@ -129,7 +129,7 @@
* @param int $len Text's length
* @param int $redir Whether the page is a redirect
* @param int $revision Latest revision's ID
- * @param int $model Latest revision's content model ID
+ * @param string $model Latest revision's content model ID
*/
public function addGoodLinkObj( $id, $title, $len = -1, $redir = null,
$revision = 0, $model = 0
@@ -140,7 +140,7 @@
'length' => (int)$len,
'redirect' => (int)$redir,
'revision' => (int)$revision,
- 'model' => (int)$model
+ 'model' => $model
);
}
--
To view, visit https://gerrit.wikimedia.org/r/155453
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I94f06baf406afa538cd2b10139598442f9fc6759
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits