On Fri, May 30, 2008 at 1:10 AM, Jim Hu <jimhu(a)tamu.edu> wrote:
In working on my UserRightsList extension, I
encountered changes in
includes/SpecialUserrights.php that have me wondering if I'm missing
something really basic about oo programming and how I should have made
the extension. I originally wrote the Special page extension by
extending class SpecialPage and writing methods that largely
duplicated things in SpecialUserrights. For 0.5, I extended class
UserRightsPage (which didn't exist prior to 1.12) to be able to reuse
UserRightsPage::saveUserGroups( $username, $removegroup, $addgroup,
$reason = ''). This works in 1.12...
but no sooner did I announce it than I got a message that it didin't
work in 1.13a.
It turns out that in 1.13a, that UserRightsPage::saveUserGroups() no
longer passes the $removegroup and $addgroup arrays, it takes them
directly from $wgRequest.
Werdna changed this in r32610 with no particular explanation, and it
was further modified by Minute Electron with no particular explanation
in r32611 to use $wgRequest instead of a $request parameter. I don't
see why it can't be changed back to use the old interface before 1.13
is released.
The larger questions:
- Should I be avoiding this approach (extending classes in includes)
altogether?
- If not, is there a way to tell whether the parameters/behavior are
likely to be stable?
- If yes, Is there a way I should be doing this to make it less likely
to break in future versions of MW?
- Was Userrights just an outlier because it needed refactoring and now
it should be stable?
Generally speaking we try to maintain correct behavior for hooks, and
for the interfaces of widely-used classes like Title, but we don't
have any strict policies on any of this stuff. I don't think anybody
is going to really notice, generally, if an interface is changed for a
class that isn't particularly meant to be used outside of that
particular file.