Commit graph

181 commits

Author SHA1 Message Date
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
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
2024-10-16 20:58:33 +02:00
jenkins-bot
c09ac42243 Merge "build: Use inline ignore for MediaWiki.Usage.DeprecatedGlobalVariables" 2024-10-05 15:59:19 +00:00
James D. Forrester
53b67ae0a6 Add namespace to remaining parts of Wikimedia\ObjectCache
Bug: T353458
Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
2024-09-27 16:19:10 -04:00
Umherirrender
c7cd5399e7 build: Use inline ignore for MediaWiki.Usage.DeprecatedGlobalVariables
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
2024-09-26 18:15:32 +00:00
Umherirrender
6eec17e9a9 Add missing documentation to class properties (miscellaneous classes)
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
2024-09-14 10:12:18 +02:00
Ebrahim Byagowi
aa16b5e7e6 Avoid use of deprecated wfExpandUrl in various places
Bug: T319340
Change-Id: I98e8e3a8fd135a554a85f6399033756c88ea415f
2024-09-09 20:55:52 +00:00
James D. Forrester
bc662aec9b Move Language and friends into Language namespace
Bug: T353458
Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
2024-08-10 13:36:30 +02:00
Ebrahim Byagowi
fab78547ad Add namespace to the root classes of ObjectCache
And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
2024-07-10 00:14:54 +03:30
Lucas Werkmeister
590bca6dd8 Linker: fix typo in statslib migration
Bug: T359242
Change-Id: Iac15a246655a31d6c6dcfafbb0e5a11e5e5b42fc
Follows-Up: If545df3079f42605c74eeee2cd58b3359e1a9d96
2024-06-21 16:06:06 +02:00
Amir Sarabadani
bb6c6e4174 schema: Drop old pagelinks columns
It has been dropped in production already.

Bug: T299947
Change-Id: I8ec1e7d9224c81d6494c39c78df9e4bdac38d377
2024-06-18 21:13:38 +02:00
Bartosz Dziewoński
da1c476b8f Add "implements/extends Stringable" to more classes and interfaces
Follow-up to ccd423225f,
which missed some classes and all interfaces.

Change-Id: Ida0477d548c767f116eb8f465090a19f7986f7ca
2024-06-13 16:06:14 +02:00
Bartosz Dziewoński
7c292ac44a Fix Linker::makeExternalLink build failures
* 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
2024-06-11 01:20:32 +02:00
C. Scott Ananian
b855c62f66 Move Linker::makeExternalLink() to the LinkRenderer service
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
2024-06-10 18:47:32 +00:00
jenkins-bot
ed10e9dbfb Merge "Remove TemplateLinksSchemaMigrationStage config" 2024-05-28 11:45:51 +00:00
Ebrahim Byagowi
14b4269d83 Add namespace and deprecation alias to Xml and XmlSelect
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
2024-05-16 15:23:14 +03:30
Umherirrender
420e071271 Remove TemplateLinksSchemaMigrationStage config
Bug: T299417
Follow-Up: I906e069a63d1dae14924c72318b22b16244371d6
Change-Id: Ia5f730af82f904bd42552e6c6a5c4dadf2454d3a
2024-05-15 22:27:44 +02:00
C. Scott Ananian
ab660966d2 Remove deprecated Linker methods
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
2024-05-15 15:18:07 +00:00
Bartosz Dziewoński
2b58278477 Remove DummyLinker
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
2024-05-13 20:18:28 +02:00
C. Scott Ananian
4eea3324d7 Linker: add deprecation warnings for Linker::generateTOC()
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
2024-05-07 14:15:32 +01:00
Thomas Arrow
70a9135593 Migrate rollbackconfirmation events to statslib
Bug: T359242
Change-Id: If545df3079f42605c74eeee2cd58b3359e1a9d96
2024-05-04 15:39:31 +01:00
Taavi Väänänen
22fd28def5
Linker: Inline deprecated User::canSendEmail()
Change-Id: I3bc1ab3fa24ccec8e2c9643e50c31667ba71cef0
2024-05-03 15:27:36 +03:00
Umherirrender
8d97313f81 Fix some line indent
Change-Id: I8f82724197d20f9289d80e138d80310f1eab29f2
2024-04-20 00:25:15 +02:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00
jenkins-bot
121ce8b620 Merge "Deprecate Linker::generateTOC() and related methods" 2024-03-08 14:13:47 +00:00
jenkins-bot
7f418f20cf Merge "Deprecate Linker::makeHeadline()" 2024-03-08 14:09:52 +00:00
jenkins-bot
ab3f8bd6fa Merge "Remove taint-check annotation from 2nd param of Linker::makeExternalLink" 2024-03-07 21:30:30 +00:00
Bartosz Dziewoński
94ac2ba845 Deprecate Linker::generateTOC() and related methods
Move the code to private methods in the only place that needs it.

