I'm writing a ArticleAfterFetchContent hook:
$wgHooks['ArticleAfterFetchContent'][] = 'myArticleAfterFetchContent';
function myArticleAfterFetchContent (&$article) { ... }
Inside myArticleAfterFetchContent, how do I tell if the user is in edit/view source mode?
A hacky way that almost works: if (isset($article->mMinorEdit)) {...}
This works fine if the user has permission to edit, but not when I'm using the "view source" hack (user who can't edit can still view the source):
$wgHooks['userCan'][] = 'fnMyUserCan'; function fnMyUserCan ($title, $user, $action, $result) { if (($action == 'edit') && $user->isAnon()) {$result = false;} }
What's the correct way of telling if a user is edit mode, even if he's viewing the source? I don't want my hook to run in this case, because I want people to see/edit what's stored in the MySQL backend *before* my hook processes it.