On Tue, May 27, 2008 at 6:13 PM, Roan Kattouw <roan.kattouw(a)home.nl> wrote:
There's been some discussion at mediawiki-api
about what we should do
with hooks in the API. There are currently three problems:
1. hooks that are supposed to be run aren't (such as ArticleDelete and
ArticleDeleteComplete before yesterday
2. some hooks that are run can mess up (such as AlternateEdit)
3. the 'hookaborted' error the API returns doesn't include details as to
who aborted the request and why
What I, personally, consider to be the best approach is to add new hooks
to the API modules, which provide a possibility for extensions to abort
the request and override the returned result. The only example thus far
is the APIEditBeforeSave hook (includes/api/ApiEditPage.php:132). Other
hooks should then be prevented from doing UI-specific things as much as
possible. The AlternateEdit hook, for instance, has no place in an API
request, as its very purpose is to override the edit form.
This should be done for hooks that are normally used to change the
interface. We should try to trigger as many core hooks as possible for
compatibility issues.
Most initialization hooks (most notably the
SpecialPage and LogPage*
hooks) are unnecessary for query requests (and also for many regular UI
requests). Shouldn't we lazy-load special page names and LogPage data?
The other lists look harmless, except for action=edit, which has the
AlternateEdit hook, which doesn't belong there. AlternateEdit serves to
replace the edit form. Extensions like AssertEdit that want to do
something for every action=edit request will have to use the right hooks
(APIEditPageBeforeSave or EditPage::attemptSave or whatever).
The problem arises that in some cases only interface hooks exist and
not clean backend hooks. IIRC this is for example
SpecialMovepageAftermove or something like that. There is no
ArticleMoveComplete hook, which leads to the fact that the
SpecialMovepage hook is used for both interface as backend hooks. That
probably needs fixing. Instead of the AlternateEdit hooks there should
be a generic BeforeArticleSave hook.