Commit graph

1047 commits

Author SHA1 Message Date
Tim Starling
d5ac0b40d0 BacklinkCache: cleanup, use fullResultCache with limit
* In queryLinks(), use the full result cache even if a limit is
  specified. Truncate the result in the caller if necessary.
* Remove the confusing boolean parameter from partitionResult(). Make it
  always false and fix up the results afterwards. So the batches are
  always the inclusive start and end IDs, false is never returned.
* Inject a logger instead of using wfDebug()
* Use private not protected. Defaulting to protected was just a coding
  style quirk I had at the time.
* In queryLinks(), use early return.
* In hooks BacklinkCacheGetConditionsHook and BacklinkCacheGetPrefixHook
  adjust the parameter type hint to avoid the need for a Phan override.

Change-Id: Ia53f494633affe48316f0a8b63d03596239ad53c
2024-06-28 15:04:16 +10:00
Umherirrender
9879723ef3 Use namespaced classes (1)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
2024-06-16 20:18:23 +02:00
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
jenkins-bot
ce3767dd85 Merge "user: Introduce UserOptionsStore" 2024-06-13 13:06:27 +00:00
jenkins-bot
0d29a60676 Merge "User objectCacheFactory methods not deprecated ObjectCache methods" 2024-06-12 12:42:05 +00:00
Tim Starling
cdc5178150 user: Introduce UserOptionsStore
Refactoring:

* Break out the database access part of UserOptionsManager to a separate
  class hierarchy implementing interface UserOptionsStore. It's
  basically a key/key/string-value store, very simple. The complex
  parts of user options storage remain in UserOptionsManager.
* Bundle the UserOptionsManager caches into a per-user cache object. I
  was adding a couple more and it was getting tedious.

Start integrating GlobalPreferences with UserOptionsManager:

* Have an array of stores. There's always a local store, and extensions
  can add stores via an attribute.
* Add $global parameter to UserOptionsManager::setOption(), allowing
  this method to update or override global options.
* Rename loadOptionsFromDb to loadOptionsFromStore.
* Move the local override feature from GlobalPreferences to core.

Bug: T323076
Change-Id: Ib3623b723557c819bc0ffdf21a4ffcb070eb298b
2024-06-12 01:27:57 +00:00
jenkins-bot
f9ae750806 Merge "Use $stage::CONSTRUCTOR_OPTIONS in DefaultOutputPipelineFactory" 2024-06-11 02:38:38 +00:00
jenkins-bot
1da7b2f8ae Merge "Implement RedirectStore service" 2024-06-11 02:27:40 +00:00
Máté Szabó
a1576cba3c Implement RedirectStore service
I469de6f85e405e8ddbe7abaa5b99b77cb9cf415d added an initial RedirectStore
implementation, but it has remained a stub despite the corresponding
task being closed. So, flesh out the implementation by moving the
corresponding logic from WikiPage.

Soft-deprecate WikiPage::insertRedirectEntry() accordingly.

Bug: T290639
Change-Id: Ia500df45bc969ce77b6b2a06bfec10e32c00b931
2024-06-11 02:03:55 +00:00
C. Scott Ananian
292709cc13 Use $stage::CONSTRUCTOR_OPTIONS in DefaultOutputPipelineFactory
Rather than have DefaultOutputPipelineFactory::CONSTRUCTOR_OPTIONS be a
union of all the options needed by all the stages, allow each stage to
define its own CONSTRUCTOR_OPTIONS and pass a Config object to the
DefaultOutputPipelineFactory service.

In the process, move the $options and $logger properties into the
abstract superclass, since they are passed to every stage.

