On 17.07.2011 18:09, Ryan Schmidt wrote:
The userCan hook fires off before the shortcut, so you should be using that $result = null; wfRunHooks( 'userCan', array(&$this,&$wgUser, 'read', &$result ) ); if ( $result !== null ) { return $result; }
# Shortcut for public wikis, allows skipping quite a bit of code if ( $useShortcut ) { return true; }
By setting $result in userCan, you can basically do whatever you want (Extension:Lockdown uses userCan, I believe, which is why it works properly). If for some reason you really can't or don't want to use the userCan hook, set something like $wgRevokePermissions['invalid']['read'] = true; and $wgImplicitGroups[] = 'invalid'; (so that it won't show up in group name dropdowns), but this is a really hacky workaround that abuses an implementation detail, so it might change in the future.
Thanks for the good tip. Of course I use userCan hook, however it's too large to be pasted here and a bit unpolished. In the end of my hook I have the following code:
if ($result==true) { $result=NULL; // continue further checks return true; // continue hook chain } else { return false; // deny access, no further checks }
I guess it is my mistake that I respect the chain and nullify the result? In case my extension "allows" access I honour further handlers of the same hook, which still may set $result to false. However, changing to:
if ($result==true) { return false; // allow access, no further checks } else { return false; // deny access, no further checks }
didn't help :-(.
I will debug my extension further (later). Maybe there is some mistake in my own code. Thanks for the tips, anyway. Dmitriy