Commit graph

295 commits

Author SHA1 Message Date
Reedy
53ad63aa97 RevDelList: Ensure setVisibility always includes itemStatuses in value if applicable
Bug: T387638
Change-Id: Ia01d730be672ec44dda36772cf29e2f11890553c
(cherry picked from commit ecb3175ac1c6b7d080beeb150144214ab61ddba2)
2025-03-08 01:53:49 +00:00
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
Ebrahim Byagowi
3174f797c6 Use HTML markup instead of bidi control chars in revision delete
Bug: T375975
Change-Id: Ib0ec0ac0cbd3a711694cdf1a6d20b31cac9b2a84
2024-10-03 22:24:32 +03:30
James D. Forrester
9e5c1e8ac7 Add namespace to IDBAccessObject and DBAccessObjectUtils
Bug: T353458
Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
2024-09-27 16:19:10 -04:00
Umherirrender
07db7102cc Replace deprecated LogFormatter::newFromRow/newFromEntry
Change-Id: I453ce3148a46fcb9cc5c685cee92274e0cb4f98a
2024-07-29 22:26:41 +02:00
Umherirrender
9a107e6b03 Use expression builder instead of raw sql
Bug: T361023
Change-Id: Ibf1c93ddbf8f680e8fb9442816f6fed94a069c0a
2024-07-23 23:30:45 +02:00
Umherirrender
a9adc61d35 Use RawSQLValue for some SET clauses in update/upsert
Change-Id: I03c068c4bf098ab073989a0ea32a0f87fe878727
2024-05-29 19:48:09 +00:00
Ebrahim Byagowi
64b7d2a03d Add MediaWiki\RevisionList namespace to the related classes
This patch introduces a namespace, MediaWiki\RevisionList, and adds it
to the related classes and establishes class aliases marked as
deprecated since version 1.43.

Bug: T353458
Change-Id: I1614a00dd8973c5300d95317a725cbe46e14d1af
2024-05-21 15:12:05 +03:30
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
8d748f0759 Type hint IReadableDatabase in RevisionListBase
Change-Id: If4104cc2328a86eb2b588a34426839086c7f6ebb
2024-03-14 00:10:37 +01:00
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05: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
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
jenkins-bot
8f8e1d6f85 Merge "Change more uses of getDBLoadBalancerFactory() to getConnectionProvider()" 2024-01-23 17:59:21 +00:00
Bartosz Dziewoński
4aebcfe097 Change more uses of getDBLoadBalancerFactory() to getConnectionProvider()
Some less trivial cases. Also update variable names.

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: I6657d783375fac5c7fa856b884ff1fb09285e94c
2024-01-23 16:34:45 +01:00
Amir Sarabadani
014bc61006 Remove more indirect calls to IDBAccessObject::READ_* constants
Found via (?<!IDBAccessObject)::READ_

We are planning to deprecate and remove implementing IDBAccessObject
interface just to use the constants.

Bug: T354194
Change-Id: I89d442fa493b8e5332ce118e5bf13f13b8dd3477
2024-01-23 15:42:38 +01:00
jenkins-bot
6220c90459 Merge "Replace wfGetDB with IConnectionProvider::getPrimaryDatabase" 2024-01-23 02:30:21 +00:00
Doğu Abaris
92d6875ecf Replace wfGetDB with IConnectionProvider::getPrimaryDatabase
This revision updates RevDelArchivedRevisionItem to use the
IConnectionProvider::getPrimaryDatabase method instead of wfGetDB,
which is deprecated in MediaWiki 1.39. It also adds type hints and annotations for clearer codebase and better maintainability.

- Add typing to the getIdField and getId methods.
- Improve documentation for constructor and setBits method.

Change-Id: Ic914c7afe8bdf0731a1d4f68aeefdfe77b5503ae
2024-01-22 22:34:42 +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
Daimona Eaytoy
175c0c4abf Replace more instances of deprecated MWException
Bug: T328220
Change-Id: Iba90f7f9b5766bccc05380d040138d74d5e9558a
2024-01-19 23:11:59 +00:00
Daimona Eaytoy
2520f3d1c4 Replace more usages of deprecated MWException
Bug: T328220
Change-Id: Ie9b56bcf5e962e275d80570cad98d676da505894
2024-01-19 22:01:12 +00:00
James D. Forrester
67217d08df Namespace remaining files under includes/deferred
Bug: T166010
Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
2023-11-22 10:08:53 -05:00
Amir Sarabadani
2e1cd74ad2 Migrate off wfGetDB() in more places to ICP
This function is uber-deprecated, meaning even its replacement is
deprecated, We have already migrated in static functions and more.