Bug: T363764
Followup-To: I64aeb81b395ba84e1d839dfbd31decf16c337cd0
Change-Id: I7d386b22c7d8e99b6dfe4cf798069914ac9af373
2024-06-10 20:53:21 -04:00
Arlo Breault
6011792afa Refactor DI in OutputTransform stages
Bug: T363764
Change-Id: I64aeb81b395ba84e1d839dfbd31decf16c337cd0
2024-06-10 16:30:06 -04:00
Arlo Breault
276fc1608a Inject MobileContext in DefaultOutputPipelineFactory
Change-Id: I613893fa236be956a4850a52a03a40e620c7ce64
2024-06-10 15:11:01 -04:00
Wandji69
1665ea876f User objectCacheFactory methods not deprecated ObjectCache methods
Bug: T363770
Change-Id: I2335b315bec6a540409492df4891c518640966d5
2024-06-06 09:59:24 +01:00
C. Scott Ananian
64d343353e [HtmlOutputRendererHelper] Use ParserOutputAccess
One more step in gradually replacing uses of ParsoidOutputAccess with
ParserOutputAccess.  This is mostly just inlining the code from
ParsoidOutputAccess (which already uses ParserOutputAccess internally)
and then removing dead code.

Change-Id: I87d6568d9dc71bc11f406ea3c31ce86e01667e05
2024-06-05 10:37:36 -04:00
jenkins-bot
742681d2f5 Merge "[HtmlInputTransformHelper] Use ParserOutputAccess" 2024-05-28 17:23:25 +00:00
jenkins-bot
07ece77e44 Merge "Add MediaWiki\Watchlist namespace to the related classes" 2024-05-23 23:12:10 +00:00
jenkins-bot
2de29c2af5 Merge "ServiceWiring: Drop _LocalClusterCache service" 2024-05-23 20:17:37 +00:00
jenkins-bot
7fc3b17a9e Merge "LoginSignupSpecialPage: Support &display=popup" 2024-05-23 16:03:19 +00:00
jenkins-bot
024e0202a4 Merge "Allow undeletion of IP revisions when temp accounts are enabled" 2024-05-23 14:37:16 +00:00
Derick Alangi
83bb1d45db
ServiceWiring: Drop _LocalClusterCache service
With the ObjectCacheFactory refactor in T358346, this service is
pretty much used in 2 places, (1) service wiring which can be replaced
and (2) in MediaWikiIntegrationTestCase.

The service can be removed entirely and the local cluster cache gotten
from the ObjectCacheFactory service injected via service wiring. Hence,
usage of this internal service can be removed.

NOTE: See followup: 7475063 for the TODO to drop this service entirely.

Change-Id: I173f04456df6cc1782cec2f16d6653c6b0826dce
2024-05-23 13:36:33 +01:00
Dreamy Jazz
400c2a62ee Allow undeletion of IP revisions when temp accounts are enabled
Why:
* When wgAutoCreateTempUser['enabled'] is true, calling ActorStore
  ::acquireActorId for an IP address user will throw a
  CannotCreateActorException to prevent attributing actions to IP
  addresses.
* When using Special:Undelete to undelete a page that has IP
  addresses who have made edits, the UndeletePage call to the
  ActorStore::acquireActorId causes an exception.
* However, the revisions already existed so (similar to importing
  revisions) it does not represent a leak of the IP address.
* As such, it should be possible to undelete a page with revisions
  performed by IP addresses.

What:
* Add ActorStore::getActorStoreForUndelete which works the same
  as ActorStore::getActorStoreForImport. Having methods that
  are named for undelete / import avoids the usage for other
  code that should use ::getActorStore instead.
* Add RevisionStoreFactory::getRevisionStoreForUndelete which
  uses the ActorStore returned by ActorStore
  ::getActorStoreForUndelete.
* Update the PageCommandFactory to take the RevisionStoreFactory
  and then call ::getRevisionStore for all but UndeletePage where
  the ::getRevisionStoreForUndelete method is called.

Bug: T362019
Bug: T365669
Change-Id: Ia7c583c625843f4f400e1c4aa7ea360519e63c87
2024-05-23 09:30:48 +00:00
Bartosz Dziewoński
5623b2e44c LoginSignupSpecialPage: Support &display=popup
Setting this URL parameter will replace the default skin with a
"micro-skin" that omits most of the usual interface elements,
making the page suitable to be displayed in a small popup window.
Its design (such as it is) is mostly based on Vector 2022.

In the future, we might allow normal skins to serve this mode too,
if they advise that they support it by setting a skin option.
For now that is out of scope.

