On Wed, May 28, 2008 at 6:17 AM, raymond@svn.wikimedia.org wrote:
Remove link to Special:Userrights for the moment as $wgUser->isAllowed( 'userrights' ) seems to strict in some cases
I think you want $userrights->userCanExecute( $wgUser ). In fact, that's the generic way to check for permissions on special pages, although in all other cases I know of it just falls back to User::isAllowed.
The catch is that you'll have to instantiate a SpecialPage object, although you won't actually be visiting the special page. It looks like it should work, from reading the code, although you might want to initialize UserrightsPage::$isself to true rather than false.
Simetrical schreef:
I think you want $userrights->userCanExecute( $wgUser ). In fact, that's the generic way to check for permissions on special pages, although in all other cases I know of it just falls back to User::isAllowed.
The catch is that you'll have to instantiate a SpecialPage object, although you won't actually be visiting the special page. It looks like it should work, from reading the code, although you might want to initialize UserrightsPage::$isself to true rather than false.
Alternatively, you can do @UserrightsPage::userCanExecute($wgUser); (the @ is necessary to suppress the E_NOTICE about calling a non-static function statically) and pray userCanExecute() doesn't dereference $this.
Roan Kattouw (Catrope)
On Wed, May 28, 2008 at 1:00 PM, Roan Kattouw roan.kattouw@home.nl wrote:
Alternatively, you can do @UserrightsPage::userCanExecute($wgUser); (the @ is necessary to suppress the E_NOTICE about calling a non-static function statically) and pray userCanExecute() doesn't dereference $this.
Suppressing errors left and right when is a bad idea unless there's really no better way to do it. You suppress all the important errors as well as the one you don't care about; it can hide problems. And userCanExecute() does use $this, anyway.
Simetrical schreef:
Suppressing errors left and right when is a bad idea unless there's really no better way to do it. You suppress all the important errors as well as the one you don't care about; it can hide problems.
That's true. I was gonna suggest to make userCanExecute static first, but that'd probably cause breakage all over the place.
And userCanExecute() does use $this, anyway.
Surprising.
Roan Kattouw (Catrope)
On Wed, May 28, 2008 at 6:08 PM, Roan Kattouw roan.kattouw@home.nl wrote:
Simetrical schreef:
Suppressing errors left and right when is a bad idea unless there's really no better way to do it. You suppress all the important errors as well as the one you don't care about; it can hide problems.
That's true. I was gonna suggest to make userCanExecute static first, but that'd probably cause breakage all over the place.
Doubtful, most likely just some changes in SpecialUserrights.php and SpecialPage.php. However, you'd have to be careful with inheritance, since self:: doesn't work with inheritance in PHP (it calls the method from the class where the current method is defined, even if it's being executed from a child class).
Simetrical schreef:
Doubtful, most likely just some changes in SpecialUserrights.php and SpecialPage.php. However, you'd have to be careful with inheritance, since self:: doesn't work with inheritance in PHP (it calls the method from the class where the current method is defined, even if it's being executed from a child class).
Wouldn't an extension that overrides that function cause an error because they try to override a static method as non-static?
Roan Kattouw (Catrope)
On Wed, May 28, 2008 at 6:18 PM, Roan Kattouw roan.kattouw@home.nl wrote:
Wouldn't an extension that overrides that function cause an error because they try to override a static method as non-static?
If any overrides it, yes. It's fairly new and not terribly useful. Anyway, I don't see a big problem in instantiating the object, honestly.
wikitech-l@lists.wikimedia.org