Change-Id: I7aa038e055adc1aea9faafd17b86e304ee2ca758
2024-03-07 19:57:35 +00:00
Bartosz Dziewoński
87ac02d3a6 Deprecate Linker::makeHeadline()
Move the code to a private method in the only place that needs it.

Change-Id: Ie68a5324b2c789f44ffc495d05eb6957234cb9c8
2024-03-07 19:57:27 +00:00
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05:00
Subramanya Sastry
e55cc517da Move Parser to Mediawiki\Parser namespace
Bug: T166010
Co-Authored-By: Daimona Eaytoy <daimona.wiki@gmail.com>
Co-Authored-By: James Forrester <jforrester@wikimedia.org>
Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org>
Change-Id: I79b4e732c45095eedbaa80afa5eb7479b387ed8a
2024-02-16 09:18:38 -05:00
James D. Forrester
eeb5a740b3 Namespace Message, move to appropriate directory
Bug: T353458
Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
2024-02-14 15:10:36 -05:00
jenkins-bot
ebb6c275ee Merge "logging: Clarify meaning of userToolLinks($edits) parameter" 2024-02-14 13:32:19 +00:00
jenkins-bot
7d0385a46d Merge "Linker: Fix strange word break in comment" 2024-02-13 19:49:56 +00:00
Timo Tijhof
3b79889fc9 logging: Clarify meaning of userToolLinks($edits) parameter
== 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
2024-02-13 19:41:54 +00:00
Ed Sanders
b065e1632a Linker: Fix strange word break in comment
Also remove unnecessary adjective "funny".

Change-Id: I25afb2e1aa6d3b833930443ad69d0fd61a3f33e8
2024-02-13 18:51:44 +00:00
Bartosz Dziewoński
a7562f9355 Deprecate DummyLinker
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
2024-02-09 00:27:23 +01:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Daimona Eaytoy
559e055501 Remove taint-check annotation from 2nd param of Linker::makeExternalLink
Added in If4071e689f476d2138d8964598c5a02b09448677, but made unnecessary
by the special-casing added in
I13781a059695a3dd3d0774438404408c5b20dbee.

Change-Id: Iea5512c192823fcc1b0777f46bdbd31a03b93cc7
2024-02-02 02:39:25 +01:00
Bartosz Dziewoński
e4c7272976 Change uses of getDBLoadBalancerFactory() to getConnectionProvider()
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
2024-01-22 22:27:45 +01:00
Novem Linguae
5e4bf53ac7 Improve LinkRenderer->makeKnownLink() documentation
Change-Id: I2b3cf46282b74744fc414d883312a698965b5463
2023-12-30 03:18:52 -08:00
Fomafix
e48ef8decf Make function Linker::getUploadUrl public
This allows to use this function in extension Phonos in change
I0d268d755364e9e12ecbca214590bc755917f56e.

Bug: T347682
Change-Id: I7f824cd6d4e1c1918756fa5a8bc31f9029faf127
2023-12-05 16:28:07 +00:00
C. Scott Ananian
3bded6596a LinkTarget: extend LinkTarget interface from Parsoid and use LinkTargetTrait
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
2023-11-22 14:46:54 -05:00
Derk-Jan Hartman
5bc33966ec Ensure framed/unscaled SVG transclusions have srcset
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
2023-11-10 09:17:06 +01:00
Gergő Tisza
0ad9f5efa5
Linker: Split userToolLinks() so it's easier to add extra tools
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
2023-10-22 17:03:20 -07:00
jenkins-bot
c1981a8d65 Merge "Move Article::getRedirectHeaderHtml() to LinkRenderer::makeRedirectHeader()" 2023-09-26 19:35:18 +00:00
Daimona Eaytoy
ebb742d04f Add second batch of taint-check annotations
Based on taint-check's MediaWikiSecurityCheckPlugin.php.

Bug: T321806
Change-Id: I1c86215afb531de03eae0c583de6b2866e50f9eb
2023-09-23 18:18:17 +02:00
C. Scott Ananian
07b396d5b5 Move Article::getRedirectHeaderHtml() to LinkRenderer::makeRedirectHeader()
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
2023-09-22 17:08:17 -04:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
James D. Forrester
468e69bccc Namespace Sanitizer under \MediaWiki\Parser
Bug: T166010
Change-Id: Id13dcbf7a0372017495958dbc4f601f40c122508
2023-09-21 05:39:23 +00:00
jenkins-bot
4d1e278105 Merge "Migrate another major batch to SelectQueryBuilder" 2023-09-20 13:39:17 +00:00