Commit graph

774 commits

Author SHA1 Message Date
Umherirrender
1b29f07440 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I73fb416573f5af600e529d224b5beb5d2e3d27d3
2024-10-21 20:41:20 +02:00
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
James D. Forrester
9f02d18eac Add namespace to maintenance/includes classes
Also a few other fixes of PHP class aliases spotted by phan.

Bug: T353458
Change-Id: Ie79d65722c47c24f8f20f1293355cfd3c2e8c2ad
2024-10-09 11:02:09 -04:00
Umherirrender
ca8b1eb476 Add missing documentation to class properties (frontend-related)
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: Id75cb2e5fbee0fe7600f92473d876f23730d46b7
2024-09-05 21:41:19 +02:00
Umherirrender
eef1ff2556 logging: Hard-deprecate LogFormatter::newFromRow/newFromEntry
Depends-On: Icd3316b7f475a09390be8787fae6a8b63dcd6418
Depends-On: I007a318135db35fc82011540b3b2baf6f358b753
Change-Id: Id2c48651e1ca28146ab6bcb57c789fae69e5c251
2024-07-29 20:29:25 +00:00
Umherirrender
07db7102cc Replace deprecated LogFormatter::newFromRow/newFromEntry
Change-Id: I453ce3148a46fcb9cc5c685cee92274e0cb4f98a
2024-07-29 22:26:41 +02:00
jenkins-bot
e8e74a7a12 Merge "logging: Combine log types in one database condition on LogPager" 2024-07-20 02:13:11 +00:00
jenkins-bot
d1cb549dd6 Merge "i18n: Use local digits for users rename log entry" 2024-07-19 21:51:42 +00:00
Ebrahim Byagowi
417c1a7db4 i18n: Use local digits for users rename log entry
The issue can be spotted on the following link that number of edits
the user had before the rename isn't getting proper local number format,

https://fa.wikipedia.org/wiki/Special:Log/renameuser?uselang=fa

Change-Id: Ieb258f2363ef0f4e370aaba040c11750f3d8684f
2024-07-20 00:11:26 +03:30
Ebrahim Byagowi
24624e6382 Add a grep helper in RenameuserLogFormatter
As I had some difficulty finding where the messages are used in
the code so hopefully this will help the next person.

Change-Id: I5b6669a3c7df13f622a10f43679b88da3e3a0cd4
2024-07-19 23:43:39 +03:30
Umherirrender
eaa8b374ea logging: Combine log types in one database condition on LogPager
Use a NOT IN clause when there are more types to exclude

Old: (log_type != 'patrol') AND (log_type != 'tag')
New: (log_type NOT IN ('patrol','tag'))

Change-Id: Ib256b5be2dc2028dd50708e2e9a87b0428453a50
2024-07-18 20:17:25 +02:00
jenkins-bot
9888f1eabe Merge "MoveLogFormatter::getPreloadTitles: Handle bad titles" 2024-07-18 17:16:51 +00:00
Lucas Werkmeister
fb760c66c5 MoveLogFormatter::getPreloadTitles: Handle bad titles
If the namespace configuration changed, it’s possible that the title in
the params can no longer be parsed. In that case, we shouldn’t return a
null entry, but just an empty array instead. (I haven’t tried it out
locally, but the test suggests that the actual formatting of the row
works without issue, with the title being shown as Special:BadTitle.)

Bug: T370396
Change-Id: I6335e12efa518332f7cd2268a833f8b60b8e6abe
2024-07-18 11:49:33 +02:00
Derick Alangi
0de13f765f
logging: Use getPage() instead of getTitle()
The latter is the new way, we don't want to rely on the full Title
object these days and the former has already been deprecated.

Change-Id: Id37b1e36d5211d1218e80f8b4da420c2a65bd2fe
2024-07-13 16:17:54 +02:00
Bartosz Dziewoński
2e328a4c49 TagLogFormatter: Don't depend on Message implementation details
You're not really supposed to know how Message represents the
parameters internally.

Change-Id: Ib2f31703c3c7d50ab98d64289140a1e4296d5c63
2024-06-25 20:37:39 +00:00
Umherirrender
472891385d Use namespaced classes (2)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Id9f3e775e143d1a17b6b96812a8230cfba14d9d3
2024-06-16 20:23:55 +02:00
Bartosz Dziewoński
1321082c6e Use real type hints for services etc. in includes/page/
Mostly used find-and-replace:

Find:
/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|)
Replace with:
\3 \1 \4

More could be done, but to keep this patch reasonably sized, I only
changed the most obvious and unambiguously correct cases.

In some cases, I also removed redundant doc comments on the
constructor, and re-ordered the properties to match the constructor.

