From cc126b8efad9007afa6f3fe24c6c7439026c4cc4 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 5 Oct 2012 16:08:07 +0200 Subject: [PATCH] Prevent page moved to different content model. Pages should never be moved in a way that would change their content model. Without this explicite check, that might happen when $wgContentHandlerUseDB is disabled. Change-Id: Id1a101f56bee6f13a7259d34019c587e75a4c182 --- includes/Title.php | 11 ++++++++++- languages/messages/MessagesEn.php | 1 + languages/messages/MessagesQqq.php | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/Title.php b/includes/Title.php index affffc3c68..f2531a2a1d 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3375,7 +3375,7 @@ class Title { * @return Mixed True on success, getUserPermissionsErrors()-like array on failure */ public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) { - global $wgUser; + global $wgUser, $wgContentHandlerUseDB; $errors = array(); if ( !$nt ) { @@ -3408,6 +3408,15 @@ class Title { $errors[] = array( 'badarticleerror' ); } + // Content model checks + if ( !$wgContentHandlerUseDB && + $this->getContentModel() !== $nt->getContentModel() ) { + // can't move a page if that would change the page's content model + $errors[] = array( 'bad-target-model', + ContentHandler::getLocalizedName( $this->getContentModel() ), + ContentHandler::getLocalizedName( $nt->getContentModel() ) ); + } + // Image-specific checks if ( $this->getNamespace() == NS_FILE ) { $errors = array_merge( $errors, $this->validateFileMoveOperation( $nt ) ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index e96418dc0c..b25d0a5ade 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3396,6 +3396,7 @@ cannot move a page over itself.', 'immobile-target-namespace-iw' => 'Interwiki link is not a valid target for page move.', 'immobile-source-page' => 'This page is not movable.', 'immobile-target-page' => 'Cannot move to that destination title.', +'bad-target-model' => 'The desired destination uses a different content model. Can not convert from $1 to $2.', 'imagenocrossnamespace' => 'Cannot move file to non-file namespace', 'nonfile-cannot-move-to-file' => 'Cannot move non-file to file namespace', 'imagetypemismatch' => 'The new file extension does not match its type', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index a1e4a73ad7..643f6f9b83 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -3191,6 +3191,10 @@ Parameters: 'immobile-target-namespace-iw' => "This message appears when attempting to move a page, if a person has typed an interwiki link as a namespace prefix in the input box labelled 'To new title'. The special page 'Movepage' cannot be used to move a page to another wiki. 'Destination' can be used instead of 'target' in this message.", +'bad-target-model' => "This message is shown when attempting to move a page, but the move would change the page's content model. +This may be the case when \$wgContentHandlerUseDB is set to false, because then a page's content model is derived from the page's title. +* $1: The localized name of the original page's content model. +* $2: The localized name of the content model used by the destination title.", 'fix-double-redirects' => 'This is a checkbox in [[Special:MovePage]] which allows to move all redirects from the old title to the new title.', 'protectedpagemovewarning' => 'Related message: [[MediaWiki:protectedpagewarning/{{#titleparts:{{PAGENAME}}|1|2}}]] {{Related|Semiprotectedpagewarning}}', -- 2.20.1