Revert and fix "Revert "EditPage: Show EditFilterMergedContent hook errors in an...
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 26 Jan 2018 17:12:28 +0000 (09:12 -0800)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 26 Jan 2018 17:15:18 +0000 (09:15 -0800)
Instead of making a one-line fix to fix the issue in T149473, the change
was reverted.

This reverts commit 022f26e9fd3ae865331f3bb1b3eec63e212240c9.
This reverts commit 12f170502cfef525344ae69caef6240eaafbf63f.

Bug: T149473
Bug: T185638
Change-Id: Ib44ba2a6d2405309ad91bcc4d6440d05b67379da

includes/EditPage.php
languages/i18n/en.json
languages/i18n/qqq.json

index 5dc0720..d49f205 100644 (file)
@@ -1717,7 +1717,7 @@ class EditPage {
                                // being set. This is used by ConfirmEdit to display a captcha
                                // without any error message cruft.
                        } else {
-                               $this->hookError = $status->getWikiText();
+                               $this->hookError = $this->formatStatusErrors( $status );
                        }
                        // Use the existing $status->value if the hook set it
                        if ( !$status->value ) {
@@ -1727,7 +1727,7 @@ class EditPage {
                } elseif ( !$status->isOK() ) {
                        # ...or the hook could be expecting us to produce an error
                        // FIXME this sucks, we should just use the Status object throughout
-                       $this->hookError = $status->getWikiText();
+                       $this->hookError = $this->formatStatusErrors( $status );
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR_EXPECTED;
                        return false;
@@ -1736,6 +1736,26 @@ class EditPage {
                return true;
        }
 
+       /**
+        * Wrap status errors in an errorbox for increased visiblity
+        *
+        * @param Status $status
+        * @return string Wikitext
+        */
+       private function formatStatusErrors( Status $status ) {
+               $errmsg = $status->getWikiText(
+                       'edit-error-short',
+                       'edit-error-long',
+                       $this->context->getLanguage()
+               );
+               return <<<ERROR
+<div class="errorbox">
+{$errmsg}
+</div>
+<br clear="all" />
+ERROR;
+       }
+
        /**
         * Return the summary to be used for a new section.
         *
index 4cabfda..8d4b952 100644 (file)
        "restrictionsfield-badip": "Invalid IP address or range: $1",
        "restrictionsfield-label": "Allowed IP ranges:",
        "restrictionsfield-help": "One IP address or CIDR range per line. To enable everything, use:<pre>0.0.0.0/0\n::/0</pre>",
+       "edit-error-short": "Error: $1",
+       "edit-error-long": "Errors:\n\n$1",
        "revid": "revision $1",
        "pageid": "page ID $1",
        "rawhtml-notallowed": "&lt;html&gt; tags cannot be used outside of normal pages.",
index 09ca63e..5cf949d 100644 (file)
        "restrictionsfield-badip": "An error message shown when one entered an invalid IP address or range in a restrictions field (such as Special:BotPassword). $1 is the IP address.",
        "restrictionsfield-label": "Field label shown for restriction fields (e.g. on Special:BotPassword).",
        "restrictionsfield-help": "Placeholder text displayed in restriction fields (e.g. on Special:BotPassword).",
+       "edit-error-short": "Error message. Parameters:\n* $1 - the error details\nSee also:\n* {{msg-mw|edit-error-long}}\n{{Identical|Error}}",
+       "edit-error-long": "Error message. Parameters:\n* $1 - the error details\nSee also:\n* {{msg-mw|edit-error-short}}\n{{Identical|Error}}",
        "revid": "Used to format a revision ID number in text. Parameters:\n* $1 - Revision ID number.\n{{Identical|Revision}}",
        "pageid": "Used to format a page ID number in text. Parameters:\n* $1 - Page ID number.",
        "rawhtml-notallowed": "Error message given when $wgRawHtml = true; is set and a user uses an &lt;html&gt; tag in a system message or somewhere other than a normal page.",