Commit graph

542 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
a5387c7c20 Namespace all remaining classes in includes/parser
Bug: T353458
Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
2024-10-15 23:54:32 +01:00
thiemowmde
b1c9ec74fa Remove meaningless @var documentation from constants
A constant is not a variable. The type is hard-coded via the value
and can never change. While the extra @var probably doesn't hurt much,
it's redundant and error-prone and can't provide any additional
information.

Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
2024-10-09 09:33:12 +02:00
jenkins-bot
c35a006fe6 Merge "Use import actor store where needed in RC categorisation" 2024-10-03 15:30:13 +00:00
Dreamy Jazz
649b0f4954 Use import actor store where needed in RC categorisation
Why:
- When temporary users are enabled, creating IP actors is disallowed
  apart from specific cases, such as importing revisions authored by
  anonymous users.
- If such a revision includes a category link and
  wgRCWatchCategoryMembership is true, MediaWiki will fire a job to
  create a corresponding RC entry, which will attempt to attribute the RC
  to the anonymous IP that authored the imported revision and fail in
  doing so.

What:
- Track whether a category membership change job was triggered by an
  import, and allow RecentChange objects created by such jobs to create
  anonymous actors.

Test Plan:
 1. On a wiki with temporary accounts enabled and wgRCWatchCategoryMembership = true,
    import a revision via Special:Import that was authored by an anonymous user
    and contains a category link.
 2. Verify that the import succeeds and that the corresponding RC entry
    shows up.

Bug: T373318
Change-Id: I89abdca9c4ab8796a211df8b37c1bd7173a496e5
2024-10-02 00:45:22 +02:00
James D. Forrester
53b67ae0a6 Add namespace to remaining parts of Wikimedia\ObjectCache
Bug: T353458
Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
2024-09-27 16:19:10 -04:00
James D. Forrester
9e5c1e8ac7 Add namespace to IDBAccessObject and DBAccessObjectUtils
Bug: T353458
Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
2024-09-27 16:19:10 -04:00
Aaron Schulz
8a2776ed81 nametablestore: simplify NameTableStore::acquireId() and update comments
Make store() handle cache purging upon new ID insertion and fetching
of the winning ID when raced out. This avoids the reloadMap() call.

Remove connection flag hack in reloadMap() given 0cb0f0ba7.

Remove comments about retryStore() logic removed in 505bd8e70f.

Clean up return types for the ID:name arrays.

Change-Id: Ic57eb5e2b59da67c6511b935d9e68ffb595028fa
2024-09-24 16:55:22 +00:00
Adam Wight
188d2cbbb0 Remove unchecked exception annotations
Callers should not catch an unchecked exception, so it doesn't belong
in a function signature.  Unchecked exceptions indicate a coding error,
which by definition the code will not be able to handle correctly.

If any of these exceptions were supposed to be in response to an edge
case, user input, or initial conditions, then they should be changed
to a runtime error.  If the exception class cannot be changed, then
the annotation should include a comment explaining its purpose and
prognosis.

Bug: T240672
Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
2024-09-17 22:20:58 +02: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
dac84bf820 Add missing documentation to class properties in NameTableStoreFactory
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.

This also avoid false positive from phan

Change-Id: I4b182fda29e9cb9719c26fd01a609de2453be56d
2024-09-07 21:37:50 +02:00
Amir Sarabadani
505bd8e70f Storage: Remove transaction cancel callback from NameTableStore
What it's trying to achieve can be done much simpler by just making an
out of transaction connection via setting CONN_TRX_AUTOCOMMIT flag.

Removing this allows us to get rid of a large portion of transaction
management in rdbms library as this is the only place that uses cancel
callbacks.

Split out of I3cb1e30611b83c0

Bug: T372169
Change-Id: Idad029b6da6b09e084d466d282ef1145ebd8fe73
2024-08-30 20:41:08 +00:00
jenkins-bot
959ebbed6a Merge "objectcache: Consolidate WRITE_PRUNE_SEGMENTS into WRITE_ALLOW_SEGMENTS" 2024-08-12 16:16:10 +00:00
James D. Forrester
bc662aec9b Move Language and friends into Language namespace
Bug: T353458
Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
2024-08-10 13:36:30 +02: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
Timo Tijhof
60eca80b7b objectcache: Consolidate WRITE_PRUNE_SEGMENTS into WRITE_ALLOW_SEGMENTS
Instead of making the caller responsible for knowing what we do
internally at each step, rebrand WRITE_ALLOW_SEGMENTS as generally
"do stuff for segments", not only creating them, but also deleting
them.

* Easier to find and verify correct usage.
* Easier to understand parity between set() and delete().
* Documentation for deleteMulti() already said this, by mistake.
* Reduce amount of required knowledge.

There is only 1 usage in Codesearch Everywhere (in PageEditStash here
in core), with no known usage anywhere else. Hypothetically, if it
were used, this commit keeps compat by aliasing WRITE_PRUNE_SEGMENTS
to WRITE_ALLOW_SEGMENTS.

