Merge "EditPage: Don't throw exceptions for invalid content models"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 13 Sep 2016 00:46:42 +0000 (00:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 13 Sep 2016 00:46:42 +0000 (00:46 +0000)
includes/EditPage.php
languages/i18n/en.json
languages/i18n/qqq.json

index c5330ee..140cd72 100644 (file)
@@ -1008,9 +1008,17 @@ class EditPage {
                // May be overridden by revision.
                $this->contentFormat = $request->getText( 'format', $this->contentFormat );
 
-               if ( !ContentHandler::getForModelID( $this->contentModel )
-                       ->isSupportedFormat( $this->contentFormat )
-               ) {
+               try {
+                       $handler = ContentHandler::getForModelID( $this->contentModel );
+               } catch ( MWUnknownContentModelException $e ) {
+                       throw new ErrorPageError(
+                               'editpage-invalidcontentmodel-title',
+                               'editpage-invalidcontentmodel-text',
+                               [ $this->contentModel ]
+                       );
+               }
+
+               if ( !$handler->isSupportedFormat( $this->contentFormat ) ) {
                        throw new ErrorPageError(
                                'editpage-notsupportedcontentformat-title',
                                'editpage-notsupportedcontentformat-text',
index 7152547..558a452 100644 (file)
        "invalid-content-data": "Invalid content data",
        "content-not-allowed-here": "\"$1\" content is not allowed on page [[$2]]",
        "editwarning-warning": "Leaving this page may cause you to lose any changes you have made.\nIf you are logged in, you can disable this warning in the \"{{int:prefs-editing}}\" section of your preferences.",
+       "editpage-invalidcontentmodel-title": "Content model not supported",
+       "editpage-invalidcontentmodel-text": "The content model \"$1\" is not a supported.",
        "editpage-notsupportedcontentformat-title": "Content format not supported",
        "editpage-notsupportedcontentformat-text": "The content format $1 is not supported by the content model $2.",
        "content-model-wikitext": "wikitext",
index 37db99b..bd8a904 100644 (file)
        "invalid-content-data": "Error message indicating that the page's content can not be saved because it is invalid. This may occurr for content types with internal consistency constraints.",
        "content-not-allowed-here": "Error message indicating that the desired content model is not supported in given localtion.\n* $1 - the human readable name of the content model: {{msg-mw|Content-model-wikitext}}, {{msg-mw|Content-model-javascript}}, {{msg-mw|Content-model-css}} or {{msg-mw|Content-model-text}}\n* $2 - the title of the page in question",
        "editwarning-warning": "Uses {{msg-mw|Prefs-editing}}",
+       "editpage-invalidcontentmodel-title": "Title of error page shown when using an unrecognized content model on EditPage",
+       "editpage-invalidcontentmodel-text": "Error message shown when using an unrecognized content model on EditPage. $1 is the user's invalid input",
        "editpage-notsupportedcontentformat-title": "Title of error page shown when using an incompatible format on EditPage.\n\nUsed as title for the following error message:\n* {{msg-mw|Editpage-notsupportedcontentformat-text}}.",
        "editpage-notsupportedcontentformat-text": "Error message shown when using an incompatible format on EditPage.\n\nThe title for this error is {{msg-mw|Editpage-notsupportedcontentformat-title}}.\n\nParameters:\n* $1 - the format id\n* $2 - the content model name",
        "content-model-wikitext": "Name for the wikitext content model, used when decribing what type of content a page contains.\n\nThis message is substituted in:\n*{{msg-mw|Bad-target-model}}\n*{{msg-mw|Content-not-allowed-here}}",