Change-Id: I7eb97640c0543ae10bf2431623a5f7efdc3349b7
2024-06-11 19:37:28 +02: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
5137fd6b1a Use functions of SelectQueryBuilder for STRAIGHT_JOIN / LIMIT
Change-Id: I0324f87ebf80f1c97ab162fcef9550fef691674f
2024-04-15 20:42:04 +02:00
jenkins-bot
5af60b4676 Merge "logging: Hard-deprecate instantiating core loggers without DI" 2024-04-05 18:28:21 +00:00
Bartosz Dziewoński
fc840bca68 logging: Hard-deprecate instantiating core loggers without DI
Bug: T356468
Change-Id: Idffbf09a32e111cf169f0e38acd178148c9bf33b
2024-04-03 18:33:39 +00:00
jenkins-bot
b3affdea7e Merge "LogFormatterFactory: Inject LinkRenderer too" 2024-04-03 18:30:14 +00:00
Bartosz Dziewoński
0b0ebabea2 LogFormatterFactory: Inject LinkRenderer too
Change-Id: I1edfc9cc4e2ad794b226b4f8be03c3846bbeb84d
2024-04-02 21:24:49 +02:00
jenkins-bot
0e5a6e2907 Merge "logging: Add LogFormatterFactory" 2024-04-02 19:07:28 +00:00
jenkins-bot
68e59fa1a9 Merge "Log duplicate translations of options-messages for HTMLFormField" 2024-04-01 20:32:57 +00:00
Dreamy Jazz
294972227e Log duplicate translations of options-messages for HTMLFormField
Why:
* When using a HTMLFormField that has accepts the options-messages
  parameter, the message keys are the key and the value is either
  an array of options or the name of the value.
* However, when converting the message key to the translated text
  it is possible for two or more message keys to have the same
  translation (for example T19746 and T347314). This causes only
  one of the duplicate items to be displayed in the options list.
* As such, an logstash error should be raised when this happens
  so that, when debugging a missing option, the error can be found
  and lead to the issue being found quickly. For example, in
  T347314 it took several months for the issue to be found and
  solved.

What:
* In HTMLFormField::lookupOptionsKeys, add code to check if the
  translated text for the message key already exists in the array
  of translated text to option value. If it does, then create a
  logstash error and skip adding the item to the array (as it
  will override the already added item).
* Also do this in LogEventsList and UsersPager, where the code
  passes the options using the 'options' key and uses the
  HTMLSelectFieldand. This means that HTMLFormField
  ::lookupOptionsKeys will not be called and as such need the
  same code to handle the duplicate values.

Bug: T360326
Change-Id: Ifdeb917f7034967feed7a3b86aabec3c4d49bcc6
2024-04-01 22:04:48 +02:00
Gergő Tisza
ce836dae7c logging: Add LogFormatterFactory
Bug: T356468
Change-Id: I8dc2ec7993d8d5268877518c86df8c604380c8a0
2024-03-30 11:37:38 +01:00
Umherirrender
63b3ee0196 logging: Inject services into LegacyLogFormatter
Bug: T356468
Change-Id: I3cc079364f9e287d9aef66a02cbaca701ec38608
2024-03-28 01:34:02 +00:00
Umherirrender
3e6a1bdd00 logging: Inject services into PageLangLogFormatter
Bug: T356468
Change-Id: I593fbd8c340aa9ea75a303115d1355f3ce96be11
2024-03-28 01:32:02 +00:00
jenkins-bot
9eaaca82f3 Merge "logging: Inject services into LogFormatter base class and use it" 2024-03-28 00:32:23 +00:00
Umherirrender
df79b6ea4f logging: Inject services into LogFormatter base class and use it
Using the same technique as used for SpecialPage base class
with setter for each used service.

Bug: T356468
Change-Id: I5269633bb7389c48f807ce164f85b21d7d5954cc
2024-03-28 00:08:52 +00:00
Matěj Suchánek
42cfe3a421 Use a different message for preloaded reason field on Special:MovePage
For many languages, I believe, it is too restrictive to require
the same message for the button text and the reason.

Additionally, this change makes the capitalization consistent
for English. Compare with "editundo" (link text) and "undo-summary"
(edit summary default text).

Change-Id: I344ca3b567b5dafbe4417228ea9e8ea27d95a45e
2024-03-20 09:38:36 +01:00
jenkins-bot
7cf65ac6c1 Merge "MoveLogFormatter: Don't show revert link if the destination doesn't exist" 2024-03-19 20:49:45 +00: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
Matěj Suchánek
c1d144e7c9 MoveLogFormatter: Don't show revert link if the destination doesn't exist
If the destination page doesn't exist anymore (moved somewhere else,
already undone, deleted etc.), the revert link will only show an error.

