Last modified: 2014-04-22 17:59:21 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 ) ); }
Probably not realistic or desirable anymore.