From: Brad Jorsch Date: Fri, 26 Jan 2018 17:12:28 +0000 (-0800) Subject: Revert and fix "Revert "EditPage: Show EditFilterMergedContent hook errors in an... X-Git-Tag: 1.31.0-rc.0~795^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;ds=sidebyside;h=268fefee97fbf8466bcd63dddf915b9089d2968a;p=lhc%2Fweb%2Fwiklou.git Revert and fix "Revert "EditPage: Show EditFilterMergedContent hook errors in an errorbox"" 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 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 5dc0720750..d49f2051e9 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 << +{$errmsg} + +
+ERROR; + } + /** * Return the summary to be used for a new section. * diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 4cabfdab4c..8d4b9522c2 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -4425,6 +4425,8 @@ "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:
0.0.0.0/0\n::/0
", + "edit-error-short": "Error: $1", + "edit-error-long": "Errors:\n\n$1", "revid": "revision $1", "pageid": "page ID $1", "rawhtml-notallowed": "<html> tags cannot be used outside of normal pages.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 09ca63e562..5cf949d05d 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -4620,6 +4620,8 @@ "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 <html> tag in a system message or somewhere other than a normal page.",