Last modified: 2014-04-22 17:59:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 12829 - Simplify and Unify Hook Naming Scheme
Simplify and Unify Hook Naming Scheme
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
  Show dependency treegraph
Reported: 2008-01-29 16:22 UTC by Christian Neubauer
Modified: 2014-04-22 17:59 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Description Christian Neubauer 2008-01-29 16:22:42 UTC
It would be nice if:

1.  Hooks fired for each discrete action.
2.  These hooks had a unified naming scheme.
3.  They passed parameters that make it easy to identify what the action is applying to.

Right now we have:

ArticleViewHeader - view, diff, purge, print
AlternateEdit - edit, diff, submit (both "save" and "preview")
ArticleDelete - delete
ArticleProtect - protect
ArticleSave - submit ("save")
AbortMove - "move"
WatchArticle - watch
UnwatchArticle - unwatch
MarkPatrolled - patrol
ArticlePurge - purge
PageHistoryBeforeList - history
RawPageViewBeforeOutput - raw

For the hooks that fire on a specific action, it would be nice if they were renamed to On<action> or Article<action> or whatever so they all matched.  For the ones that occur on numerous actions, it would be nice if different hooks were fired for each action with parameters that specified what the action was acting on.  For example, in EditPage->edit() where AlternateEdit is fired, the user has to do something like this to figure out the action and the actee:

function ef_OnEdit( &$editpage ) {
    global $wgRequest;
    if( $wgRequest->wasPosted() ) {
        if( is_null( $wgRequest->getVal( 'wpEdittime' ) ) ) {
            $preview = true;
            $diff = false;
        } else {
            $preview = $wgRequest->getCheck( 'wpPreview' ) || $wgRequest->getCheck( 'wpLivePreview' );
            $diff = $wgRequest->getCheck( 'wpDiff' );
        $save = ! ( $preview OR $diff );
        $oldid = $wgRequest->getInt( 'oldid' );
    } else {
        $preview = false;
        $diff = false;
        $save = false;
        $oldid = $wgRequest->getInt( 'oldid' );
        $edit = true;
    if( $diff ) {
        # Process diff action.
    } else if( $edit ) {
        $exists = $editpage->mArticle->exists();
        if($exists) {
            if( empty($oldid) ) {
                $revid = $editpage->mArticle->getLatest();
            } else {
                $revid = $oldid;
            # Process edit on an existing article with revid = $revid.
        } else {
            # Process edit on a new article.
    } else if( $preview || $save ) {
        # Process preview or save.

How about firing a hook a bit later in the function called ArticleEdit that looked like this:

if(doing a diff) {
    wfRunHooks( 'ArticleEditDiff', array( &$this, $oldtext, $newtext ) );
} else if(doing a save) {
    wfRunHooks( 'ArticleSave', array( &$this ) );
} else if (doing a preview) {
    wfRunHooks( 'ArticlePreview', array( &$this ) );
} else if (doing an edit) {
    wfRunHooks( 'ArticleEdit', array( &$this, $oldid ) );
Comment 1 Christian Neubauer 2014-04-22 17:59:21 UTC
Probably not realistic or desirable anymore.

Note You need to log in before you can comment on or make changes to this bug.