Hi,
given that there are some extensions which perform edits/actions automatically (not directly as a result of user request),
I was wondering, was anyone attempting or successful at subclassing "User"?
There are some places where name of this class is hardcoded.
//Saper
Generally I would not recommend subclassing User; while you can certainly create such a subclass it will have limited utility as you can't really control how they get created easily.
Like the rest of MediaWiki, the User class is intended to be customized through extension hooks... What sort of behavior customization are you thinking of doing?
-- brion
On Sun, Oct 27, 2013 at 1:34 PM, Marcin Cieslak saper@saper.info wrote:
Hi,
given that there are some extensions which perform edits/actions automatically (not directly as a result of user request),
I was wondering, was anyone attempting or successful at subclassing "User"?
There are some places where name of this class is hardcoded.
//Saper
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Agreed with Brion here. The User class has a large mixture of functionality and is hardcoded all over the place. There are very few use cases I can think of where it would work, and even then there's no guarantee the solution will continue to work in future versions.
Brion Vibber bvibber@wikimedia.org wrote:
Generally I would not recommend subclassing User; while you can certainly create such a subclass it will have limited utility as you can't really control how they get created easily.
Like the rest of MediaWiki, the User class is intended to be customized through extension hooks... What sort of behavior customization are you thinking of doing?
Some example:
https://gerrit.wikimedia.org/r/#/c/92252/
needs https://gerrit.wikimedia.org/r/#/c/92179/ in core, that gives some method to override.
Surprisinly, it even works (rc_ip will be set to "" on AbuseFilter blocks).
//Saper
On 2013-10-27 2:45 PM, Marcin Cieslak wrote:
Some example:
https://gerrit.wikimedia.org/r/#/c/92252/
needs https://gerrit.wikimedia.org/r/#/c/92179/ in core, that gives some method to override.
Surprisinly, it even works (rc_ip will be set to "" on AbuseFilter blocks).
//Saper
Could you explain why a whole subclass of user is needed. From what I'm seeing there's little need for an actual class. And a whole lot of what looks methods copied from core and then perhaps only slightly modified (ie: non-DRY).
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://danielfriesen.name/]
Daniel Friesen daniel@nadir-seen-fire.com wrote:
On 2013-10-27 2:45 PM, Marcin Cieslak wrote:
Some example:
https://gerrit.wikimedia.org/r/#/c/92252/
needs https://gerrit.wikimedia.org/r/#/c/92179/ in core, that gives some method to override.
Surprisinly, it even works (rc_ip will be set to "" on AbuseFilter blocks).
//Saper
Could you explain why a whole subclass of user is needed. From what I'm seeing there's little need for an actual class. And a whole lot of what looks methods copied from core and then perhaps only slightly modified (ie: non-DRY).
newFrom* and friends needed to be copied over because they create instances of "User" and not of derivative class (to fix this a factory method would be needed to replace "new User" in those methods).
The only (experimental) reason for now is the little getUserIP. This is just a proof of concept, if such subclassing has any chance of working.
//Saper
I think a better way to go is to add a hook point in RecentChange::checkIPaddress()... I don't like mixing more session-related stuff into User like a getUserIP method.
-- brion On Oct 27, 2013 2:46 PM, "Marcin Cieslak" saper@saper.info wrote:
Brion Vibber bvibber@wikimedia.org wrote:
Generally I would not recommend subclassing User; while you can certainly create such a subclass it will have limited utility as you can't really control how they get created easily.
Like the rest of MediaWiki, the User class is intended to be customized through extension hooks... What sort of behavior customization are you thinking of doing?
Some example:
https://gerrit.wikimedia.org/r/#/c/92252/
needs https://gerrit.wikimedia.org/r/#/c/92179/ in core, that gives some method to override.
Surprisinly, it even works (rc_ip will be set to "" on AbuseFilter blocks).
//Saper
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Brion Vibber bvibber@wikimedia.org wrote:
I think a better way to go is to add a hook point in RecentChange::checkIPaddress()... I don't like mixing more session-related stuff into User like a getUserIP method.
Brion and everyone,
thanks for your time and your insight. I will try to hold my object oriented horses next time :)
//Saper
wikitech-l@lists.wikimedia.org