Change-Id: Iea10b23f06243814c35ccd02a4a878cdc1195c76
2024-08-09 22:45:04 +01:00
jenkins-bot
71285104f5 Merge "Add namespace to the root classes of ObjectCache" 2024-07-10 11:58:53 +00:00
Daimona Eaytoy
817dee64b4 Make PageUpdater accept PageIdentity
Internally it still uses WikiPage. While this change shouldn't have any
effect in theory, this is not guaranteed because WikiPage is not
stateless and if different parts of the code use different instances we
may see unexpected errors. Hence, this patch is limited to the bare
minimum so that it's easier to revert if necessary.

Change-Id: I2c18a62ccc04720a2ef25298515850e91fb288e9
2024-07-10 01:32:21 +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
frankie
17b2250683 Migrate MediaWiki.editstash to statslib
Modifies incrStatsByContent in order to migrate cache_misses, cache_hits to Prometheus backend

Bug: T359465
Change-Id: I78afac7437bc2849b64f43c23477d702b94e907b
2024-06-13 17:11:33 +00:00
Umherirrender
57d623f530 Change some type hints from IDatabase to IReadableDatabase
Use narrow interface if no writes are done

Change-Id: I55148c8b6fda8830a29a235c63fc118f636ab3e6
2024-05-24 16:11:12 +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
Ebrahim Byagowi
a717db8e60 Add namespace and deprecation alias to FormatJson
This patch introduces a namespace declaration for the
MediaWiki\Json to FormatJson and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I5e1311e4eb7a878a7db319b725ae262f40671c32
2024-05-16 16:28:01 +03:30
jenkins-bot
e5699d2e21 Merge "Formally deprecate code marked with @deprecated" 2024-05-04 12:47:59 +00:00
jenkins-bot
ba7fe379d0 Merge "SqlBlobStore: Directly store ES addresses in content table" 2024-05-03 16:23:31 +00:00
James D. Forrester
3ed6668745 Formally deprecate code marked with @deprecated
Some of these have been marked in-code as deprecated for a long while,
but haven't ever been announced in the RELEASE-NOTES (and later,
HISTORY) file, so let's mark them up now so we can get the ball rolling
at least.

Per Gergo, the AuthManager one was 'born deprecated' and should only
have been used by humans also reading the deprecation notice given in
the code, and indeed no uses are known to code search, so also emit
deprecation warnings there immediately; others will have to wait until
uses have been migrated.

Change-Id: I0c1c71d8f4293623039302da35d58d2a24367e97
2024-05-03 18:25:03 +03: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
Amir Sarabadani
4dbbbfa550 SqlBlobStore: Directly store ES addresses in content table
Introduce "es:" which has ?flags= as url parameter and store that
instead.

Bug: T362566
Change-Id: I9d8409fdbd757ef061aa38ff6248cf614f6ef2de
2024-04-30 12:20:32 +02:00
Umherirrender
e10441e555 IReadableDatabase::select cannot return false
Remove check for false from IDatabase::select as this is not possible
A DBQueryError is thrown (documented since efda8cd3 / I056b7148)

Use IResultWrapper::numRows to check for empty IResultWrapper

This ignores includes\libs\rdbms as QUERY_SILENCE_ERRORS is an internal
option to get false from this function

Change-Id: I4b2fc26ca0e68612f6beadc01e68097a74962c84
2024-04-18 22:48:25 +02:00
jenkins-bot
e27506b056 Merge "rdbms: Remove more usages of DBAccessObjectUtils::getDBOptions()" 2024-02-27 14:14:12 +00:00
Amir Sarabadani
b61ebd5277 rdbms: Remove more usages of DBAccessObjectUtils::getDBOptions()
Also remove the fallback index and options as it was agreed upon in the
ticket as its needlessly complicates the function and is only used in
SqlBlobStore which can have its own copy of the function

Bug: T354194
Change-Id: I38b179c9bfeb7d2c3e92fa4845dce19558f45a0f
2024-02-22 12:12:50 -05:00
Amir Sarabadani
c04f1d64d6 Remove IDBAccessObject from being implemented in many classes
This is inconsistent with the access pattern of other constants in
MediaWiki. it's also confusing (e.g. it's unclear to a newcomer why
UserFactory is implementing IDBAccessObject) and it's prone to clashes
(e.g. BagOStuff class has a clashing constant).

It has been already announced: https://w.wiki/9DAX

Bug: T354194
Change-Id: Ic2357634b8385d65b55db2b557191419b06c40e0
2024-02-19 10:50:02 +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
jenkins-bot
5a7862cba4 Merge "Directly call IDBAccessObject constants instead of implementing it" 2024-01-15 06:09:51 +00:00
Timo Tijhof
937847b26a Replace various magic numbers with easy-to-verify expressions
Follows-up I8518e0488 (9c02258a04).

Instead of documenting how to compute the number to manually verify
it, use the expression directly. This should make it significantly
easier to understand, verify, and modify.

