This follows up change I608566700c, which was mainly generated by a
script. Most of the clean up here is fixing cases where it seems the
script for some reason collapsed multi-line arrays into single-line ones
and/or removed spaces after commas. A handful of other improvements are
included too (split merged conditions into ->where()->andWhere(), use
buildComparison()). In RevDelArchiveItem, a comment is restored that I
assume was removed accidentally (perhaps because the script didn’t
expect comments inside the conditions).
Bug: T330640
Change-Id: If27bafb12fdaa05d3dc1ae6da820e1630ae2742e
Follows-Up: I608566700c6d737ee986bf47dda87effc69614d6
I did this using a script written on top of antlr4 parser so it doesn't
have some clean ups a human would do but it's pretty nice already.
Bug: T330640
Change-Id: I608566700c6d737ee986bf47dda87effc69614d6
This is necessary so that EmailUser can behave as a command. EmailUser
now takes the performer as a constructor parameter; this, in combination
with the statelessness of the service, allows it to be reused for
multiple sends. Some BC code was also moved to the factory.
Bug: T265541
Change-Id: I2568359f00f429ef3ab3bfbfb803dc8e51cd8add
- Use UserEmailContact for the sender; internally, we still fall back to
User.
- Try to use Authority and UserIdentity instead of User where possible
- Replace PermissionManager with Authority
- Fix handling of block message in BC code for Special:EmailUser
(currently throwing a fatal because of return type mismatch, as the BC
code is not intercepting the Message object)
- Move the ratelimit check around the beginning of the method, instead
of running it after having pointlessly built half of the email body
- Stop using User::isBlockedFromEmailuser and add a TODO about
deprecating that method.
Bug: T265541
Change-Id: Icc06b816a553028d816e6ab1b43ad93605fd5b3f
New functions from e8dbf5f
The information is visible on the interface doc-block,
but not in the implementation doc-block, so added for convenience
Change-Id: I1e30c908526df86b385b384648047803772d2643
The new EmailUser class encapsulates logic for email-related permission
checks, so this doesn't have to be in User anymore. The two methods are
roughly equivalent, but EmailUser performs the following additional
checks:
- User::isBlockedFromEmailuser
- Ratelimiter
- onEmailUserPermissionsErrors hook
Also deprecate the EmailUserPermissionsErrors hook: after this change,
it becomes equivalent to the UserCanSendEmail hook. The only difference
is that the former also takes an $editToken parameter, but it's unused.
The hook was added in 2009 in
372ee7b344%5E%21
with TorBlock as the intended consumer. At the time, the
getPermissionsError was using the $editToken parameter, so I guess it
felt natural to pass it to the hook as well; however, the hook in
TorBlock never needed it. The method no longer needs the token as of
38c7c8f895%5E%21/#F3
in 2010, but it was never removed from the hook. Also, it's unclear why
an internal detail such as the edit token should be exposed like this.
Note that the UserCanSendEmail hook is also going to be replaced
eventually, but that'll happen in a separate patch.
Bug: T265541
Change-Id: I2492b261505886d845260e2b63c5e71966a637ce
UserTest::testUserId() was failing when run alone, because getId() was
always fetched from the database following setId(), and the test does
not write it to the database.
It passed when run with other tests since more than 7 users were present
in the database since the last truncate. Adding 'user' to tablesUsed
makes the failure reproducible.
It makes sense for setId() to mark 'id' as loaded, by analogy with
UserFactory::newFromId(). The test failure seems valid.
Fixing it in clearInstanceCache() instead of setId() seems correct to
me. There are only two callers of clearInstanceCache() with
$reloadFrom set to a field name in core and WMF deployed extensions.
So, when clearInstanceCache() is called with the name of a field to
reload from, mark that field as already loaded.
Depends-On: Iabe011bf796016b357ab2a317b810bea2568a9f5
Change-Id: Ibbf753d318a376c7c5819930dd5669d0e44eda30
Sometimes the email confirmation URL gets truncated by the email
client or during copying. The default error message warning about
token expiry isn't very helpful in that case. Add a new error
to be shown when the token does not match the expected format.
Change-Id: I6fac761efe93a863643c5e0bbcf2483529cb194f
A series of minor documentation fixes I collected in my local
dev environment over the past months. I'm not sure if it's worth
splitting this further.
Change-Id: I1ef383b40271f1513cb03d0de1fe511f4ca51ada
$body can be a string or an array containing keys text and html
for the text and html version of the email body. Update types to
match UserMailer::send().
Change-Id: Ife2f36a2ec4ccb4b9d29d70b96fb36331922e756
The motivation is to make the code less confusing. I hope this is the
case.
?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.
Change-Id: Id807affa52bd1151a74c064623b41d950a389560
User objects may hold references to service objects. They need to be
reset when services are reset between and during tests.
Change-Id: I7fe767977f1fe01d508fddf7a92ade3ec8ba2662
None are used in WMF-deployed extensions and have been hard deprecated
for multiple releases as well.
Change-Id: I62cfa22291f81295b4908192de8657a750c6716d
Introduced in 2017 with I7f14b9ca2533032 (2e5eb693) but remains
unused at WMF, and disabled by default.
Follows-up I62107789fa (9e49260fc9) which added reap to LinkCache
test cases in 2021.
Change-Id: I0654c29a671467dd6b366f462d1c09b90a273413
This patch only adds and removes suppressions, which must be done in the
same patch as the version bump.
Bug: T298571
Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
Delay the formatting of numbers/lists when the message should be shown.
That allows to use the language of the user given to the message and
avoids global state by the global variable $wgLang or it use the global
state of Message class, which needs to be fixed later.
Change-Id: I015cea3a585a647e160b94d8ef30fad5d5df6cff
The following User methods, deprecated in 1.38, have been removed:
* ::blockedBy
* ::getBlockId
Bug: T277511
Change-Id: I00e2fec4ababa3f9c12dee34c3d922d18e1c78d7
Move the User::isRegistered call into the function to let all callers
benefit from that check. This is more than an error check, it also is
business logic representing the effective default for unregistered users
which is non-obvious and benefits from being written down as part of
a central contract.
Update tests as the user must exists on the database to have
preferences.
Change-Id: Ibacdd642d03031d9659a821045788046f0187518
Dynamic property creation on PHP 8.2 raises an E_DEPRECATED unless the
class specifically allows it via the new #[AllowDynamicProperties]
attribute. The User class has stated support for dynamic property
creation, used among others by the OAuth extension, so mark it as such.
Bug: T314099
Change-Id: Ie141d9795dbc410c49e5d450945423f39fbd8164