I'm working on a parser tag that needs to know the current user -- even when the parser tag is first inserted.
I have code like:
function tagFunction( Parser $parser, PPFrame $frame, $arg ) { $user = $parser->getUser(); if ( $user->isAnon() ) { // During writes the user isn't properly loaded. global $wgUser; $user = $wgUser; } if ( $user->isAnon() ) { throw new MWException( "No such thing as anon users on this wiki" ); } }
Without the first isAnon() check, the exception is always thrown on writes that include the tag.