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

Change subject: Populate rev_content_model when a move causes default content 
model to change
......................................................................


Populate rev_content_model when a move causes default content model to change

If the default content model changes due to a page move, a NULL in
rev_content_model will now reference the new default, which is not how
the revision was serialized, causing an exception to be thrown.

This was caused by a5bc9f49cd01e, since previously NULL would use the
correct, but techncially inaccurate, page_content_model.

Bug: T105260
Change-Id: I0c29d0e657ad0b656e5da6ba365f337229ad4dfd
---
M includes/MovePage.php
1 file changed, 17 insertions(+), 0 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  Matthias Mullie: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/MovePage.php b/includes/MovePage.php
index 9891106..964fbff 100644
--- a/includes/MovePage.php
+++ b/includes/MovePage.php
@@ -416,6 +416,13 @@
                        $redirectContent = null;
                }
 
+               // Figure out whether the content model is no longer the default
+               $oldDefault = ContentHandler::getDefaultModelFor( 
$this->oldTitle );
+               $contentModel = $this->oldTitle->getContentModel();
+               $newDefault = ContentHandler::getDefaultModelFor( $nt );
+               $defaultContentModelChanging = ( $oldDefault !== $newDefault
+                       && $oldDefault === $contentModel );
+
                // bug 57084: log_page should be the ID of the *moved* page
                $oldid = $this->oldTitle->getArticleID();
                $logTitle = clone $this->oldTitle;
@@ -493,6 +500,16 @@
                $newpage->doEditUpdates( $nullRevision, $user,
                        array( 'changed' => false, 'moved' => true, 
'oldcountable' => $oldcountable ) );
 
+               // If the default content model changes, we need to populate 
rev_content_model
+               if ( $defaultContentModelChanging ) {
+                       $dbw->update(
+                               'revision',
+                               array( 'rev_content_model' => $contentModel ),
+                               array( 'rev_page' => $nt->getArticleID(), 
'rev_content_model IS NULL' ),
+                               __METHOD__
+                       );
+               }
+
                if ( !$moveOverRedirect ) {
                        WikiPage::onArticleCreate( $nt );
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0c29d0e657ad0b656e5da6ba365f337229ad4dfd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to