Page MenuHomePhabricator

Re-examine API module permissions (isAllowed, isBlocked) checks
Closed, DeclinedPublic

Description

https://gerrit.wikimedia.org/r/#/c/114974/2/api/ApiGroupReview.php,unified seems to have a bad code smell to me. Do we really require every API module to define "isAllowed" and "isBlocked"? That seems like a flawed architectural design to me, if so. When being extended, it seems to me that the base MediaWiki API should be able to handle these checks implicitly, to avoid situations like this.

Or, alternately, perhaps we need to fail faster when these checks are missing.


Version: 1.23.0
Severity: enhancement

Details

Reference
bz61841

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:07 AM
bzimport set Reference to bz61841.
bzimport added a subscriber: Unknown Object (MLST).

A nitpick: We don't require API modules to "define" any such methods. But if something wants to check for user rights or for blocked status then it needs to *call* (not "define") the methods to check for user rights or blocked status.

This seems to me as little different from now the rest of MediaWiki handles permissions checks, except for Special pages. And even many special pages need to go beyond the simple checks provided for in the base class. So no, I don't think that we need to try to cram flags for block and permissions checking into the already-overgrown API base classes.

Regarding that linked change in particular, it sounds like they have code duplication with their web UI code and their API code. Instead there should be some back-end method that does the actual work and returns status to the UI layer and both the web UI and the API should be calling that.