Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315722

Change subject: EditPage: Show EditFilterMergedContent hook errors in an 
errorbox
......................................................................

EditPage: Show EditFilterMergedContent hook errors in an errorbox

Errors that go through the Status object of the EditFilterMergedContent
hook have less control over how their errors are displayed, compared to
the legacy EditFilterMerged hook. Notably, Scribunto wrapped its errors
in an errorbox for increased visibility. That was a good idea in
general, so let's do that for all errors.

Change-Id: I1f0e463841298b8c59ed8bd898c8a4661c5e3aa4
---
M includes/EditPage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
3 files changed, 28 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/22/315722/1

diff --git a/includes/EditPage.php b/includes/EditPage.php
index 8226da5..95d11c4 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -1639,7 +1639,7 @@
                                // 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 ) {
@@ -1649,7 +1649,7 @@
                } 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;
@@ -1659,6 +1659,26 @@
        }
 
        /**
+        * Wrap status errors in an errorbox for increased visiblity
+        *
+        * @param Status $status
+        * @return string
+        */
+       private function formatStatusErrors( Status $status ) {
+               $errmsg = $status->getHTML(
+                       '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.
         *
         * @param string $sectionanchor Set to the section anchor text
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 30adf58..4107b9e 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -4227,5 +4227,7 @@
        "usercssispublic": "Please note: CSS subpages should not contain 
confidential data as they are viewable by other users.",
        "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<br><code>0.0.0.0/0</code><br><code>::/0</code>"
+       "restrictionsfield-help": "One IP address or CIDR range per line. To 
enable everything, use<br><code>0.0.0.0/0</code><br><code>::/0</code>",
+       "edit-error-short": "Error: $1",
+       "edit-error-long": "Errors:\n\n$1"
 }
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 235bf1e..6c0cd57 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -4411,5 +4411,7 @@
        "usercssispublic": "A reminder to users that CSS subpages are not 
preferences but normal pages, and thus can be viewed by other users and the 
general public. This message is shown to a user whenever they are editing a 
subpage in their own user-space that ends in .css. See also 
{{msg-mw|userjsispublic}}",
        "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)."
+       "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}}",
+       "edit-error-long": "Error message. Parameters:\n* $1 - the error 
details\nSee also:\n* {{msg-mw|edit-error-short}}",
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/315722
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f0e463841298b8c59ed8bd898c8a4661c5e3aa4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to