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
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
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
This was added in 300fcfd00b
for an experimental REST endpoint that was removed in
c3fe4b037d, and is now unused.
Bug: T305506
Change-Id: I900c00747f77af6b0844105e9681c9d4acfe1ad5
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
* Fix main makeLocalServerCache() call in ObjectCacheFactory::newFromId
to include a default keyspace, since wgCachePrefix is false by default
(including at WMF).
* Idem for ExtensionRegistry.
* Dependency inject the domain ID so that service wiring does the
correct thing when doing cross-wiki operations.
This is a followup on: I3179a387486377c6a575d173f39f82870c49c321.
Bug: T358346
Bug: T361177
Change-Id: Ibbb250465529810b8593f90bbb8330af0a2c3dbd
This is an alternate for the workaround in I5987c4f1c3 (c98aeff078).
The service class should not need awareness of MW_PHPUNIT_TEST, or
otherwise have a mixed kind-of-yes/kind-of-not DB dependency.
With this patch, DefaultOptionsLookup is reverted to remove the
test-specific workaround in favour of using StaticUserOptionsLookup
in MediaWikiServices::disableStorage.
This is already called by MediaWikiIntegrationTestCase for tests
that don't enable the database.
Bug: T155147
Depends-On: I906450a4ac2dc51cdc536fbc978661b06f62f0a4
Change-Id: I8720d32fcfb18f7468e2c4b82412fe8664e28ddc
ObjectCache is already doing a lot of factory pattern logic like
creating instances of the various BagOStuff, this should really be
the responsibility of the factory servicet.
This patch introduces a proper factory (ObjectCacheFactory) to handle
the responsibility of creating various instances of BagOStuff. Since
`newFromParams()` is a static function that gets passed in configuration
of $wgObjectCaches, that can stay that way (to keep supporting how we do
this in prod today).
Technical Breaking Change: `ObjectCache::makeLocalServerCache()` now has
a parameter and requires it but there are no callers of this method outside
MW core hence it is safe to change (and this patch update all callers) to
work correctly. Cache prefix is gotten from global state because sometimes
at this stage, the services container is not available.
Bug: T358346
Change-Id: I3179a387486377c6a575d173f39f82870c49c321
This allows HtmlOutputRendererHelper to function for all kinds of
content.
Bug: T311728
Bug: T311648
Bug: T359426
Change-Id: Ib32af7cf2a7ad989eb0b13ecca37c857fc9199ec
Why:
- The pathway to creating a regular account is different from that of a
temporary account. It makes sense to rate limiting creation of these
two types of accounts at different rates.
What:
- Add a TempAccountCreationThrottle config with a restrictive default
that matches the existing production configuration of
AccountCreationThrottle (6 creations per day)
- Update resetAuthenticationThrottle.php to support resetting the temp
account creation throttle
- For now, not adding an equivalent hook for account creation throttle's
ExemptFromAccountCreationThrottle
Bug: T357777
Change-Id: Ibf36ac96f717107bace6f0a3326f79ed129a1dfe
This reverts commit cb09a27cc2.
The class is not very useful as it is now, due to performance issues
(T169027#9342985). The Graph extension is not going to use iframes
(T334940#9537862) and that was the only concrete feature for this, so
making the class usable in practice is unlikely to get prioritized.
No point in leaving the code in its current halfway state.
Bug: T222807
Bug: T169027
Change-Id: Id1b5193975435b58aebc225528e30f04456d0c41
Why
* ApiQueryWatchList allows filtering anon users or not-anon users.
It is not obvious wether temporary users should be considered
anon for these purposes.
* The equivalent filters in recent changes group temporary users
with anonymous users (T343322).
* Since ApiQueryWatchlist queries the recentchanges table, and
shares many filters with recent changes, it makes sense to
filter the same way in both, and therefore to group temporary
users with anonymous users.
What
* Update queries in WatchedItemQueryService to group temporary
users with anonymous users for FILTER_ANON and FILTER_NOT_ANON.
* Don't change the 'anon' flag, because the other APIs flag
temporary users with anon=false.
* Instead add a 'temp' flag for temporary users.
Bug: T358693
Change-Id: I4cd3a4d0c5f4f488933cf3f06dee62a9beb85440
* Inject from ServiceWiring via PoolCounterFactory.
* In production we use PoolCounterClient (which is backed by
our poolcounterd service), we also offer PoolCounterRedis for
third parties. Replace the local logger in the Redis variant in
favour of the built-in one.
* Update PoolCounterWork to adopt this as well. Expose it via getter
to here, so that DI works all the way, including for the existing
test.
Bug: T358901
Change-Id: I5413825a0172b186d58e85bbc3cc93697b174c27
We're already constructing service options with the list of options the
service needs. Let's stick to the light-weight version and avoid injecting
the entire MainConfig object just to get 2 settings when we can just list
it them in CONSTRUCTOR_OPTIONS.
Change-Id: I0612ca1c129c55664f29e178959c017d849eb218
Set the render ID for each parse stored into cache so that we are able
to identify a specific parse when there are dependencies (for example
in an edit based on that parse). This is recorded as a property added
to the ParserOutput, not the parent CacheTime interface. Even though
the render ID is /related/ to the CacheTime interface, CacheTime is
also used directly as a parser cache key, and the UUID should not be
part of the lookup key.
In general we are trying to move the location where these cache
properties are set as early as possible, so we check at each location
to ensure we don't overwrite a previously-set value. Eventually we
can convert most of these checks into assertions that the cache
properties have already been set (T350538). The primary location for
setting cache properties is the ContentRenderer.
Moved setting the revision timestamp into ContentRenderer as well, as
it was set along the same code paths. An extra parameter was added to
ContentRenderer::getParserOutput() to support this.
Added merge code to ParserOutput::mergeInternalMetaDataFrom() which
should ensure that cache time, revision, timestamp, and render id are
all set properly when multiple slots are combined together in MCR.
In order to ensure the render ID is set on all codepaths we needed to
plumb the GlobalIdGenerator service into ContentRenderer, ParserCache,
ParserCacheFactory, and RevisionOutputCache. Eventually (T350538) it
should only be necessary in the ContentRenderer.
Bug: T350538
Bug: T349868
Followup-To: Ic9b7cc0fcf365e772b7d080d76a065e3fd585f80
Change-Id: I72c5e6f86b7f081ab5ce7a56f5365d2f75067a78
Why:
* Following T345578, the ActorStore throws an error on
attempting to create an actor whose name is their IP address
if temporary accounts are enabled.
* For the specific case of importing old revisions, we need to
be able to create new actors whose name is their IP address,
while still generally disallowing it.
What:
* Add $allowCreateIpActors flag to ActorStore, and check for
it during actor name validation.
* Set the flag from ActorStoreFactory::getActorStore depending
on whether temporary users are enabled.
* Add ActorStoreFactory::getActorStoreForImport, which sets
flag to true.
* Add RevisionStoreFactory::getRevisionStoreForImport, which
uses getActorStoreForImport. Use this from classes handling
imports, so that IP actors can always be created.
* Add $forImport flag on ActorMigration, since RevisionStore
uses an actor store obtained via ActorMigration.
Bug: T354207
Change-Id: I0715bd0d23089fd8156e579913e6e823089809be
The idea is that all formatters that need the user language or
other request specific context should be instantiated by
FormatterFactory.
Change-Id: I8334cc89dcf0f293298b82e004116be50a90f0d1
Why:
* The ability to block temporary account usernames with 'hideuser'
needs to be added so that we can hide the username of temporary
accounts in the case of accidental logged out edits by editors.
* This brings similar behaviour how IP addresses are hidden on
WMF wikis, as the IP addresses are hidden for logged out edits
using the suppression tool. Blocking the account with 'hideuser'
allows all edits to be hidden plus also prevent further editing
using that temporary account.
What:
* This reverts commit 878602ad97.
Bug: T355430
Change-Id: I7b38d2bf0155df479a179c69c91cfe1987bd234a
ThrottlePreAuthenticationProvider uses the cluster-local object
cache, but TempUserCreator used the server-local cache. This
made throttling less effective and prevented
resetAuthenticationThrottle.php from working for temp users.
Change-Id: Ic6019767076416c5c06c2c2a119d1d416f18bca1
Reduce mental burden by exposing LBFactory also as
$services->getConnectionProvider, since it's encouraged to
type-hint this as IConnectionProvider whenever possible, this is
both more intuitive and more future-proof.
Also replace occurences in ServiceWiring where the receiving parameter
was already typehinted as IConnectionProvider.
Change-Id: I557dad3c985a1b2c43743e6b75cae57ce37d1785