Page MenuHomePhabricator

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

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.

Change #1185313 had a related patch set uploaded (by Agrimasahu; author: Agrimasahu):

[mediawiki/core@master] MediaWiki-Action-API: Clarify hook docs for parameter type in API hooks

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

Hello Everyone

I am a Beginner here, and I have contributed on this task.
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1185313

can anyone review my contribution please, and give me suggestion.

Thanks

aaron triaged this task as Medium priority.Sep 9 2025, 1:45 AM
aaron moved this task from Incoming (Needs Triage) to Bugs & Chores on the MW-Interfaces-Team board.

Hi @aaron,
I’m a mentor at WikiClub Tech (RoadToWiki). We’ve been training many students, and some of them have recently started contributing. One of our beginner contributors has a task that’s been under review.
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1185313

Could you please check her task? If everything looks good, kindly merge it.

Thanks a lot for your support!

Hi, I’m a new contributor and I was going through this task and the related patch.
I understand that the $module parameter should always be an ApiBase object. I wanted to confirm if all hook documentation should consistently mention this, or if there are any exceptions where it might differ.