Page MenuHomePhabricator

API documentation unclear on hook arguments of type "Module"
Open, Needs TriagePublic

Description

This is a ticket to improve some documentation about hooks in the MediaWiki API.

Many hooks for the API have a first argument called $module. For some hooks like APIGetParamDescription, this argument is called an "ApiBase Module object," and for others like ApiCheckCanExecute, it's called a "Module object." This is confusing because:

  1. It's not clear what a "Module object" is. I can't find a class called "Module" in MediaWiki core.
  2. When I look at examples of using ApiCheckCanExecute, $module is simply a string like "upload", presumably a module name.

To help resolve this confusion. I suggest that the documentation for all these hooks should spell out whether the $module argument is a string containing a module name, or an ApiBase object, or something else.

Hope this helps!

Event Timeline

Anomie subscribed.

It should always be an ApiBase object, if it were a module name it shouldn't say "object". Sometimes it might be known to be a subclass, for example 'APIQueryAfterExecute' will get an ApiQueryBase and 'APIQueryGeneratorAfterExecute' will get an ApiQueryGeneratorBase.

This should be an good first task documentation update task for someone, just look at the caller of each hook with such an argument and see what it's being passed.

When I look at examples of using ApiCheckCanExecute

The only page in that category is an apparently-broken third-party extension. 'ApiCheckCanExecute' gets an ApiBase object and always has.