Commit graph

83 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
jenkins-bot
315de0e434 Merge "Deduplicate language links in ParserOutput and OutputPage" 2024-09-27 22:43:43 +00:00
James D. Forrester
9e5c1e8ac7 Add namespace to IDBAccessObject and DBAccessObjectUtils
Bug: T353458
Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
2024-09-27 16:19:10 -04:00
C. Scott Ananian
7495f9bc15 Deduplicate language links in ParserOutput and OutputPage
Move deduplication of language links out of Parser.php and into the
ParserOutput in order to be compatible with alternate Parsers (Parsoid).
Clean up various inconsistencies: ensure deduplication also happens in
OutputPage when multiple ParserOutputs are merged into the final output,
and ensure that the deduplication in LinksUpdate is done in the same
order (first link prevails) as in Parser/ParserOutput/OutputPage.

Deprecate OutputPage::setLanguageLinks() (the matching
ParserOutput::setLanguageLinks() was deprecated in 1.42).

As a breaking change, return an array, not an array *reference*, from
ParserOutput::getLanguageLinks().  This allows us to safely modify the
internal representation of language links. As far as I can tell, no one
used the returned reference to sneakily modify the list of language
links, and there not a good way to have deprecated this before making
the breaking change.

While we're at it, we've added tests to ensure that language link
fragments are preserved.

Bug: T26502
Bug: T358950
Bug: T375005
Change-Id: I82a05a51d94782ebb9fa87ff889ca0f633b3e15c
2024-09-26 15:28:49 -04:00
Umherirrender
6eec17e9a9 Add missing documentation to class properties (miscellaneous classes)
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: I1da4b272a6b28c419cc8e860d142dae19ca0bbcf
2024-09-14 10:12:18 +02:00
Umherirrender
c4c7fc62ec deferred: Hard-deprecate LinksUpdate::getAddedLinks/getRemovedLinks
Also TitleLinksTable::getTitleArray

Depends-On: I7bd6714f31a1a3195c1b9a47c9c49b92b9873212
Depends-On: I9514e77a73eea5ee7fbcf4cda79c8f9c4acbd328
Depends-On: I25d047ceb707837009e0a703693ebc2f49fc0ba9
Change-Id: I00b4363b9af7fef3c5a6ae4f612b37c3cd470d45
2024-07-30 02:10:30 +02:00
Umherirrender
9a107e6b03 Use expression builder instead of raw sql
Bug: T361023
Change-Id: Ibf1c93ddbf8f680e8fb9442816f6fed94a069c0a
2024-07-23 23:30:45 +02:00
Daimona Eaytoy
6469955810 Replace User, Title, and WikiPage in more signatures
Change-Id: I04e408e734edc5498c32c4433f02da613bbfafa6
2024-07-10 01:25:57 +02:00
jenkins-bot
ed10e9dbfb Merge "Remove TemplateLinksSchemaMigrationStage config" 2024-05-28 11:45:51 +00:00
Ebrahim Byagowi
b5727d94b5 Import InvalidArgumentException at top of the source
It was asked in a patch review to apply fully import
InvalidArgumentException where possible. I was guessing some
of my other already merged patches have but turned out such
thing exists other places style so for the sake of consistency
I've turned rest of inline import of the specific exception at
top of the file.

There are instances of source files that aren't in any namespace but
have fully qualified import which this patch doesn't touch.

Change-Id: I4071fc698b65746d9594cf4d5f45bae82843d436
2024-05-19 23:57:44 +03:30
Umherirrender
420e071271 Remove TemplateLinksSchemaMigrationStage config
Bug: T299417
Follow-Up: I906e069a63d1dae14924c72318b22b16244371d6
Change-Id: Ia5f730af82f904bd42552e6c6a5c4dadf2454d3a
2024-05-15 22:27:44 +02:00
C. Scott Ananian
c2df535b9c Substitute category default sort key when filling links table, not at parse time
This ensures uniform treatment of all places that call `addCategory`
without duplicating the `defaultsort` code; it also ensures that the
effect of the {{DEFAULTSORT}} parser function is independent of page
position.

Bug: T40435
Bug: T353530
Change-Id: I4480a6d59e766fa4eddc9ec9117c58b66771bb47
2024-03-29 18:30:02 -04:00
James D. Forrester
85d95dd458 Drop old class_aliases for before MW 1.39 that were missed
The RandomPage alias was dropped in an earlier commit, so
group the release note entry in with these.

Change-Id: I207d7463ced1a1bb8b8ac749eba175fc0037a217
2024-03-20 12:10:42 +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
jenkins-bot
845e69cb2e Merge "Namespace includes/cache" 2024-02-28 15:10:38 +00:00
C. Scott Ananian
b5d44bf339 ParserOutput::setPageProperty(): Update documentation
String and non-string values behave very differently when passed to
::setPageProperty(), resulting in some unexpected gotchas for the
unaware caller.

