Commit graph

17 commits

Author SHA1 Message Date
Aaron Schulz
d268230451 Cleanup UserGroupMembership::insert() and make it more atomic
Bug: T229456
Change-Id: Ibf7900dd9273d3befb5c7f0c4ed46b65bd3b0ae4
2019-08-01 17:18:36 +00:00
Aaron Schulz
f72ae0f6e6 Switch various LoadBalancer::getConnection() callers to getConnectionRef()
This is the preferred method as it enforces read-only mode for DB_REPLICA
and handles LoadBalancer::reuseConnection() calls automatically.

Change-Id: Iab9439ba8e0810fa14c302661ed7a3534f6bfc0d
2019-07-12 10:56:30 -07:00
jenkins-bot
c5d375161a Merge "Reduce contention of getScopedLockAndFlush() callers by using the DB domain in the key" 2019-07-11 22:47:11 +00:00
Aaron Schulz
d4cb1968c8 Reduce contention of getScopedLockAndFlush() callers by using the DB domain in the key
Change-Id: Ie9fb6a9ff384c72cca559f74d8e409d108207ae3
2019-07-11 22:23:09 +00:00
Aaron Schulz
9e8ad1a560 Optimize JobQueue utilization in UserGroupMembership::insert()
Change-Id: I20d6d753221616817150f34307a8ffaf1bb74ae8
2019-07-05 16:27:43 -07:00
Derick Alangi
212d303e19 Replace use of deprecated methods in Linker and SkinFactory classes
Methods replaced are Linker::link() and ::linkKnown() and ::getDefaultInstance
in SkinFactory with mediawiki services.

Change-Id: Ifc170abc958add28a2fe08aa0c44af83c6f7cad8
2019-05-08 18:06:05 +00:00
Max Semenik
abe2167b67 user: Ensure returned user groups are sorted
Without it, Special:UserRights sometimes fails with a bogus conflict error
just because groups are somehow ordered differently.

Bug: T164211
Change-Id: I9c7f51338e0849d9e134dc780eb13c542960c655
2018-12-22 07:38:51 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Reedy
f22a83c3b0 Remove else from UserGroupMembership
Change-Id: I7c18df1cab69df5f124c95b1ddb241e3f1be5927
2018-05-18 19:52:40 +00:00
Eddie Greiner-Petter
fb1333c508 purgeExpiredUserrights: Show number of rows purged
Show the number of rows purged when running
maintenance/purgeExpiredUserrights.php

Bug: T176754
Change-Id: I091042baef8982c108b17126cde4998fc9a0cd6d
2018-03-03 15:36:34 +00:00
Eddie Greiner-Petter
edba39ab60 Be more db-friendly when purging expired userrights
Each expired row has to be fetched from the user_groups table, deleted
from that table and added to the user_former_groups table.  Per Jaimes
request, let's not do this for all rows at once but for smaller chunks
and wait for replication to catch up after each chunk has been
processed. In addition the function to purge the expired rows now sets a
lock so that there won't be multiple concurrent runs.

Also, cleaning this table up isn't urgent and thus should be done in a
job and not a deferred update, so let's move it there.

Bug: T176754
Change-Id: I671d4b9d09677a2f474477ba7fea33a44d6318aa
2018-02-14 09:02:33 +00:00
Thiemo Mättig
2e94e4d790 Document "arrays of UserGroupMembership objects" as such
Change-Id: I3c60fb977a329e39933d50e275a738296bc17599
2017-12-27 12:53:17 +00:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
This, that and the other
f8008a7cb8 Remove $wgDisableUserGroupExpiry feature flag
This feature flag was added to comply with WMF's schema change policy.
It is no longer needed now that the feature is enabled on WMF sites.
External MW installations will run update.php or manually do DB updates
as required before upgrading MW.

Bug: T162517
Change-Id: I5b532d79fd1e8b178490cf2617499ae62967de2c
2017-05-06 20:50:42 +10:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
This, that and the other
894b319b2f Don't return expired user groups in UserRightsProxy
Also add a missing type hint in UserGroupMembership.

Bug: T156779
Change-Id: Ica31541f59115db3db92de82592e6a9422082bba
2017-01-31 21:24:20 +11:00
This, that and the other
73224f4f8b User group memberships that expire
This patch adds an ug_expiry column to the user_groups table, a timestamp
giving a date when the user group expires. A new UserGroupMembership class,
based on the Block class, manages entries in this table.

When the expiry date passes, the row in user_groups is ignored, and will
eventually be purged from the DB when UserGroupMembership::insert is next
called. Old, expired user group memberships are not kept; instead, the log
entries are available to find the history of these memberships, similar
to the way it has always worked for blocks and protections.

Anyone getting user group info through the User object will get correct
information. However, code that reads the user_groups table directly will
now need to skip over rows with ug_expiry < wfTimestampNow(). See
UsersPager for an example of how to do this.

NULL is used to represent infinite (no) expiry, rather than a string
'infinity' or similar (except in the API). This allows existing user group
assignments and log entries, which are all infinite in duration, to be
treated the same as new, infinite-length memberships, without special
casing everything.

The whole thing is behind the temporary feature flag
$wgDisableUserGroupExpiry, in accordance with the WMF schema change policy.

The opportunity has been taken to refactor some static user-group-related
functions out of User into UserGroupMembership, and also to add a primary
key (ug_user, ug_group) to the user_groups table.

There are a few breaking changes:
- UserRightsProxy-like objects are now required to have a
  getGroupMemberships() function.
- $user->mGroups (on a User object) is no longer present.
- Some protected functions in UsersPager are altered or removed.
- The UsersPagerDoBatchLookups hook (unused in any Wikimedia Git-hosted
  extension) has a change of parameter.

Bug: T12493
Depends-On: Ia9616e1e35184fed9058d2d39afbe1038f56d7fa
Depends-On: I86eb1d5619347ce54a5f33a591417742ebe5d6f8
Change-Id: I93c955dc7a970f78e32aa503c01c67da30971d1a
2017-01-27 09:24:20 +00:00