Commit graph

603 commits

Author SHA1 Message Date
Pppery
b9c99fc622 Fix GREATEST usage in site_stats
For the positive-delta case since the row can't be negative the
`GREATEST` is useless, so delete it. For the negative-delta case do the
GREATEST before the subtraction so that it doesn't try to temporarily go
negative.

Bug: T315573
Change-Id: I0a27a57835048ee6a06266d377ed8f3f52ddf435
(cherry picked from commit 4017d2b6d60c6eb5c02ca48c8d8eeb74a18ba262)
2025-03-20 15:48:17 +00:00
jenkins-bot
a92f3be569 Merge "rdbms: clear replica snapshots in (begin|commit|rollback)PrimaryChanges()" 2024-10-22 15:25:44 +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
Umherirrender
cefcbbbc18 deferred: Add @phan-mandatory-param for function name arguments
Providing the function name is often optional from the php code,
but it is needed for better logging, so make it mandatory and let phan
report issues about this.

Bug: T374546
Follow-Up: I5227f2fa65850ac8c6f620900f22d1f4e7bfd470
Change-Id: I3becd23d3ba9f452a8afd833d509cd907e56ca47
2024-10-11 20:46:13 +02:00
Aaron Schulz
b69c1839d4 rdbms: clear replica snapshots in (begin|commit|rollback)PrimaryChanges()
Automatically perform the empty-transaction commit logic in methods
like beginPrimaryChanges() and commitPrimaryChanges(). This avoids
the proliferation of callers having to call the same set of methods
one after another for non-obvious reasons. It also discourages code
from making brittle assumptions that might fail for setups where
there is only a primary or the primary has non-zero read load.

Deprecate flushReplicaSnapshots() and remove callers.

Clarify the related method documentation.

Bug: T315664
Change-Id: I255afd22ffcaeac0fad2d4e4a2a0c55c99be7905
2024-10-09 20:34:25 +00: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
James D. Forrester
2b11d61577 Migrate all uses of deprecated URL global functions to use wfGetUrlUtils()
wfGetUrlUtils() is also deprecated, but less so, so we can do this first
and then properly replace the individual uses with dependency injection
in local pieces of work.

Also:
* Switching Parser::getExternalLinkRel to UrlUtils::matchesDomainList
  exposed a type error in media.txt where $wgNoFollowDomainExceptions
  was set to a string (which is invalid) instead of an array.

Bug: T319340
Change-Id: Icb512d7241954ee155b64c57f3782b86acfd9a4c
2024-09-10 16:50:02 -07:00
jenkins-bot
5a0901ee8f Merge "deferred: Hard-deprecate LinksUpdate::getAddedLinks/getRemovedLinks" 2024-08-23 21:11:33 +00:00
jenkins-bot
cb12aac27c Merge "deferred: remove BIG_QUEUE_SIZE logic that turned updates into jobs" 2024-08-20 16:59:42 +00:00
Aaron Schulz
a27be97a84 deferred: remove BIG_QUEUE_SIZE logic that turned updates into jobs
There are enough points where tryOpportunisticExecute() is triggered
that this no longer needed.

Change-Id: Ie27d4ec299df0e6f2754baedc237a473821f0709
2024-08-20 15:14:02 +00:00
jenkins-bot
93a736dfde Merge "deferred: simplify $dependeeDbws parameter type for MWCallableUpdate" 2024-08-12 17:02:03 +00:00
James D. Forrester
f7ce0a0976 Move remaining four classes in includes/content into Content namespace
Bug: T353458
Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
2024-08-10 10:40:53 +02:00
Aaron Schulz
0e4fd5299a deferred: simplify $dependeeDbws parameter type for MWCallableUpdate
Remove null type hint and related conditional since it would be silly
to bother passing null and nothing is doing so according to code search.

Change-Id: I499aebd50433be8fd242461e86f5f9c69b300afe
2024-08-09 19:12:36 +00:00
jenkins-bot
d553f37388 Merge "deferred: actually flush replica view snapshots in onRunUpdateStart()" 2024-08-09 12:19:21 +00:00
Aaron Schulz
c51af555ea deferred: actually flush replica view snapshots in onRunUpdateStart()
The comment mentioned this, but the code did not actually do it.

Typically, flushing these does not matter much due to replication
lag. However, if a deferred update starts with a replication wait
or the prior one ended with a replication wait, then flushing the
read transactions can make a reliable difference.

