MovePage: Check ContentHandler::canBeUsedOn()
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 29 Sep 2016 23:09:43 +0000 (16:09 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Thu, 29 Sep 2016 23:09:43 +0000 (16:09 -0700)
If the old content model cannot be used on the new page title, the page
move should be disallowed.

Change-Id: I6078a4cde5a76a050dddedf59634d800765cbabf

includes/MovePage.php

index 5f1dd3f..8ee562a 100644 (file)
@@ -131,6 +131,14 @@ class MovePage {
                                ContentHandler::getLocalizedName( $this->oldTitle->getContentModel() ),
                                ContentHandler::getLocalizedName( $this->newTitle->getContentModel() )
                        );
+               } elseif (
+                       !ContentHandler::getForTitle( $this->oldTitle )->canBeUsedOn( $this->newTitle )
+               ) {
+                       $status->fatal(
+                               'content-not-allowed-here',
+                               ContentHandler::getLocalizedName( $this->oldTitle->getContentModel() ),
+                               $this->newTitle->getPrefixedText()
+                       );
                }
 
                // Image-specific checks