Commit graph

591 commits

Author SHA1 Message Date
daniel
b3b70624c9 Authority: expose user block info
Expose info about user blocks from Authority. This allows calling code
to provide more detailed information to the user about why they are
denied some action on the wiki.

Bug: T271494
Change-Id: Ia84e469888866d72752aad355292666c31e12bad
2021-06-30 13:42:21 +02:00
ZabeMath
4020306bf7 Hard deprecate User::listOptionKinds()
deprecated since 1.35 and unused.

Bug: T274211
Change-Id: I139ef1de149c94148ad07c62a8c024e4cb0ee053
2021-06-22 15:56:25 +02:00
jenkins-bot
970fc15f95 Merge "Move CRSF token generation to CsrfTokenSet" 2021-06-21 15:03:30 +00:00
Thiemo Kreuz
2ba01c7ee7 Remove some more comments that literally repeat the code
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.

Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
2021-06-18 21:23:56 +00:00
Petr Pchelko
6260074a8c Move CRSF token generation to CsrfTokenSet
Change-Id: Idf68f1cc63fb2e01e004ff353fcda026fa4ec10f
2021-06-18 12:24:19 -07:00
jenkins-bot
5028fe175d Merge "Remove User::$mEditCount and internal caching" 2021-06-18 17:57:35 +00:00
Petr Pchelko
eccd347da9 Hard-deprecate User::matchEditTokenNoSuffix
This feature was added to provide a custom error message
if the edit token was present, but trailing slashes were
stripped from it by some ASCII mangling proxy. According
to metrics this has happened 5 times last month, which
IMHO doesn't justify having special handling. Giving a
regular token mismatch error message should be good enough.

Depends-On: Ieb4f6e25a74ecaa1110c59a8d8eed3ca792f2d41
Change-Id: I85759e315581f891721dfac246daaafe956ab201
2021-06-18 09:42:24 -07:00
DannyS712
b82cf00983 Remove User::$mEditCount and internal caching
UserEditTracker now returns null for anonymous users
instead of throwing an exception.

Added new UserEditTracker::setCachedUserEditCount()
method (internal) to handle the user_editcount field
in User::loadFromRow()'s row. This now means that
the creation of one User object can set the cached
value for any other object for the same underlying user
- the alternative (just ignoring the value) would mean
that an extra database read might be needed. This is
only used for users created with a row that includes
the user id - we silently discard the value if
the row doesn't have a user id (or the user id is 0)
to avoid issues with UserEditTracker trying to fetch
the user id and potentially triggering another load.

A follow-up will simplify the UserEditCountUpdate class
to remove storing full UserIdentity objects now that
only the id is needed.

Follow-up: Ibf1482bcbcbf4d56fc06531bb3e17e2a6e3e2e6f
Change-Id: Ie3fb4887d9f2d96b32598865030351bf3bf20ce5
2021-06-18 00:25:47 +00:00
DannyS712
f0620f4297 Remove unused User::initEditCountInternal
Method was marked as @internal and doesn't need to go through
deprecation.

Change-Id: Ibfe3677d1fbeedb89482d10cf74ebf3775c7673e
2021-06-15 07:51:50 +00:00
DannyS712
5a229f691f Accept UserIdentity in code to manage edit counts
- UserEditCountUpdate: accept UserIdentity instead of User
- Move User::incEditCount() to UserEditTracker

Change-Id: Ibf1482bcbcbf4d56fc06531bb3e17e2a6e3e2e6f
2021-06-08 05:41:03 +00:00
Petr Pchelko
0dfa846653 Use null coalecing operators everywhere consistenctly.
Auto-generated with rector.

Change-Id: I4f27e10cf029bb067b7bc57d82f7a64e21ea8d42
2021-06-03 21:42:06 -07:00
Petr Pchelko
5455e58967 Deprecate File::getUser in favor of File::getUploader
Change-Id: I8a45a8fdfa827f203e6bc123cb685d02c3612bb0
2021-06-02 09:06:09 -07:00
Vlad.shapik
9763c48d17 Reapply "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName""
This reverts commit ecf826a2ee.

Reason for revert: need to edit the patch and then it will be GTG in order to finish hard deprecating of User ::getCanonicalName, ::isUsableName, ::isCreatableName

Change-Id: I2f57f56728fcbeada96dc2228f07dc8bcaa5d4f6
2021-05-31 16:01:36 +03:00
jenkins-bot
392b9e4926 Merge "Remove usages and hard deprecate User::changeable(By)Group" 2021-05-27 17:23:19 +00:00
jenkins-bot
93fd347463 Merge "Move User::changeable(By)Groups methods to UserGroupManager" 2021-05-27 17:17:34 +00:00
Ppchelko
5596e5784a Remove usages and hard deprecate User::changeable(By)Group
This commit was reverted before cause it has changed the initialization order
and broke FlaggedRevs. Now FlaggedRevs issue was addressed, so we can apply
it back.