Bug: T350224
Bug: T305158
Change-Id: I23b35b250f27a117d1353ea8a26d2b3f77c568e7
2024-02-20 11:26:38 -05:00
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05:00
jenkins-bot
58ed1f36ba Merge "LinksUpdate: Replace the deprecated function wfGetDB with IConnectionProvider" 2024-01-23 18:58:05 +00:00
Doğu Abaris
6e30e7469a LinksUpdate: Replace the deprecated function wfGetDB with IConnectionProvider
Change-Id: I432151384f69dcb33671fd6b4c257960e294ef52
2024-01-23 18:36:35 +00: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
Daimona Eaytoy
175c0c4abf Replace more instances of deprecated MWException
Bug: T328220
Change-Id: Iba90f7f9b5766bccc05380d040138d74d5e9558a
2024-01-19 23:11:59 +00:00
James D. Forrester
9bfb75ff90 Namespace ParserOutput
Most used non-namespaced class!

Bug: T353458
Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
2023-12-14 14:57:34 -05:00
James D. Forrester
67217d08df Namespace remaining files under includes/deferred
Bug: T166010
Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
2023-11-22 10:08:53 -05:00
Umherirrender
a66595f0c9 LinksUpdate: Compare raw domain and path for externallinks table
Using LinkFilter functions can repair some values, but that would never
removes invalid values from the externallinks table.

When LinkFilter get bug fixes on how to handle domain or path there is
no way to refresh the links on the externallinks table (even not with
refreshlinks.php) as it compares the url rebuilded from the database
with the value from the parser. But rebuilding the url from database
must not match, when reversing the url to find back the database row.
Just use the raw values internally.

Bug: T350476
Change-Id: I60e61c229c6923427585a445a08e6130d265519d
2023-11-14 23:53:11 +01:00
C. Scott Ananian
d20663259f Hard-deprecate ParserOutput::getCategories(), deprecated in 1.40
It is difficult to distinguish this method from OutputPage::addJsConfigVars()
in code search:

   https://codesearch.wmcloud.org/deployed/?q=%5BOo%5Dut%28put%29%3F%28%5C%28%5C%29%29%3F-%3EgetCategories%5C%28&files=&excludeFiles=&repos=

We generally try to replace $output with $parserOutput or $pOutput
as we touch code to improve the ability of codesearch to dig up
deprecated ParserOutput methods.

Bug: T305161
Depends-On: I02dd4f61c43c225b0ef6dc51c3e4f9d967a0a272
Depends-On: I61d2d77591579d825ad9d37f902e40366be55dd6
Depends-On: I91155106b7a9e10d3334f95ba4936d02851bfb11
Depends-On: Iaca745c79d9587571af03b23b21d76a6cba0ebf1
Depends-On: Id10a171c44411b1233ee4d6cf8fbd3dc57744eef
Depends-On: I47a25c011d9bd4b1a15dda4e673e32c25eb64f2b
Depends-On: I683fc768aba50b801f46467fcfa1668fa8731ea6
Change-Id: I5a2ac1c99b8b199102e12f0d32dd6ec5cdc24054
2023-09-29 15:25:50 -04:00
Bartosz Dziewo?ski
220f23d5f0 DerivedPageDataUpdater: Only do RefreshLinks on file page redirect changes
Previously, we scheduled recursive RefreshLinks jobs on every file
page edit, but it's only necessary when the page's redirect target has
changed. Optimize this, and only schedule them when the page is or was
a redirect.

(We still do it unnecessarily when a redirect page is edited without
changing the target, but that's more difficult to detect at this
point.)

Bug: T346383
Change-Id: Ie629881c94a7a81ae7bf597aab4587921d1c25ae
2023-09-26 04:31:33 +02:00
Bartosz Dziewoński
1988905d2a LinksUpdate: Remove deprecated public properties
Deprecated in e5a7f8f5aa.
No errors logged in WMF production, and no obvious uses
in Codesearch (although some, like mId and mTitle, are
difficult to search for).

Change-Id: Ib8f2f9e6c073d2e9244ed3579f4e68a45d5a0711
2023-09-26 01:18:10 +02:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00: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
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
C. Scott Ananian
722f64f6df Remove ParserOutput::{get,unset,set}Property and ::getProperties()
These were deprecated in 1.38 and replaced with ::{get,set}PageProperty()
and ::getPageProperties(), avoiding a heavily-aliased use of the term
"property" and making the relationship between the ParserOutput and page
properties clearer.

Bug: T305161
Change-Id: Ib1a5d0a2c1387584b81c958fa32516034e7b3d05
2023-09-18 11:34:02 -04:00
Tim Starling
95bd40b25c In query builders, use insertInto() and deleteFrom() instead of insert() and delete()
The design principle for SelectQueryBuilder was to make the chained
builder calls look as much like SQL as possible, so that developers
could leverage their knowledge of SQL to understand what the query
builder is doing.

