Commit graph

22 commits

Author SHA1 Message Date
Matěj Suchánek 11b9e66f9f Disallow anonymous non-IP agents, handle truncated names
Why:
* Echo stores agents by their user id or by the name if the user
  is not registered. This works for IPs since the "event_agent_ip"
  field has limit of 39 bytes (32× [0-9A-F] + 7× colon for IPv6).
* However, it's possible to hold a user identity that is not
  an IP address, but the user name has not been or cannot be
  registered (e.g., external users). Echo wouldn't validate this
  and would attempt to insert the user name into "event_agent_ip",
  possibly causing silent truncation and data corruption.

What:
* Do not let events with such agents be saved. For now, log an
  error in the production. Wikibase, the only known source of this
  problem, has already been fixed.
* In runtime, replace every possibly corrupted user name with
  a placeholder to avoid unexpected null values and exceptions
  in production.

Bug: T367638
Change-Id: Ic2bd218b10651d13da9e9aea54dd2d668a33d946
Depends-On: I03b4367355dc5a3fc0c14aad5fdf19fbcd0caa3d
Depends-On: I92eb93983e81708b289e9f7d837884d539dade0b
2024-11-14 11:44:19 +01:00
jenkins-bot e6a51beca1 Merge "Avoid event insertion if possible" 2024-10-30 15:06:30 +00:00
Andre Klapper 4da4dad97b Use explicit nullable type on parameter arguments (for PHP 8.4)
Implicitly marking parameter $... as nullable is deprecated in PHP
8.4. The explicit nullable type must be used instead.

Bug: T376276
Change-Id: I251cb37401c37242f493816b6f70ab61a64a4c32
2024-10-26 15:05:13 +02:00
jenkins-bot 052dc0a3ef Merge "Fix for Watchlist Notifications for deleted pages created in 1.35" 2024-10-25 00:13:25 +00:00
Umherirrender 7e5eceb5a6 Use namespaced classes
Changes to the use statements done automatically via script

Change-Id: Iab065a2005acccfe05cc827fdafc7861687d053d
2024-10-20 00:55:03 +02:00
Matěj Suchánek 4ae63d1b4d Avoid event insertion if possible
Why:
* On wikis with lots of bot activity like Wikidata, there is a large
  volume of edits which can potentially create an article-linked
  notification. These notifications are now actually rarely sent
  because they are disabled for bots (T318523). However, the event
  record is always inserted into the database, with no reference to
  it, bloating the database.

What:
* Do not unconditionally insert an event into the database when
  Event::create is called. Pass it to downstream calls and have
  it inserted when it's clear it will actually be needed (i.e.,
  a notification is definitely going to be created).
* Pass the event's payload to the job queue instead of requiring
  its ID. Introduce Event::newFromArray, which unlike ::loadFromRow
  handles ::toDbArray values that haven't been inserted into
  the database yet.
* Introduce Event::acquireId which ensures the event has been
  inserted prior to returning its ID as well as it does not get
  re-inserted.

Bug: T221258
Change-Id: I8b9a99a197d6af2845d85d9e35c6703640f70b91
2024-10-11 20:12:11 +02:00
Pavel Astakhov 4c35cecea0 Fix for Watchlist Notifications for deleted pages created in 1.35
Bug: T286192
Change-Id: I9d4ab915ca33a3d52018470f1147eb77f5590c86
2024-04-16 17:02:26 +00:00
James D. Forrester 34ffba5b03 Swap uses of Title::GAID_FOR_UPDATE for IDBAccessObject::READ_LATEST
Deprecated in MediaWiki 1.34.

Change-Id: I23732e29954d3410b22726a524c6e15b71b0d6a1
2024-01-26 13:37:47 -05:00
Umherirrender a0ca1d89c6 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements done manually

Change-Id: Iad87245bf8082193be72f7e482f29e9f1bad11fc
2023-12-11 16:39:00 +01:00
Umherirrender 5e49d52fba Call hook handler for own hooks directly and not via hook system
Extensions should not a consumer of its own hooks,
just call the code before calling the hook.
In case of EchoGetBundleRules each extension should only handle it's
own event, so this is not a breaking change.
In case if EchoAbortEmailNotification the return false in the hook
handler already aborted further hooks, so this is not a breaking change.

Change-Id: I2715aa6499d01a1c1b3a27ff510b331eae0deca9
2023-09-08 16:47:33 +00:00
gerritbot 84e0d10abd Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I19ff201e3a109d5f6b755c6c0857f7b22d08d26d
2023-08-19 16:43:18 +02:00
Reedy 8f44150300 And a few more namespaced classes...
Change-Id: I57b56d285bac4b41e81f656f3c1ddceee4620fb5
2023-08-18 22:27:18 +01:00
Reedy b003945c34 Namespace a few more classes
Change-Id: Ie233a4c8291432da3bd25d29337db52a2e97b540
2023-08-18 21:48:15 +01:00
Reedy e576cbdca0 Namespace some more classes
Change-Id: If1405788a4adb550e8a7e8c58b0c2c55cf10ea67
2023-08-18 21:24:59 +01:00
Reedy 1bc5b6daf8 Namespace classes that need aliases
Change-Id: Ieeeaf80d04b060d6dbca1959d5e66f4c69c5a7f2
2023-08-18 19:00:41 +01:00
jenkins-bot 078788f411 Merge "Create HookRunner class and the hook handler interfaces" 2023-08-16 05:26:06 +00:00
Daimona Eaytoy ef50bfeda5 Make Title and Revision caches proper services
Singletons are bad, amongst other reasons, because they're never reset
in tests. They can therefore occasionally cause test failures if the
cached data stored in one of these singletons becomes stale.

As noted on the task, ideally these two classes shouldn't exist at all,
and core should be responsible for caching the information it deems
expensive to compute.

As a temporary (TM) workaround, make both classes actual services, so
that the setUp/tearDown logic in MediaWikiIntegrationTestCase can
properly reset them between tests.

Dependencies are intentionally not being injected, precisely because
these classes should just be deleted, not improved.

Bug: T344124
Change-Id: I58b8d9610f9447468235b94d25732528ab6acce6
2023-08-14 17:41:23 +02:00
Umherirrender e52a792060 Create HookRunner class and the hook handler interfaces
Bug: T315938
Change-Id: Iffa2b409502b4269c9746e0304feb4aaee37a86e
2023-08-06 10:30:46 +00:00
Daimona Eaytoy baf711c3c5 Replace remaining usages of deprecated MWException
Bug: T328220
Change-Id: I97ea68525392e921b970d15b5d5ffd9c89bae452
2023-06-09 02:23:08 +02:00
Daimona Eaytoy 4cd98d3048 Replace some usages of deprecated MWException
Most notably, CatchableFatalErrorException and the code that throws it
are unused since Ic5712c4ce265b6faabce7a4028b4294fe3c73f18 (in 2016).

Bug: T328220
Change-Id: I5497347e41b21d2623b7e79bf7f977268a809c1d
2023-06-08 11:52:41 +00:00
Umherirrender 159863d15a Replace deprecated Hooks::run
Bug: T335536
Change-Id: I3f20828047a886e1140fa080e3f3f1945397424f
2023-05-06 19:59:22 +00:00
Reedy 5611662f06 Namespace Model
Depends-On: Id28792658de950b99a8786f881563476def59eba
Change-Id: Ib57ea2db947285946f31fa9912b37181044df9d3
2022-11-10 14:25:42 -07:00