The login/signup process is otherwise completely normal. To make use
of it, launch the login page in a popup, and set &returnto=... to
redirect back to your own success page, which should communicate the
successful login to your app and then close itself.

The display=popup / display=page vocabulary is borrowed from the
OpenID Connect spec.

Bug: T362706
Change-Id: Ic7cbbe98344b25d2e965750e0c4429ce157163ed
2024-05-22 22:06:31 +02:00
jenkins-bot
08ef39abfd Merge "Move ParsoidOutputAccess::supportsContentModel() into Parsoid SiteConfig" 2024-05-22 16:46:31 +00:00
jenkins-bot
df0fa2b09c Merge "Parser: Inject service LanguageNameUtils" 2024-05-22 15:31:12 +00:00
C. Scott Ananian
1c0089772d [HtmlInputTransformHelper] Use ParserOutputAccess
One step in gradually replacing uses of ParsoidOutputAccess with
ParserOutputAccess.  This is mostly just inlining the code from
ParsoidOutputAccess (which already uses ParserOutputAccess internally)
and then removing dead code.

Change-Id: I9807149c30f4bfe06fd7ad12f96c13816c22aa9c
2024-05-22 10:58:38 -04:00
C. Scott Ananian
a565e388f9 Move ParsoidOutputAccess::supportsContentModel() into Parsoid SiteConfig
The `supportsContentModel` method is really querying Parsoid for the
set of content models it supports, so it makes sense to put it in the
Parsoid-specific SiteConfig service.

This is part of the work to deprecate and remove ParsoidOutputAccess.

Change-Id: I81eb2df8cef93ede95361a4e03185b3d58e5b84b
2024-05-22 10:57:37 -04:00
Ebrahim Byagowi
12660db261 Add MediaWiki\Watchlist namespace to the related classes
This adds MediaWiki\Watchlist namespace to the classes of watchlist
directory and adds deprecation notice since 1.43 to the just created
unnamespaced aliases of the classes.

Bug: T353458
Change-Id: I4234f8fe62bb3bde6f5271c7ba31a2420b0f4b90
2024-05-22 01:23:10 +03:30
Derick Alangi
7475063bfd objectcache: Complete refactor of ObjectCache.php
This patch completes the rest of the ObjectCache refactor and
migrates methods to the appropriate class while deprecating them
in `ObjectCache.php`.

It also moves the `_LocalClusterCache` internal service logic
into ObjectCacheFactory and calls that instead making sure that
wiring code stays wiring code and let the class do the heavy lifting.

`::makeLocalServerCache()` is retained as a static method in the
ObjectCacheFactory class because it's called early in Setup.php
before the services container is available (so it needs to be stand-
alone).

To add, we also converts all global variables that were used in the
`ObjectCache.php` class into the config schema approach and retrieves
them using ServiceOptions injected in service wiring.

NOTE: MediaWikiIntegrationTestCase::setMainCache() was slightly
rewritten to take care of service reset which throws away the cache
object preserved by setInstanceForTesting() after service reset.
Instead, we preserve the object via MainConfigNames::ObjectCaches
setting with a factory closure which returns the correct cache object.

As a nice side effect of the above, the setInstanceForTesting() method
was removed entirely.

As a follow-up to this patch, I would like to remove the internal
_LocalClusterCache service in a stand-alone patch.

Bug: T363770
Change-Id: Ia2b689243980dbac37ee3bcfcbdf0683f9e1779b
2024-05-21 14:03:08 +00:00
jenkins-bot
37ae84be8b Merge "Add namespace and deprecation alias to WatchedItemStore" 2024-05-21 10:54:43 +00:00
Fomafix
66aa439d00 Parser: Inject service LanguageNameUtils
Change-Id: Ia9884f991550c96e4d9bbca9bfb882144716cd24
2024-05-20 19:23:37 +00:00
Ebrahim Byagowi
1be5d40e56 Add namespace and deprecation alias to FileBackendGroup
This patch introduces a namespace declaration for the
MediaWiki\FileBackend to FileBackendGroup and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Id33b6bfa56131978900199786b0082481c6c54a5
2024-05-20 20:06:00 +03:30
Ebrahim Byagowi
49fe440c63 Add namespace and deprecation alias to WatchedItemStore
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchedItemStore and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I820a3512440ba5a1de13e8470ccf5845918f3198
2024-05-20 19:14:17 +03:30
Reedy
5ab70409f5 Namespace includes/password
Bug: T353458
Change-Id: I1a701b5b7ff65356692abb0efde9a2207b6135b6
2024-05-18 16:17:38 +01:00
Ebrahim Byagowi
1e4f59b724 Add namespace and deprecation alias to WatchedItemQueryService
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchedItemQueryService and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Ib1b5c19c89087940987730939e84c8cd35cd3760
2024-05-18 01:50:29 +03:30
Tim Starling
a5372218b7 block: Deprecate and stop using $wgBlockTargetMigrationStage
* Deprecate and stop using $wgBlockTargetMigrationStage. Remove
  block_target migration code.
