Commit graph

22 commits

Author SHA1 Message Date
TChin
1f673d8e8f Create new UserGroupManager::addUserToMultipleGroups method
Bug: T287247
Change-Id: I40f560a2143a2c0fda8cb7233d9954dc645749a3
2021-08-30 10:24:46 -04:00
DannyS712
4a82f51d17 Inject JobQueueGroup into UserGroupManager
UserGroupManagerFactory takes care of getting the
correct JobQueueGroup for the domain.

Bug: T287808
Change-Id: I548f0c52b298bfcae386ca1a427521c81dc802fe
2021-07-31 07:09:27 +00:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Ppchelko
1d3d790edb Move User::changeable(By)Groups methods to UserGroupManager
Bug: T254838
Change-Id: I5868ed76c7af2adb027bad0aab4bbc8adb6daeb2
2021-05-25 21:09:38 -07:00
daniel
fed7f0b179 Remove $actor field from UsererIdentityValue
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.

Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.

Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
2021-04-13 18:18:06 +00:00
Umherirrender
f20c0ac8bb Remove incomplete @param from test function
the @dataProvider should be a enough here

Change-Id: I36549dcac027a68244de042d48d90d4070771be8
2021-02-01 20:19:22 +01:00
Ppchelko
b4c67ac0eb Revert "Move User::changeable(By)Groups methods to UserGroupManager"
This reverts commit b68e7e10af.

Reason for revert: T273296

Bug: T273296
Bug: T254838
Change-Id: I5124ca5b20bfd247d0d96b53bf31818c1b91d021
2021-01-30 09:54:02 -06:00
Umherirrender
7691dbeca9 Add missing @param and @return to documentation in tests
Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
2021-01-22 19:57:25 +01:00
Petr Pchelko
b68e7e10af Move User::changeable(By)Groups methods to UserGroupManager
Bug: T254838
Change-Id: Idb6050a38fb48e206129c12f20a0d017cbd2b5ba
2021-01-21 08:25:26 -06:00
Thiemo Kreuz
b655f382db Remove broken/outdated @param/@throws tags from @dataProviders
My personal best practice is to not document @params when there
is a @dataProvider. I mean, these test…() functions are not
meant to be called from anywhere. They do not really need
documentation. @param tags don't do much but duplicate what the
@dataProvider does. This is error-prone, as demonstrated by the
examples in this patch.

This patch also removes @throws tags from tests. A test…() can
never throw an exception. Otherwise the test would fail.

Most of these are found by the not yet released I10559d8.

Change-Id: I3782bca43f875687cd2be972144a7ab6b298454e
2021-01-21 03:42:42 +00:00
Umherirrender
0347fd0631 Improve some function documentation in tests
Also fix some whitespaces

Change-Id: Ibed50a4f07442d3f299cf545c16f5dbb5f27a411
2021-01-14 22:13:55 +01:00
Petr Pchelko
ae0b6c6a1e Introduce GroupPermissionsLookup
In order to break up cyclic dependency between UserGroupManager
and PermissionManager, introduce a lightweight service for checking
group permissions.

Bug: T254537
Depends-On: I99ab3a69c41b3ec6721f9504ad6c77d3122df591
Change-Id: I1acd55c07d07b4a0d43fd838e11374b6d9be98d9
2021-01-06 17:12:28 -06:00
Paladox
0b4c4402e8 Fix infinite recursion with wgAutopromote when using getBlock within checkCondition
The problem was that when using $user->getBlock
within checkCondition (APCOND_BLOCKED) caused a infinite
recursion as calling getBlock eventually leads back to checkCondition.

The fix here is to stop using userHasRight as that is the cause of the recursion.

This also fixes testGetUserAutopromoteBlockedDoesNotRecurse test so it
shouldn't fail.

Bug: T270145
Change-Id: Ic751eba70730de286bbd55772bd7562459fb30b4
2020-12-17 19:57:10 +00:00
Paladox
36e2a458b6 Add test showing that getBlock can recurse if you use Autopromote and use APCOND_BLOCKED
Tests are purposely skipped and will be enabled in a follow up change.

Bug: T270145
Change-Id: I7f28bd9f5644d0f4b90927525ab93e2fac2f9d8f
2020-12-17 17:21:51 +00:00
Thalia
addb098c39 Deprecate DatabaseBlock methods moved to DatabaseBlockStore
Following 23c3c70d7f, soft deprecate the static methods on
DatabaseBlock that have been moved to DatabaseBlockStore:
* ::insert
* ::delete
* ::update
* ::purgeExpired

Update calls to the deprecated methods from core.

Change-Id: I1272eb978594fd4f386bda12cbc24131ad7d882f
2020-09-13 22:17:27 +00:00
Matěj Suchánek
51642e0aae Replace tabs with spaces
Change-Id: Id034c34a294585f58dba58c26db466e0e39cb557
2020-09-04 18:04:07 +02:00
Máté Szabó
90c2840cca UserEditTracker: Do not try to initialize edit count in read-only mode
The method UserEditTracker::getUserEditCount (as well as the old User class
logic it replaced) calculates the user's edit count and writes it to the
database if it was not computed yet. However, it attempts this write even if
MediaWiki is in read-only mode, causing errors as this method is frequently
called on read requests as well.

As a fix, move the edit count initialization to the job queue, which will avoid
trying to open a source DB connection (and thus cause a read-only error) on
installs that do not use the DB-based job queue. This change requires a
workaround in UserGroupManagerTest.

Bug: T259719
Change-Id: I6d1c8e9038ae1f98f47bdb2495aecc21654b24c0
2020-08-06 00:50:41 +02:00
Petr Pchelko
d00dfbd756 Move User::addAutopromoteOnceGroups to UserGroupManager
Additionally, User::checkAndSetTouched was made public and
marked as @internal. Eventually, as User class refactoring
continues, I would expect this to be replaced by some service.

Bug: T252621
Change-Id: I53533f494950d08ee5ed1ec54d24958c21e7b3aa
2020-06-12 12:06:10 -07:00
Petr Pchelko
cd6b72ecd7 Move autopromote groups logic into UserGroupManager
Bug: T252621
Change-Id: Ic51119cd01771ab1b68294fa5dfacb8034e33b6b
2020-06-11 22:13:48 +00:00
Clara Andrew-Wani
144157dbdb UserGroupManager: Consider $queryFlags when caching
Bug: T254282
Change-Id: I41a31ba6d597c11c7d7c8e753aa0e4c29303d5d9
2020-06-10 15:01:04 -04:00
Petr Pchelko
229acec87d UserGroupManager: add tests for coverage gaps
Bug: T234921
Change-Id: I724c153f690483a9618ccb62f142d0561713f030
2020-06-05 07:42:57 -07:00
Petr Pchelko
40b88d635b Create UserGroupManager
Introduce a UserGroupManagerFactory and UserGroupManager.
The factory utilizes the same pattern as RevisionStore
for access to user groups of a foreign wiki.

Some user group related methods were ported from User
and UserGroupMembership and deprecated, more methods to
be moved over in future patches, not to make this one to large.

Eventually as all the group-related methods are moved and their
usages are replaced, the need for the UserRightsProxy will disappear,
thus it also will be deprecated and removed. Currently for backwards
compatibility, I've had to create artificial UserIdentityValue
objects in some of the deprecated methods to avoid making transitional
temporary methods in the UserGroupManager that would take user ID
instead of the UserIdentity. All of this will go away once migration
to UserGroupManager is completed.

Bug: T234921
Change-Id: If29c6a03dfdbb80b2e846243f7e384b334da9f07
2020-06-03 16:46:51 -07:00