Commit graph

786 commits

Author SHA1 Message Date
Umherirrender
769bdbf091 docs: Fix nullable documentation for class properties
Change-Id: I6d0577124d852103f485ffdc819876a13f6641c3
2021-09-24 00:54:53 +00:00
Alexander Vorwerk
d028567e4c Remove MessageCache::singleton()
deprecated since 1.34, hard deprecated since 1.37 and unused.

Bug: T249031
Change-Id: Iab7e0dda610b2e65624ede2a0bb419b0b9cc03d1
2021-09-15 18:13:37 +02:00
Alexander Vorwerk
0139a3b814 Remove LinkCache::singleton()
Deprecated since 1.28, hard deprecated since 1.37 and unused.

Bug: T249034
Change-Id: I224272e428f49db2498c30e6d12e2280fd580469
2021-09-15 18:05:34 +02:00
jenkins-bot
5a53d57449 Merge "LinkCache: soft deprecate addGoodLinkObj()" 2021-09-10 17:22:02 +00:00
jenkins-bot
7ece0e7afd Merge "Title: Make use of BacklinkCacheFactory service" 2021-09-10 14:31:23 +00:00
daniel
855988fd0e LinkCache: soft deprecate addGoodLinkObj()
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
2021-09-10 16:00:02 +02:00
jenkins-bot
1efeefe017 Merge "PageStore: Use LinkCache" 2021-09-09 20:04:47 +00:00
Derick Alangi
db43511e6a Title: Make use of BacklinkCacheFactory service
Change-Id: I48161585de6f329ec4037156234e0b07b3b837e6
2021-09-09 14:04:02 +01:00
Derick Alangi
96bc83e8eb Add BacklinkCacheFactory Service
Bug: T279433
Change-Id: I2943935e2d8148fce4457f76eca0234be72a5a5a
2021-09-09 09:58:52 +01:00
Umherirrender
44fd53fee3 Using @return never documentation on always-throw-function
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
2021-09-07 17:29:03 +02:00
daniel
3b6345ca16 PageStore: Use LinkCache
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
2021-09-01 08:24:34 +00:00
Aryeh Gregor
f79b99b7b4 Remove Title usage from BacklinkCache
Change-Id: I8f1ed821cf1d8a4ef5b073e788386920dc337e0c
2021-08-30 10:53:02 -04:00
TChin
d4cb97952f Add logger to BacklinkCache serializing
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
2021-08-20 12:58:26 -04:00
Timo Tijhof
6c4f7ad9db localisation: Remove conditional for plurals-mediawiki.xml file
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
2021-08-05 01:44:41 +00:00
Jack Phoenix
b326dd4352 Remove capitalize-all-nouns CSS class support
Functionality has been moved to MonoBook.

Bug: T97892
Change-Id: I3d4d74a2caa77f975b415af5977253ddeff6af21
Depends-On: I598c4469c46d284562ea3aec79330f9a1f40d2ce
2021-07-30 16:59:36 +00:00
Tim Starling
62bdc0fb60 Suppress LinkCache warning about "non-proper" pages
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
2021-07-27 20:51:42 +10:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
James D. Forrester
719cf161f2 More master -> primary documentation and internal var renaming
Bug: T254646
Change-Id: I63cc8895033714bdfbf09aee933a8f0a43b387f3
2021-07-15 11:20:20 +01:00
DannyS712
04202c17bf MessageCache: stop reading from $wgUser
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
2021-07-14 04:55:07 +00:00
daniel
04c2eef862 Improve logging in LinkCache.
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
2021-07-01 19:21:19 +02:00
jenkins-bot
c93be24da9 Merge "Make LinkCache behavior more consistent" 2021-06-24 20:10:50 +00:00
daniel
9e49260fc9 Make LinkCache behavior more consistent
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
2021-06-24 18:25:55 +02:00
Tim Starling
9c3c0b704b Use array_fill_keys() instead of array_flip() if that reflects the developer's intention
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
2021-06-15 00:11:10 +00:00
Petr Pchelko
bdecf516b9 Replace Title in Message/MessageCache
Change-Id: Ib0e36d767788edcdd8fa9ebc5de6bbde4cf50f12
2021-06-09 06:16:56 -07:00
Gergő Tisza
8925ba9c50 Add TransactionProfiler::silenceForScope()
Add a helper method for the common use case of temporarily silencing
transaction profiler warnings.

Change-Id: I40de4daf8756da693de969e5526b471b624b2cee
2021-05-16 18:19:53 +02:00
jenkins-bot
707e435a39 Merge "In MessageCache respect injected content language" 2021-05-15 02:55:53 +00:00
jenkins-bot
dba72b74c3 Merge "Optimise MessageCache::isMainCacheable() for the single-message case" 2021-05-15 02:52:30 +00:00
James D. Forrester
f2f9345e39 Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variables
This is just a start.