* Make the $schema parameters to DatabaseBlockStore methods default to
  SCHEMA_BLOCK. Avoid passing these parameters where possible.
* Remove cleanupBlocks.php
* Deprecate DatabaseBlock static methods which try to present the old
  schema for b/c.

Bug: T362133
Change-Id: I845bad8cc09a4528fef46a6f9d490ebdec881d99
2024-05-10 15:54:17 +10:00
Bartosz Dziewoński
f0c7fa9234 Move section edit links outside headings (new heading HTML)
Legacy parser can now output headings using a more accessible markup,
which is also identical to the markup used by the Parsoid parser.

Changes to client-side JS and CSS necessary to support the new markup
have already been merged in earlier commits.

includes/skins/Skin.php
includes/ServiceWiring.php
* Define a new skin option, 'supportsMwHeading', which can be used
  to toggle the new markup per-skin.
* Update the built-in fallback skin to enable it. This affects the
  output in parser tests.

docs/config-schema.yaml
includes/config-schema.php
includes/config-vars.php
includes/MainConfigNames.php
includes/MainConfigSchema.php
* Add a new configuration setting, 'ParserEnableLegacyHeadingDOM',
  which can be used to toggle the new markup per-site.

includes/OutputTransform/Stages/HandleSectionLinks.php
* Output new heading HTML for skins that enabled the option.

