Last modified: 2009-11-07 09:59:04 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T12764, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 10764 - add hook to User::isBlockedFrom
add hook to User::isBlockedFrom
Product: MediaWiki
Classification: Unclassified
User blocking (Other open bugs)
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
  Show dependency treegraph
Reported: 2007-08-01 00:38 UTC by Thomas "Tango" Dalton
Modified: 2009-11-07 09:59 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

adds IsBlockedFrom hook to User::isBlockedFrom (1.48 KB, patch)
2007-08-01 00:38 UTC, Thomas "Tango" Dalton
adds IsBlockedFrom hook to *beginning* of User::isBlockedFrom (2.20 KB, patch)
2007-08-01 18:48 UTC, Thomas "Tango" Dalton

Description Thomas "Tango" Dalton 2007-08-01 00:38:32 UTC
Created attachment 3959 [details]
adds IsBlockedFrom hook to User::isBlockedFrom

I have attempted to write a patch to add a hook to User::isBlockedFrom (needed for an extension I'm thinking of writing). Have I done it right?
Comment 1 Rob Church 2007-08-01 01:01:36 UTC
* In general, hooks such as this would use the return value to determine whether or not to perform internal checking at all, i.e. a false return would indicate that the $blocked value is to be returned from the method

* This hook seems a little odd, given that we have hooks on Title::userCan() which should be just fine for most access control purposes

* "$this" is an object reference, and doesn't need the ampersand in front to pass by reference any more
Comment 2 Thomas "Tango" Dalton 2007-08-01 12:44:12 UTC
1) Is it necessary to take into account the return value when the hook is after the core processing?

2) I was looking at userCan() and trying to use that, but it seems user rights and blocks are completely independent of each other (not an ideal situation - it would probably be best to do away with isBlocked() entirely and just use userCan(), but that's not the way things are set up at the moment). I'm trying to write an extension to (un)block users from individual pages. It's probably possible to do using a userCan() hook, but it's much easier with an isBlockedFrom() hook.

3) Thanks! I saw it was passed by reference in another hook, so thought it was best to follow suit. Good to know it isn't required any more.
Comment 3 Rob Church 2007-08-01 17:18:56 UTC
What I meant with (1) was that the hook should be called *before* the core processing, and the default checking skipped if the hook returns false and sets a $blocked value.
Comment 4 Thomas "Tango" Dalton 2007-08-01 18:41:03 UTC
Ah. For the extension I'm writing, it's easier if it's at the end, so that's where I put it. Having it at the beginning would probably be more useful in other cases, though, you're right. It should only make my extension a couple of lines longer, so I might as well move. I'll submit a new patch in a bit. Thanks for your help.
Comment 5 Thomas "Tango" Dalton 2007-08-01 18:48:36 UTC
Created attachment 3963 [details]
adds IsBlockedFrom hook to *beginning* of User::isBlockedFrom
Comment 6 Alexandre Emsenhuber [IAlex] 2009-11-07 09:59:04 UTC
Was fixed in r57459.

Note You need to log in before you can comment on or make changes to this bug.