Title->getContentModel: Get new content model with GAID_FOR_UPDATE
authorMatthew Flaschen <mflaschen@wikimedia.org>
Tue, 17 May 2016 14:18:58 +0000 (10:18 -0400)
committerMatthias Mullie <git@mullie.eu>
Wed, 18 May 2016 13:47:16 +0000 (15:47 +0200)
If a new revision has been inserted (e.g. with updateRevisionOn),
the content model may have changed.  This happens with e.g. undeletion.

Bug: T122262
Change-Id: Ia0ed86a9c24809256215418673e9ee8e263d1349

includes/Title.php

index 25fbce3..72c21fc 100644 (file)
@@ -908,7 +908,9 @@ class Title implements LinkTarget {
         * @return string Content model id
         */
        public function getContentModel( $flags = 0 ) {
-               if ( !$this->mContentModel && $this->getArticleID( $flags ) ) {
+               if ( ( !$this->mContentModel || $flags === Title::GAID_FOR_UPDATE ) &&
+                       $this->getArticleID( $flags )
+               ) {
                        $linkCache = LinkCache::singleton();
                        $linkCache->addLinkObj( $this ); # in case we already had an article ID
                        $this->mContentModel = $linkCache->getGoodLinkFieldObj( $this, 'model' );