Commit graph

41 commits

Author SHA1 Message Date
Amir E. Aharoni 15f3f80378 Consistent spelling of "subpage"
"Subpage" is usually written as one word
in core and in other extensions.

Change-Id: Ie10a500790c321e866c02264d55449e42b0110bb
2024-08-06 03:44:51 -04:00
Umherirrender 2a932e598c Use expression builder instead of raw sql
Change-Id: I0cb5fa07d63bc93089a4956097eee7a41dbc99e7
2024-07-21 23:25:41 +02:00
Fomafix 3c76c7918b Inject service ContentLanguage into ThreadItemStore
Change-Id: Ie9b7d462c8ddf4abb749ee07537ccec1949b8fba
2024-07-03 10:16:27 +00:00
jenkins-bot fb4d4d77a5 Merge "Trim whitespace from truncated heading titles in IDs" 2024-06-20 02:20:23 +00:00
Umherirrender 8145e7ae74 Add caller when running query builder
Change-Id: Icc9f640ff8a67d582448e4f05a4456a54218b72d
2024-05-31 00:25:03 +02:00
Ed Sanders 501046f38c Trim whitespace from truncated heading titles in IDs
Bug: T356196
Change-Id: Iddcda0cee624fda7f78a05e0a3d70eaee2635da9
2024-05-01 14:20:12 +01:00
Bartosz Dziewoński 69e8e948b2 Remove now redundant PHPDoc blocks
MediaWiki's PHPCS plugin requires documentation comments on all
methods, unless those methods are fully typed (all parameters and
return value).

It turns out that almost all of our methods are fully typed already.

Procedure:

1. Find: \*(\s*\*\s*(@param \??[\w\\]+(\|null)? &?\$\w+|@return \??[\w\\]+(\|null)?)\n)+\s*\*/
   Replace with: */
   This deletes type annotations, except those not representable
   as PHP type hints such as union types `a|b` or typed arrays `a[]`,
   or those with documentation beyond type hints, or those on
   functions with any other annotations.

2. Find: /\*\*/\n\s*
   Replace with nothing
   This deletes the remaining comments on methods that had no prose
   documentation.

3. Undo all changes that PHPCS complains about (those comments
   were not redundant)

4. Review the diff carefully, these regexps are imprecise :)

Change-Id: Ic82e8b23f2996f44951208dbd9cfb4c8e0738dac
2024-03-10 23:53:04 +00:00
Ed Sanders bf7dc0d983 ThreadItemStore: Only pass *Content*ThreadItemSet to insertThreadItems
We never a DatabaseThreadItem back into the database. If someone
wants to do this in the future they should be thinking very
hard about it first.

Change-Id: Ie073c030905e31d81cb75bc9c46d5bb7c5d85b04
2024-02-21 16:10:25 +00:00
Ed Sanders b4e4f30234 ThreadItemStore: Remove "ButTryHarder" from method name
This appears to reference the retry that happens due to
REPEATABLE_READ, but that seems like an implementation
detail so not really useful to have in in the function
name, nor does it disambiguate it from another function.

Change-Id: Iacc95b74f25c166545734818efb1b30e18a1754e
2024-02-21 15:56:32 +00:00
Bartosz Dziewoński fc4d70f9f5 ThreadItemStore: Add ->caller() in queries
It makes it easier to find the queries in debug logs in production.

Change-Id: I80f94d1fc8c49227218b07234e162445cc43ca00
2024-02-09 19:16:55 +01:00
Ed Sanders 8b99c1fbbe Add more search methods to findNewestRevisionsByHeading
In production, indexing the full history of every page will take
too long, so we can't rely on being able to find the target heading
text in the history of the current page.

When this search fails, fall back to the following searches:
* The heading appears in the current revision of a sub-page
* The heading appears anywhere on the wiki, but only once

Bug: T356276
Change-Id: I90e92cb9c85aaf6fb2355f842450981bbe6abf2d
2024-02-01 18:32:36 +00:00
jenkins-bot 797bd2ea0b Merge "ThreadItemStore: Omit redundant updates to avoid warnings" 2023-12-14 11:06:45 +00:00
Bartosz Dziewoński ab2a83601a Use SQL expression builder instead of buildLike()
Follow-up to c82783a5b6.

Change-Id: If844b601b3887d5f853fb9f56be2741896114698
2023-12-14 11:55:34 +01:00
Bartosz Dziewoński 1e5dc67c36 ThreadItemStore: Omit redundant updates to avoid warnings
Bug: T353432
Change-Id: Ib095d622e549139efdd050cadc87ac9dd6a1f318
2023-12-14 10:54:16 +00:00
Umherirrender 64bcb583e9 Use namespaced classes
Done automatically via script
Change to extension.json done manually

