Page MenuHomePhabricator

Add hooks to SpecialListusers.php to allow for expansion of it's use, without hacking core.
Closed, ResolvedPublic

Description

Patch to MediaWiki 1.12 (r29412) to add the hooks.

I've seen a few example cases, and one live case where users have wanted, or are using a altered version of [[Special:Listusers]]. Unfortunately, this always means that they are required to hack the core code, and need to re-hack it whenever they upgrade.

People can use shared users, add sso systems with more user data, and expand the data on a user all without hacking core. Unfortunately, if they want to change the data displayed on the user list, then they have to hack core to do it. It would be nice to be able to do that, without making upgrades tougher.

I made a patch which introduces 5 new hooks to includes/SpecialListusers.php:
SpecialListusersQueryInfo: Allows for chaning/expanding the sql query array.
SpecialListusersFormatRow: Allows for changes to the output of the user rows.
SpecialListusersHeaderForm: Allows for additions to the header form.
SpecialListusersHeader: Allows for additions to the header outside of the form.
SpecialListusersDefaultQuery: Allows for new defaults to the default query.

If you want some example use cases where this could prove useful:

Filtering out global users and displaying local users:
Wikia is a good example of this. They've got thousands of users, but they are all spread out over thousands of wiki. As a result the list users page got to be extremely large, and near useless because 99% of the users on a wiki's user list weren't part of the wiki. So they did some work and made the listusers page filtered. Unfortunately, this required the hacking of the core code, and now work needs to be done to put it back during every upgrade. If the hooks were added, this kind of thing could be done using hooks instead, and no core hacking would need to be done on upgrades.

  • SpecialListusersQueryInfo would allow for filtering of the SQL query.
  • SpecialListusersHeaderForm would allow for an option to disable the filtering using an extra option.
  • SpecialListusersDefaultQuery would be used to add a default option to have filtering on.

Adding user data from a sso:
Sometimes a site using a SSO may actually use different user names for global SSO users, than for local wiki users. Or they may have links to central profiles, or other user data they would like to show up on the listusers special page.

  • SpecialListusersQueryInfo would allow for extra querying on needed data like a user_id, or perhaps some table data that identifies what sso user the account is linked to.
  • SpecialListusersFormatRow would allow the extra data such as user data, global names, or links to a central profile to be added to the row.

Filtering out spam usernames:
Sometimes a wiki is hit by users who just create a user with a vandalized username, just to vandalize the listusers page. Unfortunately, on some sites a shared database is used, or there is some other limitation that stops them from being able to rename or delete these names, and the listusers page becomes a vandalized page which can't be cleaned. However, it would be possible for a extension to filter out these names from displaying in the listusers page.

  • SpecialListusersQueryInfo would be used to add a query, which in conjunction with either a new column in the user table, or a shared table with a list of users to not show would allow selected users to be excluded from listing.

If you're wondering a use of SpecialListusersHeader, it could be used for various uses. Perhaps something like a notice on the page, or adding some other type of option outside of the form (below it, instead of inside the form to the left of the submit link). Or, something like a form for quick user promotion could be added through a hook by adding the form input here, adding the checkboxes with SpecialListusersFormatRow and then using an existing hook which works before page output to add the opening and closing form tags.


Version: 1.12.x
Severity: enhancement

Attached:

Details

Reference
bz12542

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:02 PM
bzimport set Reference to bz12542.
bzimport added a subscriber: Unknown Object (MLST).

Ok, just to note. Unlike my last patch, I did make sure that this works before I posted this.

Modified version of patch applied in r31453.

Added missing RELEASE-NOTE in r34197.