Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead
Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a
Break one long line in SpecialPage.php
Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.
Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.
Change-Id: I1da4b272a6b28c419cc8e860d142dae19ca0bbcf
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.
Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.
For reference:
https://www.php.net/manual/en/function.get-debug-type.phphttps://www.php.net/manual/en/function.gettype.php
To keep this safe and simple to review, I'm only changing cases where
the type is immediately used in an exception message.
Change-Id: I325efcddcb58be63b1592b9c20ac0845393c15e2
In change I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83 I am planning to
make Wikimedia\Message\MessageValue use it, and we try to pretend that
it is a library separate from MediaWiki, so it makes sense to move
MessageSpecifier to the same namespace under Wikimedia\.
Bug: T353458
Change-Id: I9ff4ff7beb098b60c92f564591937c7d789c6684
In PHP 8, but not in PHP 7.4, every class with a __toString() function
implicitly implements the Stringable interface. Therefore, the
behavior of checks like "instanceof Stringable" differs between these
PHP versions when such classes are involved. Make every such class
implement the interface so that the behavior will be consistent.
The PHP 7.4 fallback for the Stringable interface is provided by
symfony/polyfill-php80.
Change-Id: I3f0330c2555c7d3bf99b654ed3c0b0303e257ea1
Motivation:
* Remove need to hardcode out-of-component files in various places.
Especially for Gerrit queries, this not only reduces effort but
also makes these files more likely to show up in the first place.
* Clarify component boundaries and ownership, e.g. when filing tasks
with a stack trace.
* Now rather than later, to avoid need for multiple class renames and
aliases when PSR-4 namespaces are applied later (T166010).
Background:
Similar to how jobs in extensions belong to that extension, the same
is true within core. There is a distinction between the JobQueue system,
and individual jobs belonging to a specific feature or component,
likewise for deferred updates, and special pages.
To make a begin with this, I propose moving the job classes to their
respective components for cases where component boundaries are already
clear. E.g. due to exclusively being queued by that same component,
being named/introduced by the same commit, being already documented
as such in component descriptions on mediawiki.org.
Bug: T364652
Change-Id: I73d6b97c6ca9f5abd29f4277d0f845426aa23bd0
* Add missing `ingroup` to class blocks (and remove from any file blocks)
as otherwise the file is indexed twice (e.g. in Doxygen) which makes
navigation on doc.wikimedia.org rather messy.
Remove duplicate descriptions from file blocks in favour of class
doc blocks. This reduces needless duplication and was often
incorrect or outdated, and helps make file headers more consistently
(visually) ignorable.
Ref https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged
* Widen `@covers` tags in phpunit tests
Given all called methods are de-facto and liberally claimed, and
that we keep the coverage limited to the subject class, it maintains
the spirit and intent by listing the class explicitly instead.
PHPUnit offers a more precise tool when you need it (i.e. when testing
legacy monster/god classes), but for well-written code, the
class-wide tag is exactly what you want.
We lose useful coverage and waste valuable time on keeping tags
accurate through refactors (or worse, forget to do so).
Tracking tiny per-method details wastes time in realizing (and
fixing) when people inevitably don't keep them in sync, and time
lost in finding uncovered code to write tests to realize it was
already covered but "not yet claimed".
Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:Widen
While at it, improve purposes and explainations of several mail-related
classes, and set `@since`:
- EmailNotification introduced in r22110 (1.11.0), git a6f6e04841,
later moved to a separate file in bf8810d6bc (Ic435bbdbb6).
- MailAddress introduced in r12082 (1.6.0, 1.5.7), git 5cfddf9a82.
- UserMailer converted to class with ::send in r26357 (1.12.0),
git 353f203ce2.
Change-Id: I1216781240bcfabdebf109cef8f995355db0f659
Wrap the links in emails in angle brackets to avoid punctuation to become part of the url.
Bug: T350535
Change-Id: Ida52f50dcf22b206a107e8e8d7a985bd9c62c39a
This skips ones that have been marked but were never in the then
RELEASE-NOTES and later HISTORY file, and so weren't properly
deprecated ever.
Change-Id: I31df2d7e83182b5bf9524237fc4a1862356bfd5a
For precedent see also change I6492f51428, I1e76d2f5ae, I98ea4670e8,
and many other results for "parse_url" in Codesearch (WMF Deployed).
This follows recent commits that clarified dependency on UrlUtils:
* I3f1d7a2da2f67a38a7d7a7b4268a93e01a01bf1e: Setup.php.
Same as before, no fallback check, because $wgServer must be valid.
* I5e36ee80e5c30e95b79bf45e7b26860cb2668d56: UserMailer.php.
Fallback to empty string, same as before.
* Id82a9fba6b3cdae3caf169eef5192766b33f0550: ParsoidHandler.php.
Change-Id: I57a8e7ea1b379779f31f562920888acc6656569e
Updating name & email addresses for Brooke Vibber.
Re-ran updateCredits.php as well so there are some new entries in
there as well.
There are a couple of files in resources/libs that will have to
be changed upstream to keep tests happy, I will do patches
later. :D
Change-Id: I2f2e75d3fa42e8cf6de19a8fbb615bac28efcd54
This reduces the mail spam making the email on page changes option much
more bearable.
Bug: T356984
Change-Id: Id6428ae6f128b20b482e4b03599492d49d7981c0
The wfParseUrl function is deprecated as of MediaWiki 1.39 and has been
replaced with the UrlUtils::parse method provided by the UrlUtils class.
List of affected classes:
- deleteSelfExternals
- UserMailer
Change-Id: I5e36ee80e5c30e95b79bf45e7b26860cb2668d56
There are a couple of user options related classes already,
and the T321527 work on dynamic defaults is going to add
even more. Let's move them into a separate namespace
to make core a bit more organized.
Old name is kept as an alias for compatibility purposes.
Bug: T321527
Bug: T352284
Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
When a page has been marked for translation or marked as reviewed, the
parameters that enotif receives include pageStatus='change', which is
the same as for revisions of a page's content. Thus the same wording in
the mail's body is used. This resulted in confusion for users ("Why did
I receive an email notification when there is no change in the page
revision history?").
This change aims to avoid that confusion by linking to the page log when
there is no revision to link to. This will at least happen for deletions
and for special changes such as those I mentioned earlier.
Bug: T115183
Bug: T145933
Change-Id: I12c09759f87f32f0df94d8441021b16e0e10c91c
Instead of replacing 1 character at a time the functions used here
can replace sequences of any length. This can dramatically reduce the
function call overhead.
Also make use of the `fn ()` syntax because we can.
Change-Id: I2dbc2271aa7847d9b687703f837cb0d850596ef0
Strings that do not need encoding like 'Foo.Bar' are already quoted;
but where the string is encoded, the character appears literally which
makes the string to fail pear/mail validation.
Bug: T344912
Change-Id: I9bce80c1c99c67a65bce1a30b1d9a77e00b0bc18
EmailUser should distinguish between pre-checking permission, and
authorizing the sending of emails, so we can call authorizeAction()
at the appropriate time. This way, rate limits get enforced
implicitly.
This change demonstrates the motivation behind Iebd62b0487a
and I0c2ce8bdf07.
Change-Id: Ic30c36f82ab142130b5f4167c13284aeed899231
empty() only makes sense when the expression it checks is possibly
undefined, otherwise it's equivalent to a truthiness check with the
additional downside of suppressing errors when it's not wanted.
Replace it with simple truthiness checks, using strict comparison when
that seems to help with polymorphic variables.
These were caught by a bespoke phan plugin.
Change-Id: I70b629dbf9e47cf3ba48ff439b18f19e839677f4
It was deprecated in 2013, and
"scheduled for removal in MediaWiki 1.23",
but never actually removed.
Now this parameter doesn't seem to be used anywhere
in the core code or in translations, so it, as well
as the associated messages, can be removed.
Follow-up to
Ibb7953741e4189127d1cd6718ac58492f254671e
and
I7d9fd90519a68dd66f99479a7c92f6c664485a9c
Change-Id: I1e8eed2f5b4421b0d387c27c9714b9ed7272a481
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.
Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
- Replace MessageLocalizer with message formatters. This is still not
very pretty, but at least now callers don't need to obtain monster
classes like RequestContext to use this service.
- Update the documentation and add a couple notes about potential future
improvements.
A subsequent patch will make the service stable for use, deprecate the
old stuff, and update the release notes.
Bug: T265541
Change-Id: Ic9b0ef7b3b410d48375836f4db565ffd46936319
- Rename methods to follow the more standard convention used for
commands.
- Update doc comments.
- Add new hooks with final method names and parameter types, to replace
the old messy hooks.
- Deprecate the remaining old hooks.
Bug: T265541
Change-Id: I609709a70fb58ce00b9f179ee4de2f6ac5e0a1cf
Changes made in this commit:
* SpecialConfirmEmail treats temp users the same as IP users:
* with no confirmation code, the page is unavailable
* with a valid confirmation code, prompt login
* Add temp user handling in EmailNotification:
* Custom message for notifications from a temp user
* Custom debug message for notifications to a temp user
Bug: T331579
Change-Id: I5c3999addf185059ef310422a6bb0f5a472c9f93
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
- Remove getTarget(). Converting a username to a user object is not a
responsibility of this command. This logic generally belongs to
callers.
- Use Authority for the sender, as we need to perform permission checks
on them. Internally, we're still converting to User.
Bug: T265541
Change-Id: Ib0cd86d97dbf1cd97dcb316480171e4fbf4a09f4
This is non-trivial because:
- "blockedemailuser" is not a real message, so it can't be passed to
StatusValue. For now, use BlockErrorFormatter to obtain a suitable
message. In the future, we should simply rely on
Authority/PermissionManager to set a message for us, but that's left
for another change.
- The hooks used here return an error in the format accepted by
ErrorPageError. There's no "official" way to do this with StatusValue.
This patch uses StatusValue::value as a temporary workaround, but
these hooks should be replaced with a new hook that uses StatusValue
for errors.
As an aside, note that ApiEmailUser passes the return value of
getPermissionsError to dieWithError(), which doesn't work in the cases
above. This is a pre-existing issue that will be fixed in another patch.
Bug: T265541
Change-Id: I84cc521b24adef6406e0378a293438d5cd7db02a