Change-Id: Ied7bbddd357290ac6be6bf480be0ee9116e77365
2023-12-11 16:38:02 +01:00
Ed Sanders c82783a5b6 Find a heading by title in archives
* Looks for heading IDs matching "h-<heading text>-%" that once
  existed on the target page.
* For such IDs, finds where those items currently exist,
  presumably in an archive.

Pros:
* Doesn't need to know anything about the local wiki's archiving
  conventions, so can be deployed universally.

Cons:
* ID conflicts will return matches in unrelated archives, e.g.
  MassMessages.

Bug: T349653
Change-Id: Ie94efd0503e9f4689d3421babe445f9f4e2b4fb7
2023-12-06 18:39:28 +00:00
Bartosz Dziewoński 97dbe19a34 ThreadItemStore: Fix rows with itr_items_id=0 corrupted by T339882
In T339882 we thought that these rows are harmless, but for the
specific case of itr_items_id that's not true.

Bug: T343859
Change-Id: Iebfa583d7d4b00a59291f91ec84c41241d5469d4
2023-09-21 03:51:48 +02:00
Bartosz Dziewoński 6b633803c8 ThreadItemStore: Add details to row insertion exceptions
Bug: T343859
Change-Id: Ic0d741c192f42a3bd54276259820f25edcb0705b
2023-09-14 19:05:04 +00:00
Umherirrender 1a8ee0f3d1 Call IDatabase::insertId only when a row was inserted
As docs says on IDatabase::insertId

Change-Id: I4a61ce625c4f31316bb9eee83f293a438bac2e0e
2023-08-16 20:54:09 +02:00
Bartosz Dziewoński 505aef8a60 Use UpdateQueryBuilder and InsertQueryBuilder
Change-Id: I8d8377a0ad3472d193b1bf9b20c8966bb6b34dd7
2023-08-11 21:59:03 +02:00
Bartosz Dziewoński a783b9371f ThreadItemStore: Ignore duplicates caused by duplicate executions
For some unknown reason our updates are being processed more than once
at the same time. Ignore or work around the "duplicate entry" errors
caused by that.

Bug: T323080
Bug: T341811
Change-Id: Iaae1dc2d5ed5bf4ac6760fb1d39dc21f2af89e9a
2023-08-04 18:56:36 +00:00
Bartosz Dziewoński 1b80b1ffcf ThreadItemStore: Look harder for invisible rows
This reverts 08e1073f58 (T322701),
which does not work, and instead uses the same solution as
4439e934429617cc77f34cc9c783f0b52a06c920 (T247553).

Bug: T339882
Change-Id: I1b6772b1cdfd0d7e1c603333a2e43152d3591c38
2023-07-16 00:45:52 +02:00
Amir Sarabadani 40c3c65ccf Switch from typehinting ILBFactory to IConnectionProvider
Narrower interface

Change-Id: Id94d098089f1db645ea6b4b4eb516a512c66fdb2
2023-04-29 23:00:59 +00:00
Bartosz Dziewoński 0d21df43dc Allow maintenance script to work even when DiscussionToolsEnablePermalinksBackend is off
Bug: T334258
Change-Id: I40e09b2f8561eeac1744bbbc48e3973e519bd9ea
2023-04-14 19:36:18 +02:00
Bartosz Dziewoński c0cb0bb24d Add a limit to queries on SpecialFindComment etc.
Some mass messages appear on hundreds or thousands of pages and it's
not good to try to list them all.

Change-Id: Ib903d67ba4fd9d85790ef4271933991b9b6f3834
2023-03-26 10:29:39 +00:00
Amir Sarabadani a1ee2d6daf Use the new method of getting database object
Bug: T326274
Change-Id: I40c6efee0d13ebb6f345ac9f13d243d730b146b9
2023-02-23 12:57:16 +01:00
Bartosz Dziewoński af68c835bb Update exception handling for new code conventions
Change code to match the documented consensus formed on T321683:
https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#Exception_handling

* Do not directly throw Exception, Error or MWException
* Document checked exceptions with @throws
* Do not document unchecked exceptions

For this extension, I think it makes sense to consider DOMException an
unchecked exception too (in addition to the usual LogicException and
RuntimeException).

Depends-On: Id07e301c3f20afa135e5469ee234a27354485652
Depends-On: I869af06896b9757af18488b916211c5a41a8c563
Depends-On: I42d9b7465d1406a22ef1b3f6d8de426c60c90e2c
Change-Id: Ic9d9efd031a87fa5a93143f714f0adb20f0dd956
2023-01-22 18:17:11 +00:00
Bartosz Dziewoński e72f58ca78 Remove some redundant PHPDoc comments
Inspired by this Wikitech-l discussion:
https://lists.wikimedia.org/hyperkitty/list/wikitech-l@lists.wikimedia.org/thread/NWXPNHRNLEVXHSWX33H473OAWQP6CDOA/