Bug: T254646
Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
2021-05-14 12:40:34 -07:00
Tim Starling
2ae37fa62e In MessageCache respect injected content language
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
2021-05-14 09:32:38 +10:00
jenkins-bot
297d1bfb0e Merge "Remove unused default values from class properties" 2021-05-13 00:58:34 +00:00
Thiemo Kreuz
6805f39a30 Remove unused default values from class properties
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
2021-05-12 13:44:28 +02:00
DannyS712
ba2e216399 GenderCache: remove checking for valid usernames
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
2021-05-12 06:37:38 +00:00
Tim Starling
8a010024be Optimise MessageCache::isMainCacheable() for the single-message case
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
2021-05-12 14:19:59 +10:00
daniel
0dec104bc0 Deferred updates: remove Title from method signatures.
This allows deferred update tasks to be constructed with a PageIdentity
rather than a Title instance.

Bug: T278459
Change-Id: Ifa2888fdef9ecc97f5bf09ae0b3fa7be48a0e9ef
2021-05-11 11:17:02 +02:00
daniel
316053ed88 LinkBatch: skip bad input
LinkBatch used to be lenient about receiving null or invalid titles.
This patch restores this lenient behavior.

Bug: T282180
Bug: T282070
Change-Id: I2c6378a3a0d508c77bcb290a6ed07f4d5f96d62c
2021-05-07 16:22:24 +02:00
Alexander Vorwerk
596344db7a Hard deprecate MessageCache::singleton()
deprecated since 1.34 and unused.

Bug: T249031
Change-Id: I6003c56f07469ffe796ccb415bb4d1e5ff8993a9
2021-05-03 14:11:21 +00:00
Alexander Vorwerk
41ae2236f0 Hard deprecate LinkCache::singleton()
deprecated since 1.28 and unused.

Bug: T249034
Change-Id: Ib21d994bf31e14f650a8684628d0b1542085c877
2021-05-03 12:32:11 +00:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
daniel
c829bfc8dd LinkBatch: replace Title with PageReference in method signatures
Bug: T278459
Change-Id: I7ed97f868f2a8a505ca4e529036d7efce6eea3ae
2021-04-26 19:54:24 +02:00
Petr Pchelko
ab9ecc0268 Drop hard-deprecated CacheHelper classes
Bug: T249230
Change-Id: I8fb43e862a19031520dda5a147e533becd7eb89e
2021-04-20 12:56:01 +00:00
daniel
90e1469012 HtmlCacheUpdater: replace Title in method signatures.
We still rely on Title internally, until the logic for mapping Titles to
URLs has been factored out.

Bug: T279796
Change-Id: I6abf30b8359fbe306c569ea290a64ed0d4105d71
2021-04-16 11:04:26 +00:00
daniel
185d535457 HTMLFileCache: replace Title in method signatures
Bug: T278459
Change-Id: I77fb37c1aec17d3e51056f85fdff59821f326cc3
2021-04-14 18:49:45 +02:00
Reedy
cce3fb49d0 Use more neutral or alternative language
Bug: T277987
Change-Id: Iafc4b3e3137936046487119b7e17635f4e560277
2021-03-20 19:47:18 +00:00
C. Scott Ananian
3f990d5b4c Inline Parser::firstCallInit() into ::__construct()
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
2021-03-16 19:41:56 +00:00
ZabeMath
15881aefe9 Avoid using User::isValidUserName()
User::isValidUserName is deprecated since 1.35 and should be replaced with the UserNameUtils service

Bug: T277398
Change-Id: Iaef995b992e2f38f651453092b23c928479e7d18
2021-03-14 18:04:12 +01:00
Umherirrender
8de3b7d324 Use static closures where safe to use
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
2021-02-11 00:13:52 +00:00
jenkins-bot
d749cbdf38 Merge "Use __CLASS__/::class to define callback for array_map/_filter/usort" 2021-02-05 03:14:42 +00:00
Petr Pchelko
c446e32682 Hard deprecate CacheHelper, ICacheHelper, CachedAction, SpecialCachedPage.
Bug: T249230
Depends-On: Ia2c6e93595905e6143cccede8478a6aac8dbf567
Change-Id: I749be35d784481671936c5ba037945f3b9ee2c4f
2021-01-25 13:34:31 -06:00
Umherirrender
e4d1a2c8bd Use __CLASS__/::class to define callback for array_map/_filter/usort
Change-Id: I3519dd5a1ce1ea688de602190cd74755c400c717
2021-01-22 16:39:29 +00:00
Ammarpad
beeccf8520 LinkBatch: Fix property documentations
* Remove incorrect null type from documentation of properties
that cannot be null.
* Add type doc for $caller and $data

Change-Id: I8d51dca7fd4910acf744361279c441fe4c3a4307
2021-01-22 07:41:07 +01:00