Commit graph

524 commits

Author SHA1 Message Date
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
jenkins-bot
4d1e278105 Merge "Migrate another major batch to SelectQueryBuilder" 2023-09-20 13:39:17 +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
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
James D. Forrester
b16be7a36c Namespace TitleFormatter under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
2023-09-19 05:17:18 +00:00
Amir Sarabadani
8cd2646ba9 Migrate several services to use ICP instead of LB
Bug: T330641
Depends-On: I4b8a8ecd2efd0e872dbf6b24762401f95a7654c7
Change-Id: Ic4359b05f7f4fdc2a25a2f11aae33c63a2836bc9
2023-09-16 10:04:13 +02:00
Amir Sarabadani
52f33d7d72 Bump phan to 0.13.0
Change-Id: I57c25d953700ca1cd97cc71ec2a28cbeb9ee875f
2023-09-11 19:22:44 +02:00
Timo Tijhof
e56552557f deferred: Decouple DeferredUpdates from MediaWikiServices
* Create task-specific methods with simple defaults that require no
  mocking or stubbing of any kind, as used by the pure unit tests
  where service container (and by extent, storage services) are
  disabled.

* Remove all use of global variables, LBFactory, JobQueue,
  StatsdFactory, and RequestContext.

Bug: T265749
Change-Id: If85c448d2d1b806e70f641f06263680d49c6eeec
2023-09-09 20:42:02 +01: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
f4e68e055f Reorg: Move Status to MediaWiki\Status\
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.

Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
2023-08-25 15:44:17 +02:00
Amir Sarabadani
15a278189f Reorg: Move MWTimestamp to MediaWiki\Utils
Bug: T321882
Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
2023-08-19 05:53:40 +02:00
jenkins-bot
91e4316330 Merge "objectcache: Remove IExpiringStore interface" 2023-08-08 20:31:46 +00:00
Derick Alangi
2abbb1a774 objectcache: Remove IExpiringStore interface
Interface was deprecated since 1.35 in favor of ExpirationAwareness
or StorageAwareness interfaces. No longer used anywhere, see dependent
patches.

Depends-On: Ida557b3180eb5e7ebae46968142b4f154f26ffbc
Depends-On: I3d6fbf535560655472ade27c37b0e42b3e11a535
Depends-On: I2b0a669d41d9e6a8a859cba314c0e9e4c0ef40d7
Depends-On: I776040c2c8f61e25ae986e93bb1975fdd8bf9dd5
Change-Id: I9c5ffa9f51aec6356e3e27458fd098a37cd754ad
2023-08-08 20:15:03 +00:00
jenkins-bot
a8d3383444 Merge "Mass migrate Database::insert calls to InsertQueryBuilder" 2023-08-08 11:01:32 +00: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
Subramanya Sastry
5dd1b08b26 Remove unused ParsoidOutputAccess from PageUpdater classes
This usage moved to ParsoidCachePrewarmJob.php that was
created in 99d989087d

Change-Id: Ic0e57bdd7c572094daa92a9c288320edd88e7b58
2023-08-03 16:25:57 -05:00
Daimona Eaytoy
485e47ff10 tests: Avoid database usage when possible
We would like to remove DB access in non-database PHPUnit tests. As a
first step, avoid database usage in tested code when possible. In
particular:
- In NameTableStoreFactory, avoid domain ID normalization if the
  provided ID is already false.
- In SpecialDoubleRedirects, do not acquire a DB connection until it's
  needed (which is just one place).
- Use editPage() in TitleDefTest instead of a DIY implementation, and
  add `@group Database` accordingly.
- Avoid parsing titles in ContentHandler tests that don't need to parse
  titles. Among the many dependencies of parsing titles is the interwiki
  lookup, which requires DB access.
- Also remove test cases that used the "Gadget" namespace; it doesn't
  exist in core, so these pages were actually in the mainspace.
- Mock the database in CategoriesRdfTest. The only two methods that use
  the database were already being mocked.
- Add `@group Database` to test classes that are intentionally using the
  Database, mainly via getTestUser().

Bug: T155147
Change-Id: I9385fe14cfeb6b7b7378cc322d510034c4ee0711
2023-07-31 00:46:13 +00:00
jenkins-bot
dc3578a910 Merge "Migrate more calls of Database::select* to SelectQueryBuilder" 2023-07-26 11:21:08 +00:00
Amir Sarabadani
7432b21816 Migrate more calls of Database::select* to SelectQueryBuilder
Using a php parser written on top of ANTLR4, done semi-automatically.

I checked everything and made adjustments.

Bug: T311866
Change-Id: I6150c6909bce8f3dbd745a26380cc0af9d9c547f
2023-07-26 13:01:28 +02:00