tests/*
* Duplicate parser tests that cover heading generation to cover both
  new and old markup. Update other parser tests to use new markup.
* Add some unit and integration tests for the behavior of the skin
  option and some parser tests for edge cases of the new markup.

Bug: T13555
Change-Id: I1180169a8e83af834c2984ba16089e6277f2a8dd
2024-05-06 12:25:33 -04:00
jenkins-bot
406014bbf4 Merge "WatchedItemStore: Switch to StatsFactory" 2024-05-05 14:25:37 +00:00
Máté Szabó
ae5c0ffe80 WatchedItemStore: Switch to StatsFactory
Switch WatchedItemStore metrics to StatsFactory, preserving the existing
StatsD metric names as compatibility mappings. Add assertions for the
metrics in unit tests.

Bug: T359256
Change-Id: I7cc84abbbbb005e598423099af7bad818c78123b
2024-05-05 15:55:10 +02:00
Máté Szabó
4920e1a71e PageStore: Migrate to StatsLib
Use StatsFactory for emitting metrics from PageStore and add assertions
for the new metrics.

Bug: T359374
Change-Id: Id099f54eb79a2dce078259cf9c13e548c1ec56f2
2024-05-05 15:36:33 +02:00
jenkins-bot
f0a2f1dd1d Merge "fix: use objectcachefactory methods instead of deprecated objectcache methods" 2024-05-05 11:08:07 +00:00
Irina Balaban
dc989f680f fix: use objectcachefactory methods instead of deprecated objectcache methods
Bug: T363770
Change-Id: Ie732f6925ec2b1316a60bebbe3c27f963c9dacb1
2024-05-05 12:40:30 +03:00
Umherirrender
ad517bed05 UserEditTracker: Replace deprecated ActorMigration::getWhere
Migrate database access to SelectQueryBuilder instead of using the
queryInfo array returned by ActorMigration

Bug: T344971
Change-Id: Ib405fcb71766793dc3c68c463564a64c8c008927
2024-05-04 09:36:27 +03:00
Kosta Harlan
6efd008f33 TempAccounts: Rate limit acquisition of temp account names
Why:

- We don't want to allow unlimited acquisition of temp account names.
  These should be rate limited in similar way to how we limit the
  creation of temp accounts

What:

- Provide a TempAccountNameAcquisitionThrottle, and use it in the
  acquireName() method
- Set a default that is 10 times the limit of
  TempAccountNameCreationThrottle

Depends-On: If660aad1d0f04f366414084aff3f88484a19d416
Bug: T343101
Change-Id: I99d5973498a89ac227847de5837c0a8e895c28fb
2024-04-23 13:33:57 +00:00
Derick Alangi
e2f6161980
objectcache: Inject DBLoadBalancerFactory into ObjectCacheFactory
This patch does the follow with a few gotchas:

* Properly inject LBFactory service into ObjectCacheFactory to be
  used where needed.

* doc: Pull in relevant documentation from ObjectCache class into
  the ObjectCacheFactory class and also update docs in the OCF
  class to be more accurate with the code.

* This patch also resolves an issue that caused an infinite loop in
  SqlBagOStuff making connections to the DB not to be reused within
  a request there by crashing the application (when the index.php
  entry-point) is accessed directly and every cache type is set to
  CACHE_ANYTHING. Meaning in LocalSettings, only `$wgMainCacheType`
  is set and its relatives (ParserCache, MessageCache, etc) aren't
  set.

NOTES
=====
-> A circular dependency would occur in OCF when injecting LBFactory:

   DBLoadBalancerFactory->DBLoadBalancerFactoryConfigBuilder
   ->LocalServerObjectCache->ObjectCacheFactory->DBLoadBalancerFactory

   directly, so in order to resolve this, we'll inject a closure instead
   and call that to retrieve the service when needed. The solution above
   is already used in other services today in the code. As an example,
   you can see SignatureValidatorFactory.

-> In MainConfigSchema.php, the CACHE_ANYTHING key got removed
   in https://gerrit.wikimedia.org/r/c/mediawiki/core/+/955771
   and this is a change in behavior. So we need to recompute the
   value of CACHE_ANYTHING's ID via service wiring for DB operations.

Test plan
=========

This patch is fairly straight forward, all it does is do some DI of
a service into OCF (via a callable). No change in behavior should be
expected in your local wiki.

So if your local wiki is still running smoothly when you hit the
`/index.php` entry-point directly and other cases, then everything
should be working fine.

Bug: T362686
Change-Id: I305ef0c377a023236b8ed9a101762813f32e6cd0
2024-04-18 22:04:16 +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
Thalia
14a2ec687b Remove ContributionsLookup service
This was added in 300fcfd00b
for an experimental REST endpoint that was removed in
c3fe4b037d, and is now unused.

Bug: T305506
Change-Id: I900c00747f77af6b0844105e9681c9d4acfe1ad5
2024-04-15 16:29:47 +00:00
jenkins-bot
b3affdea7e Merge "LogFormatterFactory: Inject LinkRenderer too" 2024-04-03 18:30:14 +00:00
jenkins-bot
62da79f197 Merge "Add new conditional default conditions for user options: anon and named" 2024-04-03 13:24:41 +00:00
Steph Toyofuku
1e26f420dc Add new conditional default conditions for user options: anon and named
Adds two new conditional user option default conditions CUDCOND_ANON and
CUDCOND_NAMED, for the purpose of allowing the specification of a
separate default user option for logged-out users.  We're taking two
different approaches to the targeting of logged-out users (anon vs
named) because of the temporary users project - anon will not include
temporary users while named will allow us to target only fully created
user accounts.  This will be ultimately be used for the rollout of the
reading accessibility settings menu

Bug: T360098
Change-Id: I316d231330159770f05234dd2f5fdb7d07531002
2024-04-02 14:46:53 -07:00
Bartosz Dziewoński
0b0ebabea2 LogFormatterFactory: Inject LinkRenderer too
Change-Id: I1edfc9cc4e2ad794b226b4f8be03c3846bbeb84d
2024-04-02 21:24:49 +02:00