Bug: T254838
Change-Id: Id29024caf06fcd0d7d4e039aea8142e8131d47a7
2021-05-27 13:54:29 +00:00
DannyS712
f057d2253c Replace deprecated uses of PermissionManager with GroupPermissionsLookup
In a few places where a PermissionManager is used
but only GroupPermissionsLookup is needed

Also update references to the class in PermissionManager
that referred to it as GroupPermissionLookup

Change-Id: I5d7a13900852a38768a106aeee1ce012c3a04ea2
2021-05-26 05:47:21 +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
Alexander Vorwerk
88a70e066c Hard deprecate User::getRights()
deprecated since 1.34 and unused in Wikimedia deployed repositories.

Bug: T274211
Change-Id: If00e52255b8f555f0e60584c44970c42afe0270e
2021-05-24 11:11:40 +02:00
jenkins-bot
38bf35e966 Merge "Make UserGetEmail hook more robust" 2021-05-12 09:27:00 +00:00
Thiemo Kreuz
f93efbbbee Make UserGetEmail hook more robust
When a hook handler returns something else, e.g. null, this
will be stored in $this->mEmail and cause unexpected errors
(most notably type mistatches) later. This was not a problem
as long as we didn't use strict `string` type hints. But now
we do.

Change-Id: Iae9806304d8c39496b6d8e49e700f3a2c55520db
2021-05-12 09:17:12 +02:00
Petr Pchelko
7136d671d2 Replace User::idFromName with ActorStore
Depends-On: I87fdac02a88aba52a2174949f8736a9a36d3edf7
Depends-On: I812c49009665515778cd354d6c62a17ee24f3625
Change-Id: I5369e9714a3ec653c19ad81f02402e4aa1b22553
2021-05-11 07:44:38 -07:00
jenkins-bot
334dfff732 Merge "User: Hard-deprecate the confusingly-named isLoggedIn() method" 2021-05-10 16:52:21 +00:00
James D. Forrester
6bbad15444 User: Hard-deprecate the confusingly-named isLoggedIn() method
This was soft-deprecated in 0171846c, since when all uses in Wikimedia
production code have been removed. As this is such a vital and widely-
used method, we'll want to deprecate it for at least two releases. and
so we should get this in at a time when we're willing to fix many such
uses. Why not now?

Bug: T270450
Change-Id: I8ac4a91d77c2bb748183b69b3e901cce93cbc940
2021-05-10 07:30:23 -07:00
Gergő Tisza
2e7856a67c User::getID: Be lazier when fetching UserNameUtils
Given that User::getID is a very common method, used very early
during setup (e.g. during session initialization), only load
its dependency when it's really needed.

Bug: T282320
Change-Id: I6565426e9bf7084b1a33d39b2882639a03210460
2021-05-10 15:26:24 +02:00
jenkins-bot
f13d26f2ec Merge "Use a constant for 'Maintenance script' username" 2021-05-07 01:36:16 +00:00
jenkins-bot
67d261449a Merge "Hard deprecate watchlist methods in User" 2021-05-05 17:25:02 +00:00
jenkins-bot
d7083856d9 Merge "Revert "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName"" 2021-05-05 02:45:35 +00:00
Ppchelko
ecf826a2ee Revert "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName"
This reverts commit b491279268.

Reason for revert: caused CentralAuth tests to fail.

Change-Id: Icb3ed094578df427622e0da2a7462645adcc3d6f
2021-05-05 02:14:47 +00:00
jenkins-bot
1ed7dcd022 Merge "Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName" 2021-05-04 23:35:53 +00:00
DannyS712
40eda16b0e Remove deprecated talk page message handling in User class
Most needed for moving forward with the removal of uses
of the Revision class, and remove User::getNewtalk at
the same time to be consistent. All of this code was
already hard deprecated in 1.35.

- User::getNewtalk
- User::getNewMessageLinks (could return Revision objects)
- UserRetrieveNewTalks hook (could return Revision objects)
- User::getNewMessageRevisionId (used ::getNewMessageLinks)
- User::setNewtalk (accepted Revision object parameters)

Bug: T247143
Bug: T277511
Change-Id: Ib4fd1e4cbc5ba1497658190b6c6ea3c6a5dc97f0
2021-05-04 19:21:06 +00:00
vladshapik
b491279268 Hard Deprecate User ::getCanonicalName, ::isUsableName, ::isCreatableName
Bug: T275030
Change-Id: I60689ee6519c2dbd6d000afa8ac05c3e6b7895d2
2021-05-04 21:20:50 +03:00
Gergő Tisza
926cfa3b3d Use a constant for 'Maintenance script' username
The user 'Maintenance script' is often used to perform various
automated tasks. Providing it everywhere as a string literal is
error-prone, and errors can be somewhat disruptive (e.g. with
User::newSystemUser with steal=true it can erase the credentials
of a legitimate account). Provide a constant instead.
Also replace existing uses for consistency.