That's why SelectQueryBuilder::select() takes a list of fields, and by
the same principle, it makes sense for UpdateQueryBuilder::update() to
take a table. However with "insert" and "delete", the SQL designers
chose to add prepositions "into" and "from", and I think it makes sense
to follow that here.

In terms of natural language, we update a table, but we don't delete a
table, or insert a table. We delete rows from a table, or insert rows
into a table. The table is not the object of the verb.

So, add insertInto() as an alias for insert(), and add deleteFrom() as
an alias for delete(). Use the new methods in MW core callers where
PHPStorm knows the type.

Change-Id: Idb327a54a57a0fb2288ea067472c1e9727016000
2023-09-08 10:16:08 +10:00
Amir Sarabadani
f405bbb5f2 Add support for write both for pagelinks
Bug: T345669
Change-Id: Ia099d092461aa12fc1bfac10c65cf79b391bafca
2023-09-06 13:33:19 +01:00
Amir Sarabadani
06fa7a9107 ExternalLinks: Drop migration code
Anything that writes or reads from now-dropped columns

Bug: T312666
Change-Id: Ic1c69de717bfa03bba94e97dabad9e717ba13fd6
2023-09-05 16:43:18 +02:00
David Causse
a7bdc20a7f LinksTable: pass insert options
Seems to cause failures otherwise and prevent LinksUpdate to complete.

Change-Id: Ib46eb935b9131f5a6480fcd5318b3a0068de620a
2023-08-09 16:21:20 +02:00
Amir Sarabadani
98d6503f65 Mass migrate Database::insert calls to InsertQueryBuilder
Done automatically based on a php parser written on top of ANTLR4

Bug: T335377
Change-Id: Ie8fabc594edab18e55cb1d5bbf573762106e3d71
2023-08-07 19:44:27 +02:00
Amir Sarabadani
b57b81066e rdbms: Remove or move unused public methods of ILB/ILBF
These methods are either:
 - Completely unused, removed
 - Used only by the class itself, made private
 - Used by LBF (ILB methods) which they were moved to
   ILoadBalancerForOwner

In the meantime, completely deprecating and removing per-domain and
per-cluster waitForReplication. Simply wait for all LBs to catch up:
 * In reality, the replication lag is so small that it doesn't matter.
   It's probably caught up already by that point anyway.
 * If you don't make a db call, you don't init a new LBF to be waited on
   so it's already quite small.

Bug: T326274
Change-Id: I2c0a89d70152de56d35290f2666b6699822ed330
2023-08-01 10:33:43 +00:00
Amir Sarabadani
be437f97c4 ExternalLinks: Add support for WRITE_NEW only mode
This can be only enabled once I0d60742b6ce is deployed

Bug: T341828
Change-Id: I422b6799de9b9e1dfa6eca96ad711b3e59a5b04a
2023-07-25 13:27:26 +02:00
Umherirrender
28ae6795f8 Move array destructuring into foreach
Change-Id: I54c98085b21f1fe48ccf575d1b9dd60d3b855c58
2023-07-08 19:52:46 +00:00
Umherirrender
fe40101587 Replace IDatabase::delete with DeleteQueryBuilder
Change-Id: Ie0c1c955ca1a7028f75f24563fdeb9f94285af30
2023-06-21 17:50:31 +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
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
jenkins-bot
42a644bea8 Merge "Reorg: Move LinkFilter to ExternalLinks" 2023-03-03 19:18:26 +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
22cec534c5 Reorg: Move LinkFilter to ExternalLinks
It's one-class namespace and I know it's not great but:
 - I hope to add more classes with the redesign of externallinks table
 - It's not named very well either, it's a collection of URL-related
   functionalities
 - Making it clear LinkFilter is about external links, not internal or
   interwiki or templatelinks etc.

Bug: T321882
Change-Id: I0dd530237f45e4fec786178ec03ee941c6bcd982
2023-03-01 22:08:29 +01: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
Func
1132c3dc19 LinksUpdate: Use DB key for category links table
The first parameter returned from findVariantLink() is not the DB key,
which whitespaces should be replaced with underscores.

Also:
1. Replaced Title::makeTitleSafe with Title::makeTitle, invalid links
   would be treated as plain text by the parser and can never hit this
   code path. And the makeTitle function below is also using
   Title::makeTitle.
2. Updated the document of findVariantLink().

Bug: T328477
Change-Id: I2b08edd90666e0fa4eafe91444a58806909b02d6
2023-02-10 18:21:49 +08:00
Amir Sarabadani
c8116223b4 Reorg: Move category-related classes from includes/ to Category/
Bug: T321882
Change-Id: I0b86acfdeaa3a2a0a14b7763fd088122820bafdc
2023-02-09 20:18:54 +01:00