In this batch, all calls have been migrated that there is already a call
to MediaWikiServices::getInstance() making the migration easier. Of
course in most cases, they should eventually turn into proper service
injection but this at least makes it clear what services should be
injected.

Also removing "category" group since we are removing all groups except a
handful from mw (see T263127 for more information).

Bug: T330641
Change-Id: I90cd35ee45a37eb6e6bf7a531cc8f75effbd0328
2023-11-20 14:40:28 +01:00
Amir Sarabadani
d5adc3ca65 Mass migrate simple cases to use expression builder
Done via
'([A-Za-z_\.]+) ?(=|!=|<|<=|>|>=) ?' . (\$db(?:r|w|))->addQuotes\( (.+?) \)
to:
$3->expr\( '$1', '$2', $4 \)

And
'([A-Za-z_\.]+) IS NULL OR ([A-Za-z_\.]+) ?(=|!=|<|<=|>|>=) ?' . (\$db(?:r|w|))->addQuotes\( (.+?) \)
to:
$4->expr( '$1', '=', null )->or\( '$2', '$3', $5 \)

Bug: T210206
Change-Id: I109bf2a712bdefa9e074f775b1bee41ac5b9d665
2023-10-26 16:59:19 +00:00
Amir Sarabadani
d05fbe1c39 Introduce ChangeTagsStore::modifyDisplayQueryBuilder()
To deprecate ::modifyDisplayQuery() and unblock a lot of migrations to
SelectQueryBuilder.

Bug: T344971
Change-Id: Icb9265644bdbc0b30e2a419ae0103f0e78fe90bd
2023-09-27 13:16:10 +02:00
Amir Sarabadani
44a6dd21b3 Migrate another major batch to SelectQueryBuilder
I fixed some edge cases in the script that migrates to SQB and it
managed to fix these now.

Bug: T344971
Change-Id: I00cc9a6660d9bd4c64c976121b2121ccd7aae1f0
2023-09-20 13:32:09 +02:00
James D. Forrester
459cbb0494 Namespace remaining 'specialpage' files under \MediaWiki\SpecialPage
SpecialPageFactory is already here, but none of the others were yet.

Bug: T166010
Change-Id: I9689bf0a1ab329625e23669b99f019b96295fffd
2023-09-18 18:23:13 +01:00
Amir Sarabadani
e1b3323312 Migrate calls to wfGetDB() in static methods
wfGetDB() has been deprecated since 1.39 (or more?) and it's better to
inject LBF and call ::getReplicaDatabase() or ::getPrimaryDatabase()
which is not straightforward in classes but for static functions, there
is no way to inject the method so we can simply call
MediaWikiServices::getInstance()->getDBLoadBalancerFactory()

While I was here, I migrated one call to SelectQueryBuilder.

Bug: T330641
Change-Id: Idd2278cef647035dce05a2d461a620e145fe1167
2023-09-05 10:48:31 +02:00
Amir Sarabadani
f4e68e055f Reorg: Move Status to MediaWiki\Status\
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
2023-08-25 15:44:17 +02:00
Amir Sarabadani
e569aedde5 Introduce FileSelectQueryBuilder
So much can be cleaned up with this

Bug: T311866
Change-Id: Ia4d46679c540c731b2ae8da2f8022fd6f5b931a4
2023-08-07 19:05:34 +02:00
jenkins-bot
dc3578a910 Merge "Migrate more calls of Database::select* to SelectQueryBuilder" 2023-07-26 11:21:08 +00:00
Amir Sarabadani
7432b21816 Migrate more calls of Database::select* to SelectQueryBuilder
Using a php parser written on top of ANTLR4, done semi-automatically.

I checked everything and made adjustments.

Bug: T311866
Change-Id: I6150c6909bce8f3dbd745a26380cc0af9d9c547f
2023-07-26 13:01:28 +02:00
jenkins-bot
a2f7b4d792 Merge "revisiondelete: Use correct rev-del constants in Item/List classes" 2023-07-24 19:04:27 +00:00
Umherirrender
9edc925620 revisiondelete: Use correct rev-del constants in Item/List classes
Not use RevisionRecord constants for LogPage or File,
even the number are the same, the context should be the match

Change-Id: Icf50f48fa63144c5ac798e7453faf9cd0a1b706a
2023-07-24 17:30:57 +00:00
thiemowmde
9cc3f1f44b Turn RevDelList::getSuppressBit() into a constant
Not used anywhere else as a method. It really is just a constant.

This goes along with Icf50f48. Can be merged in any order.