Change-Id: I685a5bfe56bbf1a47f35072f7f7c8be320ee27db
2021-05-03 23:34:26 +02:00
jenkins-bot
028fa9659b Merge "Remove uses and hard deprecate wfCanIPUseHTTPS" 2021-05-03 03:18:24 +00:00
ZabeMath
73249a36ba Drop User::getGrantName()
hard deprecated since 1.36 and unused.

Bug: T277511
Change-Id: Ib47d2e3f6b9a24d3b81f86423cee4c94532b31b5
2021-05-01 09:28:31 +00:00
DannyS712
71a1f3f937 Hard deprecate UserLoadFromDatabase hook
Completely unused per codesearch, so in theory it
could be removed without deprecation, but there is
no rush

Bug: T277334
Change-Id: Id7e22c8e9f7f6ea6ed4c8c7cc10686ff58410694
2021-05-01 01:30:05 +00:00
DannyS712
5e5b5b196b Remove uses and hard deprecate wfCanIPUseHTTPS
Bug: T281598
Change-Id: I4685674921eb68f8fb540607d88d07416749bc1c
Depends-on: Ic86d68d5b328e84cdb6a0cc9f1b6adfd2ac0a604
2021-04-30 19:09:20 +00:00
DannyS712
c6216377bb Remove deprecated https-related hooks
All hard deprecated in 1.35
* BeforeHttpsRedirect
* CanIPUseHTTPS
* UserRequiresHTTPS

Also soft deprecate the wfCanIPUseHTTPS
method, which always returns true. Will
be hard deprecated once callers are updated

Change-Id: Ie6d71809d09edf6be9b8280debeb152ef7fce398
2021-04-30 11:53:18 -07:00
James D. Forrester
64898405cb build: Upgrade mediawiki-codesniffer from v35.0.0 to v36.0.0
Change-Id: I8905d0d69738a1cd6997c104080fdf128d315e8b
2021-04-29 13:00:15 -07:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
Cindy Cicalese
3069e1c428 Hard deprecate watchlist methods in User
Bug: T281187
Depends-On: Id380a5441e30041b6fb79f6ad1fc0506b6a770f9
Depends-On: Ib8bf129a8f31ca054a74a9ec07a1ca0f7ac3e68c
Depends-On: Iddcd1cbf67ad1f8e918c1da07347dd19e5f6f7d9
Change-Id: Ief54eeb149e44ca7ffb2fddb1ba7fbe0e3eb62ea
2021-04-28 23:38:27 +00:00
jenkins-bot
d47ece1e62 Merge "Move AuthManager::checkAccountCreatePermissions to Authority." 2021-04-26 21:53:51 +00:00
Petr Pchelko
1f9c3a4566 Move AuthManager::checkAccountCreatePermissions to Authority.
Change-Id: I8d223508ccec7122eef5e0bf136964ad65d64ab7
2021-04-26 14:14:43 -07:00
Petr Pchelko
f50c097b9a Keep ActorStore caches consistent on user rename
Multi-key in-memory keys for the actors is complicated
enough to have it's own small abstraction.

Change-Id: Id0e091504b71a44ce52d418c5737d64ac70495e9
2021-04-26 14:02:00 -07:00
vladshapik
9cc797695b Hard deprecate User ::isIP, ::getOptions
Bug: T275602
Change-Id: Id4be13751ca0a900e51214c1855a4624077a5a62
2021-04-26 16:10:24 +00:00
Petr Pchelko
956393d96e User::setActorId only invalidate cache if required
If the actor ID already existed for the user, we don't
need to invalidate all caches and touch the user.

Bug: T274179
Change-Id: I9d85b4584e5d30499c1a137ce22d1a4f08f47d58
2021-04-20 06:13:41 -07:00
jenkins-bot
d245e4cfbb Merge "Move watchlist-related methods from User to WatchlistManager" 2021-04-19 03:40:32 +00:00
jenkins-bot
022b38299b Merge "Remove Title from method signatures in User" 2021-04-19 02:52:51 +00:00
Cindy Cicalese
47998b0783 Move watchlist-related methods from User to WatchlistManager
Deprecate the watchlist-related methods in User.

Change-Id: I1cde60252dd0f9659c718e27c7f2193294de63cd
2021-04-19 01:47:53 +00:00
daniel
cf6e3c50dc Remove Title from method signatures in User
Bug: T278459
Change-Id: I78c6a1b57e1b8383905e6650ab16085d28a38769
2021-04-16 15:37:05 -04:00