Hoo man has uploaded a new change for review.

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


Change subject: Really parse the API warning in the APIEditBeforeSave hook
......................................................................

Really parse the API warning in the APIEditBeforeSave hook

Status::getHtml doesn't actually parse messages, but
performs a dump message transformation on them.

Bug: 51403
Change-Id: I9d82d0a74f049648735b820e731ab1883aaa3131
---
M AbuseFilter.hooks.php
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter 
refs/changes/95/73895/1

diff --git a/AbuseFilter.hooks.php b/AbuseFilter.hooks.php
index 1ef481f..a2c0b80 100644
--- a/AbuseFilter.hooks.php
+++ b/AbuseFilter.hooks.php
@@ -33,23 +33,26 @@
 
                if ( !$status->isOK() ) {
                        $msg = $status->getErrorsArray();
+                       $msg = $msg[0];
 
                        // Use the error message key name as error code, the 
first parameter is the filter description.
-                       if ( $msg[0] instanceof Message ) {
+                       if ( $msg instanceof Message ) {
                                // For forward compatibility: In case we switch 
over towards using Message objects someday.
                                // (see the todo for AbuseFilter::buildStatus)
-                               $code = $msg[0]->getKey();
-                               $filterDescription = $msg[0]->getParams();
+                               $code = $msg->getKey();
+                               $filterDescription = $msg->getParams();
                                $filterDescription = $filterDescription[0];
+                               $warning = $msg->parse();
                        } else {
-                               $code = $msg[0][0];
-                               $filterDescription = $msg[0][1];
+                               $code = array_shift( $msg );
+                               $filterDescription = $msg[0];
+                               $warning = wfMessage( $code )->params( $msg 
)->parse();
                        }
 
                        $result = array(
                                'code' => $code,
                                'info' => 'Hit AbuseFilter: ' . 
$filterDescription,
-                               'warning' => $status->getHTML()
+                               'warning' => $warning
                        );
                }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d82d0a74f049648735b820e731ab1883aaa3131
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to