Change-Id: I0b449f042fa54f4f946a1d9ec87d8ee76250baa6
2024-03-15 09:26:30 +01:00
James D. Forrester
060a1b1668 Replace last remaining wfGetDB() calls in core, except ResourceLoader
Bug: T330641
Change-Id: I6d30af6ff9f667e367d39befb80c2bb0bf5fb29e
2024-02-14 11:02:01 -05:00
jenkins-bot
ebb6c275ee Merge "logging: Clarify meaning of userToolLinks($edits) parameter" 2024-02-14 13:32:19 +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
Amir Sarabadani
ea268ddcfd Move away from wfGetDB() calls
If we are serious about getting rid of wfGetDB(), we should start
replcing callers with proper replacement.

These classes don't have any injection so it doesn't make sense to
introduce it for this specific usecase.

Bug: T330641
Change-Id: I645f67324d441288c63787c7e42390b59106c585
2024-02-12 21:23:38 +01:00
Brooke Vibber
dcd9c3ae26 Update name & email for bvibber
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
2024-02-08 17:02:16 -08:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
jenkins-bot
1a66246e19 Merge "Use native str_contains/str_starts_with in a few more places" 2024-01-25 16:27:36 +00:00
thiemowmde
4e7c3ca094 Use native str_contains/str_starts_with in a few more places
This makes the code quit a bit more readable, I believe.

strpos is especially confusing because it can return false when a
string doesn't contain the needle, as well as 0 when the string
starts with the needle. This is sometimes used as a feature (i.e. to
check if a string contains the needle, but doesn't start with it),
but that's not the case here.

A slightly more complicated change is made in TitleTest. But this is
only in a test and should verify itself when the test still succeeds.

Change-Id: I355ad1dc8e1725ae7a1eb652ec047ce7ff589cdf
2024-01-25 12:17:27 +01:00
Daimona Eaytoy
7acfa6a0a5 Replace more instances of unchecked MWException
Most (all?) of the remaining usages are caught somewhere and will be
migrated later.

Bug: T328220
Change-Id: I5c36693a5361dd75b4f1e7a0bab5ad48626ed75c
2024-01-23 16:20:53 +00: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
Gergő Tisza
9de0e23b48 Support dependency injection in log formatters
Use ObjectFactory specifications instead of class names in
$wgLogActionHandlers, like in most other places. Class name
support is retained for B/C.

Also remove old LogPage code that assumed $wgLogActionsHandlers
is an array of callables. This is how $wgLogActionsHandlers was
defined in b6d72cfeb2, but then
4ac56c2466 redefined it to an
array of classnames (and I6846ce0 adjusted the documentation),
and the old functionality has been broken since.

Make LogFormatter::__construct() public so subclasses can be
created in the service wiring.

Technically this is a breaking change since there is no
guarantee existing formatter classes are publicly creatable,
but there is no way to issue a deprecation warning about that,
and it isn't really covered by the stable interface policy.
All non-public constructors found by codesearch are fixed in
companion patches.

Bug: T54220
Change-Id: I72427a4b3f4be1c3c1eb3522a8b58fe9445a3397
Depends-On: Ie691e8d59141f696619dce8f756645c45a3e943a
Depends-On: I41562247d51f4f9fe8dafed37ba2ad81c881d99d
2024-01-20 16:36:56 +01:00
Pppery
876e9883aa Allow MergeHistory to split up joined revisions with same timestamp
Bug: T183501
Change-Id: Iedd818a83838683fb07334aade11754557828062
2024-01-05 23:09:15 +00:00
Amir Sarabadani
72a7b74ea9 Migrate remaining Database::insert calls to InsertQueryBuilder
Tests are not checked.

There is nothing left as far I can check.

Bug: T353219
Change-Id: I1d58397118c7ab1110b9d7cf400c59c4bff7378c
2023-12-22 14:53:17 +01:00
Thomas Chin
a7690c5a12 Use InsertQueryBuilder in ManualLogEntry
Bug: T353219
Change-Id: Ibebb3b92f9ed6a69688a7357cec813ffc33fbd16
2023-12-12 09:05:50 -05:00
Dreamy Jazz
7684dbb33d Fix documentation for LoggingSelectQueryBuilder
Why:
* The documentation for the LoggingSelectQueryBuilder incorrectly
  states to use RevisionStore::newSelectQueryBuilder. This
  should be instead the DatabaseLogEntry::newSelectQueryBuilder.

What:
* Fix the documentation for LoggingSelectQueryBuilder::__construct

Change-Id: I6f07a771ed0aa41d29b407eb56555b8d25584b2a
2023-11-29 15:33:12 +00:00