Page MenuHomePhabricator

API blocked error should give details - blocker, target (IP, range, user), expiry, reason, etc.
Closed, ResolvedPublic8 Story Points

Event Timeline

Krenair created this task.Apr 4 2015, 1:40 AM
Krenair raised the priority of this task from to Needs Triage.
Krenair updated the task description. (Show Details)
Krenair added a subscriber: Krenair.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 4 2015, 1:40 AM

Which query you are using?
Using meta=userinfo with uiprop=blockinfo should give some of that information. (Target seems missing.)

Or you are talking about the error 'blockedtext' coming from the api when using some write action as action=edit?

Anomie added a subscriber: Anomie.Apr 4 2015, 3:46 PM

Chances are that the "blocked" errors aren't even coming from the API directly, but rather are coming from the underlying core MediaWiki code. But since you haven't mentioned what query you're talking about, it's difficult to say.

As already mentioned, the best way to find out about the current user's block status is to use api.php?action=query&meta=userinfo&uiprop=blockinfo. If there's information missing there that is exposed to users via the web UI, file a bug and it can be added.

IIRC, we were thinking about this in the context of user account creations. But this data should come with block errors from action=edit and others as well.

Anomie triaged this task as Low priority.EditedApr 4 2015, 4:40 PM

Or, as already stated, the information can be queried by the client when it's needed.

If someone wants to write code for this, here's a general outline of what you'd need to do:

  • Refactor the parsing of block information in ApiQueryUserInfo into a static method (e.g. ApiQueryUserInfo::getBlockInfo( Block $block )).
    • Bonus: Use the same static method in ApiQueryUsers and ApiQueryAllUsers. Keep in mind private vs public if you consider adding stuff like the block target.
  • Identify the modules that have a "blocked" error. Don't forget extensions.
  • Identify the specific error messages that indicate "blocked" status.
  • Detect those messages, and use $this->dieUsage( $description, $code, 0, array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $block ) ) ) when reporting the error.
Krenair claimed this task.May 10 2015, 2:04 PM

Change 209974 had a related patch set uploaded (by Alex Monk):
API: Give block details along with errors

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

Change 209974 merged by jenkins-bot:
API: Give block details along with errors

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

Anomie closed this task as Resolved.Jun 17 2015, 7:56 PM