Commit graph

48 commits

Author SHA1 Message Date
jenkins-bot
abc8da60be Merge "Use explicit nullable type on parameter arguments" 2024-10-16 23:10:14 +00: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
e7db78e8d6 Replace uses of deprecated ChangeTags static methods
Bug: T360664
Change-Id: I3363a225e54bb2cae01ba066d432a8b7b21933d2
2024-10-16 13:30:12 -04:00
James D. Forrester
984076f98e Add namespace to includes/api classes
Bug: T353458
Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
2024-09-25 19:31:14 +00:00
thiemowmde
dca4931b42 Make use of the ??= and ?? operators where it makes sense
This touches various production classes and maintenance scripts.
The code should do the exact same as before. The main benefit is that
the syntax avoids any repetition.

Change-Id: I5c552125469f4d7fb5b0fe494d198951b05eb35f
2024-08-26 09:26:36 +02:00
Aaron Schulz
8454bf2314 deferred: pass $fname to MWCallableUpdate callbacks and improve comments
This is more convenient for callers since they can avoid the pattern
of setting $fname to __METHOD__ and needing $fname in the "use" clause.
This is also more consistent with AutoCommitUpdate/AtomicSectionUpdate.

Remove @since tags from @internal MWCallableUpdate class.

Change-Id: I67c58897dc366a55f43e0a61d56064b26d520c17
2024-08-08 15:50:00 +00:00
James D. Forrester
b7b881aa3b WatchlistManager::setWatch: Exit if the user is a temp account
Bug: T371091
Change-Id: I3996229cf1d21acd0e10d6404cd1db056cc729ee
2024-07-26 18:33:54 +00:00
Umherirrender
8d49affda6 watchlist: Use expression builder to avoid IDatabase::addQuotes
Many unit tests needs adjust, because the ->with() call no longer
matched and using expression objects for the matching repeats the same
code between test and real implementation.

Bug: T361023
Change-Id: I6f8dbd12d7135ee28ad5b1eabb58d1354d1591d3
2024-07-18 22:34:40 +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
Kosta Harlan
20638462a7
[temp accounts] Make use of isKnown config flag
Why:

- A few places in core should check the isKnown
  flag (I4ce534a847461230f7fa276a565bdc1d6c9857e1) rather than isEnabled

What:

- Update ChangesListSpecialPage, UserGroupManager,
  UserSelectQueryBuilder, WatchedItemQueryService,
  ApiQuerySiteInfo, maintenance/expireTemporaryAccounts and
  maintenance/userOptions to used the isKnown() config check

Bug: T356524
Change-Id: I5a88808c7297752c60f6e7ffe16cf6543d783269
2024-06-14 17:26:30 +02:00
Ebrahim Byagowi
12660db261 Add MediaWiki\Watchlist namespace to the related classes
This adds MediaWiki\Watchlist namespace to the classes of watchlist
directory and adds deprecation notice since 1.43 to the just created
unnamespaced aliases of the classes.

Bug: T353458
Change-Id: I4234f8fe62bb3bde6f5271c7ba31a2420b0f4b90
2024-05-22 01:23:10 +03:30
Ebrahim Byagowi
49fe440c63 Add namespace and deprecation alias to WatchedItemStore
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchedItemStore and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I820a3512440ba5a1de13e8470ccf5845918f3198
2024-05-20 19:14:17 +03:30
Ebrahim Byagowi
8aecf94da0 Add namespace and deprecation alias to ActivityUpdateJob
This patch introduces a namespace declaration for the
Wikimedia\Watchlist to ActivityUpdateJob and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I34342bb01c8f6c9657f1b2f05de1de64a107665f
2024-05-19 21:45:47 +03:30
Ebrahim Byagowi
fe4bbc8918 Add namespace and deprecation alias to WatchedItemQueryServiceExtension
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchedItemQueryServiceExtension and
establishes a class alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I65b414013291b0ca21288b70e29530bba3f7e22e
2024-05-19 17:42:59 +03:30
Ebrahim Byagowi
1e4f59b724 Add namespace and deprecation alias to WatchedItemQueryService
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchedItemQueryService and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Ib1b5c19c89087940987730939e84c8cd35cd3760
2024-05-18 01:50:29 +03:30
Ebrahim Byagowi
03dc841a08 Add namespace and deprecation alias to WatchedItem
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchedItem and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Id2a582b624f21867240def2541c98ce5b1bd12b4
2024-05-17 13:26:36 +03:30
Ebrahim Byagowi
bd2186338c Add namespace and deprecation alias to WatchlistExpiryJob
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchlistExpiryJob and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Ia0a85c9d7550edc972ea512606dfcf272c71a6cd
2024-05-17 01:40:57 +03:30
Timo Tijhof
c68eb007ea watchlist: Move un-namespaced watcheditem classes to /includes/watchlist/
Bug: T364652
Change-Id: I264024784e8147fa421c8a13e8ae4541d8735f78
2024-05-10 21:07:20 +01:00
Timo Tijhof
b432fd2f20 Move various job classes to relevant component directories
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
2024-05-10 20:14:00 +01:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
James D. Forrester
a8a6cfd966 Namespace NamespaceInfo under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: Ibe103cd362535d3cb94cb8931e95fc74099d1497
2023-09-19 05:17:04 +00:00
Martin Urbanec
636d86a2ea WatchlistManager: Do not require watchlist rights for clearing talk page notification
A recent core patch removed `editmywatchlist` user right from
anonymous users, as those users do not have watchlist access.
It turns out WatchlistManager is also responsible for informing
TalkPageNotificationManager when should talk page notifications
be cleared.