Change-Id: I8270df212193c10ad35e0b735cca67b2307e535e
2023-07-24 10:46:23 +02:00
Alexander Vorwerk
d93c9001f4 Migrate more usages of Database::update() to UpdateQueryBuilder
Bug: T330640
Change-Id: I094eea810886b13d832be575d9b9df8f8e4a77ea
2023-06-09 13:36:04 +00:00
Lucas Werkmeister
15f076efca Clean up UpdateQueryBuilder usage
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
2023-06-08 12:50:37 +02:00
Amir Sarabadani
b55c501fe0 Migrate Database::update() to UpdateQueryBuilder
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
2023-06-08 12:34:20 +02:00
Bartosz Dziewoński
6ba47296d9 Fix Phan suppressions related to Title::castFrom*() and friends
There is no way to express that Title::castFromPageIdentity(),
Title::castFromPageReference() and Title::castFromLinkTarget()
can only return null when the parameter is null. We need to add
Phan suppressions or explicit types almost everywhere that these
methods are used with parameters that are known to not be null.

Instead, introduce new methods Title::newFromPageIdentity() and
Title::newFromPageReference() (Title::newFromLinkTarget() already
exists), without the null-coalescing behavior, and use them when
the parameter is not null. This lets static analysis tools, and
humans, easily understand where nulls can't appear.

Do the same with the corresponding TitleFactory methods.

Change the obvious uses of castFrom*() to newFrom*() (if there is
a Phan suppression, a type check, or a method call on the result).

Change-Id: Ida4da75953cf3bca372a40dc88022443109ca0cb
2023-04-22 16:45:09 +02:00
Tim Starling
317b460500 Fix even more PHPStorm inspections (#3)
* Inappropriate @inheritDoc usage. Arguably all @inheritDoc is
  inappropriate but these are the ones PHPStorm flags as misleading
  due to the method not being inherited.
* Doc comment type does not match actual argument/return type.
* I replaced "@return void|never" with "@return void" since never means
  never, it doesn't make sense for it to be conditional. If a method
  can return (even if that is unlikely) then @return contains the type
  that it returns. "@return never" means that there is no such type
  because the method never returns.
* Incomplete/partial/broken doc tags

Change-Id: Ide86bd6d2b44387f37d234c2b059d6fbc42ec962
2023-03-25 00:30:15 +00:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Amir Sarabadani
fa967b49ae Switch some simple use of LoadBalancer to use new LBFactory methods
Bug: T326274
Change-Id: I837f7a7b0fad4353dbd670eec609fedfd0603af1
2023-02-23 01:36:49 +00:00
Amir Sarabadani
7d8768e931 Reorg: Move HTML-related classes out of includes/ to Html/
Bug: T321882
Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
2023-02-16 20:40:01 +01:00
Umherirrender
5c564886a2 revisiondelete: Reuse LogFormatter::getComment instead of own formatting
Avoid code duplication and
allows to use the new styling if Icfb46d9 (T327538) gets merged

Remove duplication of span.history-deleted on Special:EditTags - before
this change a span.history-deleted element was nested inside another
span.history-deleted element and after this change it is not.

Change-Id: I2e27bd8e0bcca47a7734fcb6ee28c0d1e6bb5896
2023-02-09 22:38:42 +00:00
Umherirrender
e6f4dc96fe revisiondelete: Replace dynamic property Status::$itemStatuses
Creation of dynamic property Status::$itemStatuses is deprecated

Bug: T314099
Change-Id: I5fc1496aa38502143a3511a6a8a110eb9446a2a9
2023-02-04 20:31:11 +00:00
Daimona Eaytoy
c5a01d4b2e Replace some usages of MWException
These exceptions are not documented with @throws and they're really not
meant to be caught.

Bug: T86704
Change-Id: I07f32e42c6fd4bc8785bac91547858f15a9fc2a8
2023-01-26 00:10:34 +00:00
Thiemo Kreuz
df4120903d Remove now unused (bogus) cache key in RevDelRevisionList
Unused since Idbb5a5a.

Note it never worked because of a misplaced } at the end.

Bug: T238374
Change-Id: Ic8759a78d02fb5d3d600443445ba5122d512794b
2023-01-11 10:33:52 +01:00
Alexander Vorwerk
f6bd18d6c2 Split a base class out of CommentStore
so that extensions (i.e. CheckUser) can implement their own comment
store without having a lot of code duplication

basically the comment store version of I3a6486532f2ef36

Bug: T233004
Change-Id: Ib40f99e00a514d41776ce521baf113e46d37e9cd
2023-01-01 22:34:36 +00:00
Umherirrender
6442e5b1cc revisionslists: Replace deprecated Linker::revComment/commentBlock
Bug: T324906
Change-Id: I0db8521f5ea0266a41687c46d7466a97fbc21742
2022-12-11 01:40:43 +01:00