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
This avoids addition of new code with the deprecated global,
or at least it gives extra attention on review when new code also uses
the inline ignore
Change-Id: I5c1bc5a1685c28f153d4fbe3525959930f54b557
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
And deprecated aliases for the the no namespaced classes.
ReplicatedBagOStuff that already is deprecated isn't moved.
Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* Add a @param-taint annotation to avoid new false positives (T367127)
* Add a fallback to Special:Badtitle when $wgTitle is null
Follow-up to b855c62f66.
Bug: T367127
Change-Id: I554aecb77c7c8401d28377d35789950b45082a24
Move Linker::makeExternalLink to the LinkRenderer service, as has been
done with the other static methods of Linker.
In order to allow phan's SecurityCheckPlugin to perform a more accurate
analysis of taintedness, tweak the API of Linker::makeExternalLink to
clearly indicate via the type system whether the link text has already
been escaped or not: a `string` argument will always be escaped, and
if the argument is already escaped it should be passed as an HtmlArmor
object. In refactoring, `Message` arguments were also common, and accept
them as-is to avoid the caller having to think about whether to call
Message::text() or Message::escaped().
This allows us to provide a more precise taint type to the $text argument,
avoids an opaque boolean argument, and avoids spurious errors from
SecurityCheck.
We also require the caller to explicitly pass a Title context, instead
of implicitly relying on the global $wgTitle. This works cleanly
everywhere except for CommentParser, which has a $selfLinkTarget which
generally works as the title context for the external link, but which
is nullable. The original Linker::makeExternalLink() used $wgTitle as
a fallback, but $wgTitle can also be null in some circumstances. The
title context only determines how $wgNoFollowNsExceptions is handled,
so existing code basically just ignored $wgNoFollowNsExceptions when
$wgTitle was null, which isn't terrible. A future refactor could/should
clean up CommentParser to ensure that there is always a non-null title
context that can be used.
Change-Id: I9bcf4780f388ba639a9cc882dd9dd42eda5736ae
This patch introduces a new namespace declaration,
MediaWiki\Xml and adds Xml and XmlSelect to it
and establishes class aliases marked as deprecated
since version 1.43.
Bug: T353458
Change-Id: I45cccd540b6e15f267d3ab588a064fbeb719d921
The removed tests in LinkerTest were ported (or were previously
ported) to the new CommentFormatter framework in the CommentParserTest
class; some references to the LinkerTest class have been removed since
CommentParserTest is now the canonical location for these.
Cleaned up a bit more from the removed DummyLinker class as well
(I69689b2037269af3320b6203fc44755f93713489).
Followup-To: I69689b2037269af3320b6203fc44755f93713489
Change-Id: Ia743d13c4fe7f4e3e2bd11274895a261adbfd8e2
DummyLinker existed for backwards-compatibility with a few hooks that
have since been removed, e.g. 'LinkBegin'. The last hook using it is
'ImageBeforeProduceHTML', and it looks like it can be harmlessly
replaced there with `null` (none of the extensions implementing the
hook use this parameter).
Change-Id: I69689b2037269af3320b6203fc44755f93713489
This method was already deprecated and may be removed in 1.43; ensure
that it generates deprecation warnings if used in 1.42.
Change-Id: I3da9cebd70627e4232ddefd6220b81dd1c65ae81
== Optional ==
It was described as "optional" but it's not a "typical" optional
parameter because its presence has non-trivial consequences on the
output in a way that can't be ignored by callers.
It sounded like passing it would be faster for cases where the caller
has computed it already and can pass it to allow re-use, and
otherwise the function will compute it on-demand, but behave the same
way logically. Except, that isn't true at all.
== Null fallback ==
Replace the overcomplicated `intval( $edits ) === 0 && $edits !== 0`
expression with an explicit `=== null` check. The old logic actually
also accepted values that cast to zero, but are not zero.
This originates from a misunderstanding in a 2012 code review,
where it was suggested to use `(int)` on the non-null before
returning it. But this author did not do that, and instead created the
above complicated conditional. [1]
Change 26457, PS2:
> ```
> $count = !is_null( $edits ) ? $edits : $user->getEditCount();
> ```
> Should `? $edits` be `? intval( $edits )`?
Change 26457, PS3:
```
if ( intval( $edits ) === 0 && $edits !== 0 ) {
$edits = $user->getEditCount();
}
```
I believe the intention of the reviewer was:
```
$count = $edits !== null ? (int)$edits : $user->getEditCount();
```
[1] https://gerrit.wikimedia.org/r/c/mediawiki/core/+/26457/2
== Redundant null ==
Follows-up I62faf9d042a92. Remove another redundant ternary from
a UserEditTracker caller, in LogFormatter, as getEditCount() already
returns `int|null` based on User->getId().
Change-Id: Iaf68ec373f2458554cd028844e6531244cd28356
DummyLinker existed for backwards-compatibility with a few hooks that
have since been removed, e.g. 'LinkBegin'. The last hook using it is
'ImageBeforeProduceHTML', and it looks like it can be harmlessly
replaced there with `null` (none of the extensions implementing the
hook use this parameter). Let's try deprecating it.
Change-Id: I73549afdafd681fc238e825f03bff329a65a3f47
Added in If4071e689f476d2138d8964598c5a02b09448677, but made unnecessary
by the special-casing added in
I13781a059695a3dd3d0774438404408c5b20dbee.
Change-Id: Iea5512c192823fcc1b0777f46bdbd31a03b93cc7
Update cases where one of the IConnectionProvider methods is called
immediately.
This doesn't really change anything, but I hope it helps promote
getConnectionProvider() as the common way to do this.
Follow-up to 8604c384f6.
Change-Id: Id0e7d02bab0c570343c2b1f03c70b44ee39db112
This allows to use this function in extension Phonos in change
I0d268d755364e9e12ecbca214590bc755917f56e.
Bug: T347682
Change-Id: I7f824cd6d4e1c1918756fa5a8bc31f9029faf127
This ensures that Parsoid and core can communicate using a common
interface. By reusing Parsoid's trait it also eliminates code duplication
between LinkTarget, Title, and TitleValue.
Even though Parsoid's LinkTarget interface is identical to core's, I've
elected not to leave an empty LinkTarget interface in core but instead to
(re)define the interface methods in order to make core slightly more
self-contained and avoid the need for core hackers to consult the
Parsoid codebase for the definitions of LinkTarget methods.
A small number of types in core were broadened to accept a Parsoid
LinkTarget instead of just a core LinkTarget, but these changes should
be minimal: only core which directly communicates with Parsoid should
need to know about Parsoid's superinterface here.
Bug: T296023
Depends-On: Id6ad5ac3b8d1c21c129fa94c10879a1632ed4b47
Depends-On: I59794e98c9881aff3ea6a258bf7d1660a203eb84
Depends-On: Ifc14c0ffc43c7939a6e6b55e00fe2f453fa143a1
Change-Id: I9adc349b230834827b002f412dcc697b44773abe
When using the frame specified to transclude SVG files,
because the image was being treated as not requirering scaling,
it would also not generate high density versions of the SVG.
Instead, do not set noscale for vectorized images.
Bug: T133489
Change-Id: Ie8dbed3a4a7bb040f22d5dae867a8bc6959bb0e7
Split userToolLinks() into a method that generates an array of
tools and another that formats them into a HTML snippet, so that
callers can easily add more tools.
Change-Id: Ic5c4384d230d2837efbf22b97a278573f075f4ad
The use of Article::getRedirectHeaderHtml() has been discouraged for a
while, since WikitextContentHandler can (should) be used to insert the
redirect header. Further, since I20db09619999919bfeda997d79561d21e3bf8718
the header should be added as an extension data property instead of
directly concatenated to the HTML. Regardless, this functionality
logically should live in LinkRenderer.
Change-Id: I4d0de0e72473ae039dca420a2733bc746d8c2951