Unlike watchlist, all users have talk page notifications,
including logged out users. Consequently, WatchlistManager
needs to inform TalkPageNotificationManager before checking
for the `editmywatchlist` permission.

Ideally, this would not be a part of WatchlistManager
at all, and callers would invoke TalkPageNotificationManager
as appropriate (or a wrapper service is introduced), but
that change is likely to trigger similar regressions, as there
can be funny & interesting callpaths.

In the interest of patch scope, ignore permission checks
for this one matter in WatchlistManager for now.

Follow-up to I1ccda3878a658d4251429ae65ebee04c09d81243.

Bug: T345031
Change-Id: Id88fd9c5e05cd7337b4cfc1abebe61a36c39f0d4
2023-08-31 17:22:16 +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
Umherirrender
11d4d33e08 Remove deprecated WatchlistNotificationManager class alias
- class MediaWiki\User\WatchlistNotificationManager
- MediaWiki\MediaWikiServices::getWatchlistNotificationManager

Change-Id: I334f10e814b2bf9ef3de6f6ea3ed5ae4ad402ae0
2023-05-13 09:55:45 +02:00
Amir Sarabadani
623d3dc419 rdbms: Move ReadOnlyMode and ConfiguredReadOnlyMode to rdbms library
The db/ directory does not have an owner and it's a mess in general.
These classes don't depend on anything in core except the rdbms library.
Let's simply move it there. In other words, Krinkle made me do it.

Since the class was moved in I6202e52ba73 merged less than a week ago,
no need to alias anything.

Bug: T321882
Change-Id: I24ceeb8bf765a50f441270136acd612359d50aa2
2023-05-04 23:41:21 +02:00
Amir Sarabadani
d59ffa4202 Reorg: Move ReadOnlyMode classes to db/
They are not suitable to go to rdbms library as they depend on mediawiki
pieces, the second best place is the db/ directory.

Bug: T321882
Change-Id: I6202e52ba7306d74261206c2ba7930c5f1a0a18e
2023-04-28 12:13:01 +02:00
Tim Starling
580ec48e5b Fix more PHPStorm inspections (#2)
* Illegal string offset and invalid argument supplied to foreach, due to incorrect type information
* Array internal pointer reset is unnecessary
* $hookData unused since MW 1.35 due to incomplete revert
* array_push() with single element
* Unnecessary sprintf()
* for loop can be replaced with str_repeat()
* preg_replace() can be replaced with rtrim()
* array_values() call is redundant
* Unnecessary cast to string
* Unnecessary ternary. Often the result relies on short-circuit evaluation, but I find it more readable nonetheless.

Change-Id: I4c45bdb59b51b243fa96286bec8b58deb097d707
2023-03-25 00:19:58 +00:00
Timo Tijhof
b765222915 watchlist: Re-centralise former wgUseEnotif condition
Follows-up I9bfa502a0b (9b8f153f). Also document the reason for
this logic, to the best of my knowledge, and some ideas to improve
it.

Bug: T305093
Change-Id: I4c5bf4d4da83ff1e03d0fe0dd9891507b1f1e455
2023-02-02 08:48:50 +00:00
Umherirrender
9b8f153fb8 Setup: Remove internal short-cut config $wgUseEnotif
It is not possible to set $wgUseEnotif on LocalSettings.php,
because it is always set on setup, it should not be a global/setting.
Just remove it from the dynamic setup and use the config it is set from

Bug: T305093
Change-Id: I9bfa502a0b9798bd149b4cfe4db86a0461e76f55
2022-08-17 23:41:30 +02:00
Umherirrender
5139b241a3 Remove unneeded use of TitleValue::newFromPage
The called method accept a PageReference as well

Change-Id: I44f7f0f4392dcc1474f586fbbf5c337880535bd8
2022-07-31 12:26:11 +00:00
jenkins-bot
40abc7d834 Merge "Use User::isRegistered for readability instead of ::getId falsy check" 2022-05-23 04:06:10 +00:00
Matěj Suchánek
e47c441078 Fix many typos in comments
Found using IntelliJ's "Typo" code inspection.

Change-Id: I746220ebe6e1e39f6cb503390ec9053e6518cf16
2022-05-10 12:46:11 +00:00
Umherirrender
49ad716948 Use User::isRegistered for readability instead of ::getId falsy check
Change-Id: I42aab149559e3e899cde6c77af76c66936ed0ef0
2022-04-29 21:15:57 +02:00
Aryeh Gregor
7b791474a5 Use MainConfigNames instead of string literals, #4
Now largely automated:

VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \
  tr "\n" '|' | sed "s/|$/\n/;s/'//g")
sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \
  $(grep -ERIl "'($VARS)'" includes/)

Then git add -p with lots of error-prone manual checking. Then
semi-manually add all the necessary "use" lines:

vim $(grep -L 'use MediaWiki\\MainConfigNames;' \
  $(git diff --cached --name-only --diff-filter=M HEAD^))

I didn't bother fixing lines that were over 100 characters unless they
were over 120 and triggered phpcs.

Bug: T305805
Change-Id: I74e0ab511abecb276717ad4276a124760a268147
2022-04-26 19:03:37 +03:00
Tim Starling
8a90e18029 Propagate the RevisionRecord down from Article::view() to WatchlistManager
This eliminates a query from getRevisionById(), and in combination with
the parent commit Ibf0ab45ddfebbf6f188d3630610946c3c7376f9f, also
eliminates the query from getTimestampFromId().

Change-Id: I87d9b5a84caad7363230e99232bb74c9290476b0
2022-03-18 18:57:55 +11:00
Tim Starling
1155648ecf Fix core newtalk 304 suppression and update deferral
Deferring newtalk updates caused the skin to show the notification on
the same user talk page view request in which it is cleared. Even if the
user refreshed the page, it would still show the notification since a
304 response was given.

So, move the newtalk part of WatchlistManager
::clearTitleUserNotifications down to TalkPageNotificationManager, so
that the in-process updates can be done immediately, with the DB updates
being deferred. TalkPageNotificationManager is now responsible for
deferring the relevant parts.

Originally (2002) the newtalk status was set by calling
User::saveSettings(), which had the side-effect of updating
user_touched. Restore this behaviour, which is fast now due to the
"quick touched" cache. Also update the touched timestamp when the
notification is cleared.

Change-Id: Ic3c14bca7bed04f46afffa971fa0a57224c666ce
2022-03-18 16:52:12 +11:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Petr Pchelko
0dfa846653 Use null coalecing operators everywhere consistenctly.
Auto-generated with rector.

Change-Id: I4f27e10cf029bb067b7bc57d82f7a64e21ea8d42
2021-06-03 21:42:06 -07:00
DannyS712
7a8a86476b WatchlistManager: remove unneeded conversion to full User object
The UserClearNewTalkNotification hook only needs a UserIdentity

Change-Id: Ibeab18321d099556bd0cdecc77b78bc2b84c03f7
2021-05-27 05:24:47 +00:00
DannyS712
ed99cdd6c5 WatchlistManager: reduce more uses of full user objects
WatchedItemStoreInterface accepts UserIdentity

Change-Id: I4d2afb8cfe11d496d060c0e5de651e77c26ff904
2021-04-23 20:43:10 +00:00
DannyS712
4f3d8ccb59 WatchlistManager: reduce use of full user objects
In addWatch and removeWatch, after checking permissions
we call the corresponding *IgnoringRights method and need
to provide a UserIdentity object. Previously, the Authority
used in addWatch/removeWatch was converted to a full User
object via the UserFactory, but since we only need to provide
a UserIdentity we can use Authority::getUser

Change-Id: I32d63dfa2ec4ce35ff6ba1be7c11d9c3d355aa7c
2021-04-23 19:43:37 +00:00
Cindy Cicalese
fb6b6e058c Fix parameter order of setWatch to match add/removeWatch
Change-Id: I0ea63482a5cab24c23b49b8bbe6c80bdbe8b102b
2021-04-21 04:41:38 +00:00
Cindy Cicalese
f8ed11e170 Replace doWatch/doUnwatch with addWatch*/removeWatch*
Change-Id: I8882bc24b178ea49198bed5fb206e1a8ea0a4f30
2021-04-20 22:46:07 -04:00
Cindy Cicalese
577824ae7f Move watchlist-related methods from WatchAction to WatchlistManager
Deprecate the watchlist-related methods in WatchAction.

Change-Id: Id235cc483e2f1f3a432e2c26aebc48ae6cd73a0b
2021-04-20 21:44:54 -04:00
Cindy Cicalese
47998b0783 Move watchlist-related methods from User to WatchlistManager
Deprecate the watchlist-related methods in User.

Change-Id: I1cde60252dd0f9659c718e27c7f2193294de63cd
2021-04-19 01:47:53 +00:00
daniel
cf6e3c50dc Remove Title from method signatures in User
Bug: T278459
Change-Id: I78c6a1b57e1b8383905e6650ab16085d28a38769
2021-04-16 15:37:05 -04:00
Cindy Cicalese
200e9abbd0 Convert WatchlistManager to use Authority and PageIdentity
- take PageIdentity in addition to LinkTarget where appropriate and
  deprecate taking LinkTarget
- take Authority in addition to UserIdentity where appropriate and
  deprecate taking UserIdentity

Change-Id: I410a4c26b25e086e1e6abb293789d718de4aa20a
2021-04-14 18:21:58 -04:00
Cindy Cicalese
f1dadbb4ca Rename WatchlistNotificationManager to WatchlistManager
Change-Id: Ic9707c6b74180ef111d128f9f00de218d191c175
2021-04-07 18:16:24 -04:00