To keep this simple for now, I am only removing redundant PHPDoc
comments on constructors, and only when all the documentation for
parameters completely duplicates type hints.

More could be done, but that can happen later when we have better
tooling. Redundant comments on constructors that take a dozen services
are by far the most annoying for me and I want them gone now.

Change-Id: I86cbf7d6e48035cfa06f780c8fb1b02e68709a0c
2022-11-29 18:47:18 +00:00
Bartosz Dziewoński 08e1073f58 ThreadItemStore: Handle race conditions when finding/inserting outside of transaction
Bug: T322701
Change-Id: Icea63dd562c1812a372f3a947ba1244e72d07a16
2022-11-10 23:33:24 +00:00
Bartosz Dziewoński 759e6b757a ThreadItemStore: Fix setting parent IDs when parent already existed
Bug: T322599
Change-Id: I697de586fb3c1b1901f434f6fbef501cec3164df
2022-11-08 01:38:41 +01:00
jenkins-bot 98285f3b27 Merge "ThreadItemStore: Update existing rows if possible rather than insert+delete" 2022-11-03 14:12:49 +00:00
Bartosz Dziewoński c4c455c550 ThreadItemStore: Update existing rows if possible rather than insert+delete
Bug: T321121
Change-Id: I678b093aef95febb33cf4b0140b0625ef3241779
2022-11-03 00:53:19 +01:00
Bartosz Dziewoński 433e57394c Use PHP 7.4 property types
Change-Id: I788db64f0c0c00894d77256b7f016d44eda4bbb1
2022-10-28 21:56:38 +02:00
Bartosz Dziewoński 33f4006713 ThreadItemStore: Fix updates for identical revision timestamps
Use revision IDs to break the tie, consistently with MediaWiki (see
RevisionStore::getRelativeRevision) instead of assuming that the
revision we're processing now is somehow both older *and* newer than
the other one (the mind boggles how that ever made sense to me).

Change-Id: I9f1a07124301a36be68578d908353b72f0442c00
2022-10-20 02:37:47 +02:00
Bartosz Dziewoński 91aeaabe83 ThreadItemStore: Remove long comment no one is ever going to read
I should have just put that in a commit message rather than source code.

Change-Id: Ia5c06c91c21b0b5da1ed578369825a3870c48833
2022-10-20 01:49:19 +02:00
Bartosz Dziewoński 482a2c6dd0 ThreadItemStore: Move some work in insertThreadItems() outside transactions
As suggested in the discussion on T315353.

Bug: T317236
Bug: T317237
Change-Id: I8d9f2e3d4779a2e2f433a8fffea2767ae986bc48
2022-09-29 21:34:15 +02:00
Bartosz Dziewoński 14b01e101a Only hold on to a Config instead of ConfigFactory when injecting
The config is currently unused in some classes, but this is okay since
it might be used in the future.

Change-Id: Ie25fc52cc5d3476c9445e182975d229991316bd3
2022-09-03 00:39:51 +02:00
Bartosz Dziewoński c1442f8331 Replace deprecated database stuff
From in-person code review with Amir:
* getConnectionRef() has been deprecated in favor of getConnection()
* 'watchlist' query group no longer exists (T263127)
* Since this simplifies things, we can remove our wrapper methods

Change-Id: Ic610233b2e6d6ed68f7e1f5b31bb8996ed77f04b
2022-08-16 18:51:28 +00:00
Bartosz Dziewoński 4ffebd80f2 Add config option to enable/disable permalinks backend
From in-person code review with Amir: using tableExists() is a bad
idea, because the table might not consistently exists on all replicas.
It's better to have a config option despite the inconvenience.

Bug: T315353
Change-Id: I728759634c454c0dcbdc4603c15cab60415c7c03
2022-08-16 18:38:45 +00:00
Bartosz Dziewoński 4c17819a76 Migrate usage of Database::select (and friends) to SelectQueryBuilder
Bug: T312466
Change-Id: I99d4402d796421221a1c6c56ef88b023cb495833
2022-08-13 00:32:45 +02:00
Bartosz Dziewoński 0024a94ba7 Store permalink data, implement Special:FindComment/GoToComment
Depends-On: I90656cc74bb1cb1f2f3c82ad51cfb164cb8a4a4b
Bug: T296801
Change-Id: I84187b303aa10a242c872088403f808df3d1f940
2022-08-11 01:19:47 +02:00