addGoodLinkObj() has many optional arguments, but omitting them actually
means corrupting the cache.
Nearly all existing callers are in tests.
So LinkCacheTestTrait::addGoodLinkObject() was created only
for testing. It is better to have this method in the
trait, because building the row directly in each test
would make these tests brittle against schema changes.
The only usage in WMF production code was in WikiPage and has been
fixed.
Bug: T284955
Change-Id: I03a2bd9ed64fcc0281ee29a286c8db395a9e03d9
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before
Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
This makes the data stored by LinkCache compatible with PageStoreRecord,
so we can use LinkCache inside PageStore.
This causes PageStore to make use of local caching as well as WANObjectCache.
Note that getPageById() does not yet benefit from cache, but does
populate the cache.
Bug: T278940
Change-Id: Icc27a0d9299a3e4ce45521daef87ad06ec06f064
While refactoring BacklinkCache, it was noticed that there is a __sleep method even though it doesn't seem to be used anywhere.
Git blame indicated that the last time BacklinkCache could've been potentially serialized was back in 2012 when Title used to save an instance of it. This is no longer the case.
However, there is a slight possibility that it's used in a hidden corner of some extension out there, so the plan is to add a logger, wait a week to see if __sleep is ever hit, and if not, we can just remove it so we don't have to worry about it when refactoring and writing tests.
Bug: T288278
Change-Id: Idb0f9985cb321cd53fea60d1fc94613c914e0de2
Follows-up bbbcf089db.
This file always exists. If we want to support disabling this, we
could introduce a configuration option rather than encouraging users to
apply core hacks by modifying or removing this file.
Also move the file paths into an array for re-use.
Bug: T225756
Change-Id: I6c86b5b0bdc4b0242bc406599eb0a172f17f2d03
Functionality has been moved to MonoBook.
Bug: T97892
Change-Id: I3d4d74a2caa77f975b415af5977253ddeff6af21
Depends-On: I598c4469c46d284562ea3aec79330f9a1f40d2ce
Every special page link handled by LinkRenderer::makeKnownLink()
would generate a warning in LinkCache about the target being a
"non-proper" page. Duplicate LinkCache's sanity checks to avoid this.
Also improve LinkCache warning messages.
Change-Id: Ia2dc9136cc2edf5ee57e8f1ee54819f891b41a1c
Use RequestContext::getMain()->getUser() instead.
Given that there is an explicit check if the user is safe
to load, this should be fine - if the RequestContext
doesn't already have a user, it'll create one via
User::newFromSession() and then the isSafeToLoad()
call will fail.
Bug: T243708
Change-Id: I217f169b2f5c5a0a337011e383b5171f7c7a2975
When reporting non-preoper LinkTargets or PageReferences, we need to
include the fragment part. Title::__toString does not, so use
TitleFormatter::getFullText instead.
For the purpose of T285951: this patch is not necessary to resolve the
bug, it just improves logging.
Bug: T285951
Change-Id: I1b4fccebae585edf07dccadfb4e8cb48e0b5d597
This patch does several things to LinkCache to make its behavior more
consistent and predictable:
* Methods that set a "good" link now clear the "bad link" flag, and vice
versa.
* invalidateTitle() now also clears the local cache, not just the
persistent cache.
* Attempts to set data for LinkTargets that are not proper local pages
are ignored.
* All methods now accept LinkTarget|PageRecord as the key.
The ones that previously accepted a string still allow that as well.
* addLinkObject() now consistently uses the local cache if possible,
and consistently bypasses it if the forUpdate() flag is set.
This is all done in preparation for LinkCache being used inside PageStore.
Bug: T278940
Change-Id: I62107789fa185606a81be20ffa8f0be48297c08f
array_fill_keys() was introduced in PHP 5.2.0 and works like
array_flip() except that it does only one thing (copying keys) instead
of two things (copying keys and values). That makes it faster and more
obvious.
When array_flip() calls were paired, I left them as is, because that
pattern is too cute. I couldn't kill something so cute.
Sometimes it was hard to figure out whether the values in array_flip()
result were used. That's the point of this change. If you use
array_fill_keys(), the intention is obvious.
Change-Id: If8d340a8bc816a15afec37e64f00106ae45e10ed
Add a helper method for the common use case of temporarily silencing
transaction profiler warnings.
Change-Id: I40de4daf8756da693de969e5526b471b624b2cee
Replace the many references to $wgLanguageCode with a cached copy of the
code of the content language passed to the constructor. The references
to $wgLanguageCode in this class were just meant to be a shortcut for
$wgContLang->getCode().
Change-Id: I60c61aaef0abe6df79ab39f123206d8aae044113
In all these cases the property is unconditionally set in
the constructor. The extra initialisation is effectively
dead code and an extra source of errors and confusion.
Change-Id: Icae13390d5ca5c14e2754f3be4eb956dd7f54ac4
Violates proper DI by retrieving UserNameUtils from
MediaWikiServices instead of injecting, but can't inject
because that creates a circular dependency (UsernameUtils
indirectly relies on GenderCache via MediaWikiTitleCodec).
If callers can validate that they are only searching for the
genders of valid user names, that would be great but its
not required, at worst we just search for a few
extra database rows that don't exist.
Bug: T267054
Change-Id: I00813228e177a7a7d13969fae85cf725def8f879
Loading all messages with getSubitemList() takes about 10ms per
language and loads an array with ~20k elements. When messages in many
languages are requested, this causes an OOM.
So, use getSubitemList() only when isMainCacheable() is called from
loadFromDB(). Remove the second parameter in that case, since it was
always the same.
In the getMsgFromNamespace() case, use getSubitem() to check the
specific message for existence. Have the caller specify the language, in
order to share a subitem cache entry with usual previous
getMessageForLang() call.
Bug: T247223
Change-Id: I6369f307b6bf74bd4aeb1d6e4c41d6e59e403703
This allows deferred update tasks to be constructed with a PageIdentity
rather than a Title instance.
Bug: T278459
Change-Id: Ifa2888fdef9ecc97f5bf09ae0b3fa7be48a0e9ef
LinkBatch used to be lenient about receiving null or invalid titles.
This patch restores this lenient behavior.
Bug: T282180
Bug: T282070
Change-Id: I2c6378a3a0d508c77bcb290a6ed07f4d5f96d62c
We still rely on Title internally, until the logic for mapping Titles to
URLs has been factored out.
Bug: T279796
Change-Id: I6abf30b8359fbe306c569ea290a64ed0d4105d71
This has effectively been the case since 1.35; this just cleans up the
remaining code which assumed it still needed to explicitly call
Parser::firstCallInit() on a newly-constructed Parser.
Bug: T250444
Change-Id: I340947c721172f12ff413322b4283627c0b0b3a4
User::isValidUserName is deprecated since 1.35 and should be replaced with the UserNameUtils service
Bug: T277398
Change-Id: Iaef995b992e2f38f651453092b23c928479e7d18
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.
Created by I25a17fb22b6b669e817317a0f45051ae9c608208
Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Remove incorrect null type from documentation of properties
that cannot be null.
* Add type doc for $caller and $data
Change-Id: I8d51dca7fd4910acf744361279c441fe4c3a4307