Also, if many deferred updates are running in a process, flushing the
snapshots means that mysql can purge old versions of rows, since
otherwise they could potentially be seen by a future query (e.g. MVCC).

Bug: T315664
Change-Id: Ia3ac4193e56ef5b49727457b0cd50dfbc987f881
2024-08-08 22:41:10 +00: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
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
Bartosz Dziewoński
ef2329c012 rdbms: Warn about queries that don't provide the caller
Change-Id: Ib02dac0c607fc9931e1384a9cd7e989db683a4ff
2024-05-31 22:08:19 +00:00
Umherirrender
a9adc61d35 Use RawSQLValue for some SET clauses in update/upsert
Change-Id: I03c068c4bf098ab073989a0ea32a0f87fe878727
2024-05-29 19:48:09 +00:00
jenkins-bot
ed10e9dbfb Merge "Remove TemplateLinksSchemaMigrationStage config" 2024-05-28 11:45:51 +00:00
Ebrahim Byagowi
389b1d0436 Add namespace and deprecation alias to RefreshSecondaryDataUpdate
This patch introduces a namespace declaration for the
MediaWiki\Deferred to RefreshSecondaryDataUpdate and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I9ee3282918f8f3d444a12ca32434a15e93952055
2024-05-20 19:05:24 +03:30
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
Cole White
e71c6f7750 SiteStatsupdate: update to use StatsFactory
Bug: T359243
Change-Id: If5f754054e469bdf11dc1446d7f43628dfda65b0
2024-05-04 12:05:19 +00:00
Amir Sarabadani
8e183495e1 Stop using LoadBalancer::getConnectionRef() so it can be hard-deprecated
Bug: T326274
Change-Id: I90493d7cd4c21fdc022bcc19765fc04d986a9c8f
2024-04-30 13:31:08 +01:00
Derick Alangi
791cb9f676
search: Use ServiceOptions not full config object
This patch uses the recommended MW practice for injecting
settings into MW services. Instead of passing in the full
config object, pass in service options which MW service wiring
will use to lookup settings/options from config sources.

So in this patch, the various options have been identified
and put into `CONSTRUCTOR_OPTIONS` constant and inject via
service wiring.

Test plan
=========
Ensure that the special page: `Special:Search` still works
with this patch checkout on your local test wiki.

When you visit `Special:Search` on your local wiki, you should
see a search form view. Type in something like: "Main Page" and
then hit search. If everything works well, then local test passes.

NOTE
====
This patch also resolves a TODO which mentions the removal of
the `getConfig()` method from the SearchEngineConfig class.

Change-Id: Ib5dfc10f3f210c6c35247f4f30f9549dd60e0af7
2024-04-16 15:50:43 +01: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
Derick Alangi
1f3be17f06
deferred: Migrate deferred updates metric to StatsLib
Bug: T360290
Change-Id: I1076b10a77723dbab4262f41a4e3c295d49c4a6a
2024-03-18 12:52:37 +03: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
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
Gergő Tisza
353b37b4e0
DeferredUpdates: normalize logging
Change-Id: I1fd5d897c947dd407aa04b72e11c2ce9f5ef900d
2024-01-14 00:44:49 -08:00
jenkins-bot
d8307e3816 Merge "Replace $wgCommandLineMode checks with MW_ENTRY_POINT in other places" 2024-01-02 22:39:56 +00:00
Bartosz Dziewoński
6876ccf177 Replace $wgCommandLineMode checks with MW_ENTRY_POINT in other places
I'm not sure if there's a good way to split this up into
logical chunks.

Bug: T313841
Change-Id: I3b35a2e475b5143f383d4085fbc6a0ed3bbc32b8
2024-01-02 22:17:14 +01:00
Umherirrender
62c1bd5abc deferred: Add a freshness option to RefreshSecondaryDataUpdate
Allows to trigger RefreshSecondaryDataUpdate jobs with a timestamp to
ensure a link update was done after that timestamp.

Since e5655255 it is possible that RefreshSecondaryDataUpdate gets
queued for api action=purge, but RefreshSecondaryDataUpdate only checks
that the links update is done after the last edit, so when jobs get
queued by action=purge, the jobs does nothing.
Ensure that page_links_updated gets updated via action=purge when the
timestamp is before the new freshness timestamp (checked in
RefreshLinksJob::isAlreadyRefreshed).

Bug: T351729
Change-Id: I85aed4c40d430ba6c30c763141f4b821c36e6eaf
2023-12-27 16:07:06 +01:00