Noteworthy:

* Language.php, I kept 31_556_952 as-is because the
  calculation would otherwise involve a float. It also has the benefit
  of allowing the long durations to build upon that as a given number.

* SqlBlobStore.php, remove this irrelevant default value as it is
  unreachable. The only call to new SqlBlobStore is BlobStoreFactory,
  which always calls setCacheExpiry. For back-compat and to keep
  tests as-is, move to re-used constant between class and config.

Change-Id: I86b034883bd7efdf93b8365b43178af826f1c703
2024-01-11 15:12:24 +11:00
Amir Sarabadani
0daee7697d Directly call IDBAccessObject constants instead of implementing it
Instead of calling self::READ_* on these constants, just directly call
it.

Since these classes are public and might be relied on directly in other
places, we can't remove the "implements IDBAccessObject" yet but we will
start doing that soon.

Bug: T354194
Change-Id: I3e26b9fc7f93efdfc55a1790a7cdfa5c0d562303
2024-01-10 22:22:34 +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
jenkins-bot
3e07889c70 Merge "Inline once-called short private methods to its caller, part 1" 2023-12-19 00:05:45 +00:00
Amir Sarabadani
a778d3fea7 Inline once-called short private methods to its caller, part 1
This makes the code easier to read to avoid jumps and improves
encapsulation by not allowing the rest of the class having access to the
logic. Of course, if needed then some code can be refactored out again
but for now let's not do YAGNI.

Change-Id: Ic37524e386fc04fd67e33768417ff8425f85b0ca
2023-12-18 23:43:32 +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
Tim Starling
9c02258a04 Use thousands separators in selected integer literals
For readability. Allowed since PHP 7.4.

I searched for integer literals of 6 or more digits, and also changed
some nearby smaller numbers for consistency.

Bug: T353205
Change-Id: I8518e04889ba8fd52e0f9476a74f8e3e1454b678
2023-12-12 09:22:45 +11:00
Ammarpad
e801a85ff5 PageEditStash: Deprecate passing Wikipage to parseAndCache()
There are no remaining callers with Wikipage

Change-Id: I33bcda004399348cab47a12673ca757668ab7d18
2023-11-28 12:42:15 -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
Subramanya Sastry
c8d0470f4b Make ParsoidOutputAccess a wrapper over ParserOutputAccess
* Updated ParserOutput to set Parsoid render ids that REST API
  functionality expects in ParserOutput objects.
* CacheThresholdTime functionality no longer exists since it was
  implemented in ParsoidOutputAccess and ParserOutputAccess doesn't
  support it. This is tracked in T346765.
* Enforce the constraint that uncacheable parses are only for fake or
  mutable revisions. Updated tests that violated this constraint to
  use 'getParseOutput' instead of calling the parse method directly.
* Had to make some changes in ParsoidParser around use of preferredVariant
  passed to Parsoid. I also left some TODO comments for future fixes.
  T267067 is also relevant here.

PARSOID-SPECIFIC OPTIONS:
* logLinterData: linter data is always logged by default -- removed
  support to disable it. Linter extension handles stale lints properly
  and it is better to let it handle it rather than add special cases
  to the API.
* offsetType: Moved this support to ParsoidHandler as a post-processing
  of byte-offset output. This eliminates the need to support this
  Parsoid-specific options in the ContentHandler hierarchies.
* body_only / wrapSections: Handled this in HtmlOutputRendererHelper
  as a post-processing of regular output by removing sections and
  returning the body content only. This does result in some useless
  section-wrapping work with Parsoid, but the simplification is probably
  worth it. If in the future, we support Parsoid-specific options in
  the ContentHandler hierarchy, we could re-introduce this. But, in any
  case, this "fragment" flavor options is likely to get moved out of
  core into the VisualEditor extension code.

DEPLOYMENT:
* This patch changes the cache key by setting the useParsoid option
  in ParserOptions. The parent patch handles this to ensure we don't
  encounter a cold cache on deploy.

TESTS:
* Updated tests and mocks to reflect new reality.
* Do we need any new tests?

Bug: T332931
Change-Id: Ic9b7cc0fcf365e772b7d080d76a065e3fd585f80
2023-10-13 15:03:03 -05:00
Bartosz Dziewoński
c43b44c7d5 DerivedPageDataUpdater: Do HTMLCacheUpdate on file page redirect changes
Previously, we never scheduled HTMLCacheUpdate jobs on file page edits
or creations, but it is necessary when the page's redirect target has
changed, or it's created as a redirect.

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

Bug: T238426
Change-Id: I6775a4fb7239d49de88e22e45082ab474cfaaa8b
2023-09-26 04:32:20 +02: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
4031b0a0d8 DerivedPageDataUpdater: Fix unset $this->pageState['oldRevision']
In only this code path, $this->pageState['oldRevision'] was left unset.
Other code expects it to be null, but not unset.

Change-Id: I15023834ffbac307924aee4028f3b7fe75fbabeb
2023-09-26 04:22:20 +02:00