Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/247276
Change subject: [WIP] Return better error information via the API
......................................................................
[WIP] Return better error information via the API
* Use only a single error code 'titleblacklist-forbidden'
to allow API users to easily identify TitleBlacklist errors.
* Return the internal code and the matching entry's text
in machine-readable format (depends on
I1334ba21a2862973a9d8ff5be2c9bec06a82698b in MediaWiki core).
Bug: T115258
Change-Id: I42a0c5b0ea7e61088dd609b764dd7d1396c60cd5
---
M TitleBlacklist.hooks.php
1 file changed, 11 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TitleBlacklist
refs/changes/76/247276/1
diff --git a/TitleBlacklist.hooks.php b/TitleBlacklist.hooks.php
index d2e2c36..801fd21 100644
--- a/TitleBlacklist.hooks.php
+++ b/TitleBlacklist.hooks.php
@@ -33,13 +33,18 @@
$blacklisted = TitleBlacklist::singleton()->userCannot(
$title, $user, $action );
if ( $blacklisted instanceof TitleBlacklistEntry ) {
$errmsg = $blacklisted->getErrorMessage( 'edit'
);
- ApiBase::$messageMap[$errmsg] = array(
- 'code' => $errmsg,
- 'info' => 'TitleBlacklist prevents this
title from being created'
+ $result = ApiMessage::create(
+ wfMessage(
+ $errmsg,
+ htmlspecialchars(
$blacklisted->getRaw() ),
+ $title->getFullText()
+ ),
+ 'titleblacklist-forbidden',
+ array(
+ 'message' => $errmsg,
+ 'line' =>
$blacklisted->getRaw(),
+ )
);
- $result = array( $errmsg,
- htmlspecialchars(
$blacklisted->getRaw() ),
- $title->getFullText() );
return false;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/247276
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I42a0c5b0ea7e61088dd609b764dd7d1396c60cd5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TitleBlacklist
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits