From 72bd3d545eec00354d37679d4bb34827eb451466 Mon Sep 17 00:00:00 2001 From: Ricordisamoa Date: Wed, 4 May 2016 17:35:59 +0200 Subject: [PATCH] Do not show useless form at Special:ChangeContentModel If the choosen title cannot be converted to any of the available models, show an error page instead of an empty and confusing dropdown field asking for the new content model. Change-Id: Idc7372a8870f98aa8148592385f3a837f16886f0 --- includes/specials/SpecialChangeContentModel.php | 10 +++++++++- languages/i18n/en.json | 2 ++ languages/i18n/qqq.json | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/specials/SpecialChangeContentModel.php b/includes/specials/SpecialChangeContentModel.php index ee9f665bbd..c7a650cca6 100644 --- a/includes/specials/SpecialChangeContentModel.php +++ b/includes/specials/SpecialChangeContentModel.php @@ -84,12 +84,20 @@ class SpecialChangeContentModel extends FormSpecialPage { ], ]; if ( $this->title ) { + $options = $this->getOptionsForTitle( $this->title ); + if ( empty( $options ) ) { + throw new ErrorPageError( + 'changecontentmodel-emptymodels-title', + 'changecontentmodel-emptymodels-text', + $this->title->getPrefixedText() + ); + } $fields['pagetitle']['readonly'] = true; $fields += [ 'model' => [ 'type' => 'select', 'name' => 'model', - 'options' => $this->getOptionsForTitle( $this->title ), + 'options' => $options, 'label-message' => 'changecontentmodel-model-label' ], 'reason' => [ diff --git a/languages/i18n/en.json b/languages/i18n/en.json index aacf623bdb..093607982b 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2133,6 +2133,8 @@ "changecontentmodel-success-text": "The content type of [[:$1]] has been changed.", "changecontentmodel-cannot-convert": "The content on [[:$1]] cannot be converted to a type of $2.", "changecontentmodel-nodirectediting": "The $1 content model does not support direct editing", + "changecontentmodel-emptymodels-title": "No content models available", + "changecontentmodel-emptymodels-text": "The content on [[:$1]] cannot be converted to any type.", "log-name-contentmodel": "Content model change log", "log-description-contentmodel": "Events related to the content models of a page", "logentry-contentmodel-new": "$1 {{GENDER:$2|created}} the page $3 using a non-default content model \"$5\"", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index ed5c2b42ec..413b333600 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2311,6 +2311,8 @@ "changecontentmodel-success-text": "Message telling user that their change has been successfully done.\n* $1 - Target page title", "changecontentmodel-cannot-convert": "Error message shown if the content model cannot be changed to the specified type. $1 is the page title, $2 is the localized content model name.", "changecontentmodel-nodirectediting": "Error message shown if the content model does not allow for direct editing. $1 is the localized name of the content model.", + "changecontentmodel-emptymodels-title": "Title of the error page shown if the content model cannot be changed to any of the available types.", + "changecontentmodel-emptymodels-text": "Text of the error page shown if the content model cannot be changed to any of the available types. $1 is the page title.", "log-name-contentmodel": "{{doc-logpage}}\n\nTitle of [[Special:Log/contentmodel]].", "log-description-contentmodel": "Text in [[Special:Log/contentmodel]].", "logentry-contentmodel-new": "{{Logentry}}\n$4 is not used.\n$5 is the new content model.", -- 2.20.1