Commit graph

527 commits

Author SHA1 Message Date
DannyS712
bab2c0099c Make ApiModuleManagerTest a pure unit test
Switch test case with services to use a
service other than ObjectFactory, to make
it easier to mock.

Change-Id: I374a516b6bcc8111b2432245faf935f8287d45a7
2021-02-26 22:41:46 +00:00
Timo Tijhof
245bdafd9e resourceloader: Add wikimedia/minify package and remove local copies
- JavaScriptMinifier: The public interface for this internal class is
  ResourceLoader::filter which, except for one caller (minify.php)
  is indeed consistently used already, no other callers need replacing.

- CSSMin: Idem for minification, however, this class has some other
  method as well, which have a number of internal users, but none
  outside core. These have all been replaced in this commit.

- Remove pear/net_url2 as own dependency as this was only used by CSSMin
  and recently added there. This is now a dependency of wikimedia/minify
  instead. This was not part of the public API and no longer mentioned
  here in composer.json or RELEASE-NOTES. (It remains pinned in
  mediawiki-vendor, however.)

Bug: T273247
Depends-On: Iadff8c2112d5e53bd994ab4882006e8c644a2379
Depends-On: Id3c6dcc0b952a9efe34b3a9ed88b716101a51f87
Depends-On: I589be910f57289fd908b22db87241b0e52da60d4
Change-Id: I8d71fc64aeecdb31db218b02e361ae9bb0d19b48
2021-02-24 21:03:02 +00:00
jenkins-bot
cbf94bdf7f Merge "Fix and add various type hints" 2021-02-24 19:20:21 +00:00
Petr Pchelko
375e9f0a68 Rename Authority::getActor to Authority::getPerformer
Bug: T274947
Change-Id: I8f652816af00bf9fa413ba4b1fa7ac4c27290dc2
2021-02-22 14:53:21 +00:00
James D. Forrester
5a622b6a2e build: Upgrade eslint-config-wikimedia from 0.17.0 to 0.18.1
Change-Id: I5e3687be2b197134578126e1b890ee37dbc1bc1b
2021-02-18 08:39:09 -08:00
Vadim Kovalenko
66573bec7e Introduce LogEntry::getPerformerIdentity and deprecate ::getPerformer
Bug: T274329
Change-Id: I3dadb20f076494f7b46f0647ea3a8bfbbdaa59da
2021-02-17 19:12:22 +02:00
Thiemo Kreuz
c09f4fd6ef Fix and add various type hints
I keep fixing type hints in my local dev environment whenever I
see something that is worth updating. This is what I collected
over the past weeks.

Change-Id: Ia4f1b4bee2019abe4ab0fb0df8164e1b446229e7
2021-02-16 17:22:15 +00:00
jenkins-bot
183d83b572 Merge "parser: new BeforeParserFetchTemplateRevisionRecord hook" 2021-02-16 04:31:16 +00:00
jenkins-bot
5ea464b234 Merge "Use static closures where safe to use" 2021-02-14 23:05:48 +00:00
Timo Tijhof
c1709d9e70 MemoizedCallable: Disallow memoizing of unnamed closures
Using a random id as the cache key is useful in that it ensures
we don't poison ourselves with results from unrelated closures,
but it also prevents any use of APCu caching beyond the current
web request which is kind of what it is for.

There is a subclass inside the test case that stores results
in-process with an array instead, but for things like that we
generally use in-object caching of class instances, or
HashBagOStuff::getWithSet, or MapCacheLRU::getWithSet.

Change-Id: I264ad87af25dda4cde0c71aad83b30c314f8cd8d
2021-02-11 00:51:26 +00: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
2d2fe36d3c Merge "objectache: Revert "throw on Closure" in WANObjectCache" 2021-02-09 16:58:36 +00:00
Krinkle
0ec2643767 objectache: Revert "throw on Closure" in WANObjectCache
This reverts commit 4e94fa8812.

The extra serialization call here is not needed since storing
a value naturally results in serialization and thus exception
throwing already (hence the fatal error at T273242).
Performing serialization twice comes with a significant cost,
which has in past led to notable regressions.

Adding a try-catch makes sense, but this can be placed at a
higher level instead, as is already done by Ibfcbf0eceb4b7a36
which was already merged and back-ported, making this obsolete.

Other use cases:

- Continuous integration where HashBag is used, which doesn't
  need serialize and thus doesn't cover the Closure issue.
  Cost of serialize was removed there for performance reasons,
  but if we want to add it back, let's do so there in the natural
  place where it once was (or in MediumBag, which might be preferable
  so that we can use that same code path to gradually switch to JSON
  encoding and warn/throw for non-jsonic values).

- Regular getWithSet calls (rather than the async refresh from which
  the fatal is currently seen). For regular getWithSet calls we already
  get a useful stack trace that points directly to the line of code
  where the value and cache key are computed, so additional logging
  does not seem that valuable. But for consistency we could move the
  try-catch from Ibfcbf0eceb4b7a36e33a8 a little lower to cover all
  fetchOrRegenerate() calls, not just those from scheduleAsyncRefresh.

Bug: T273242
Change-Id: Ic649016dde7b58323a028ce6d4fe617ef62a1ff8
2021-02-09 16:27:48 +00:00
jenkins-bot
726f87c0c6 Merge "WANObjectCache: throw on Closure" 2021-02-09 13:35:31 +00:00
daniel
4e94fa8812 WANObjectCache: throw on Closure
Alternative to Ia91d9f8533d4cc58564473ee9a375ba6be90eb64

Bug: T273242
Change-Id: I76a6667a1fcdc35ff972ebcdf1ad0b95ef07e015
2021-02-09 11:10:41 +00:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
jenkins-bot
e897a7bd50 Merge "logger: Fix broken Monolog\CeeFormatterTest" 2021-02-09 00:32:29 +00:00
Ammarpad
56247c2d5c logger: Fix broken Monolog\CeeFormatterTest
If we pass mock datetime in the data to be formatted, the
formatter will use it, so the time string will no longer vary.

Bug: T218688
Change-Id: I4ea846cf1e908de085a551bda2bd944e846f7a36
2021-02-09 00:07:25 +00:00
jenkins-bot
4478047d6e Merge "Introduce helper WikiAwareEntityTrait" 2021-02-08 20:29:14 +00:00
Petr Pchelko
26be00fac4 Introduce helper WikiAwareEntityTrait
Bug: T273948
Change-Id: I21180d7031646f13413e2edb1bf0a17fbfdada13
2021-02-08 13:49:50 -06:00
jenkins-bot
8d2b4a81dd Merge "Introduce ActorStore, ActorLookup and ActorFactory." 2021-02-08 19:24:50 +00:00
Petr Pchelko
8d2c674ab0 Introduce ActorStore, ActorLookup and ActorFactory.
The ActorNormalization factory methods create
UserIdentityValue from the database rows, either via
fields of a joined table, or via a row from actor table.
They assume that the actor_id exist and throw othervise.

ActorNormalization is a storage-layer service providing
access to finding and acquiring actor_id.

The UserIdentityLookup methods do not instantiate new actor
on demand, they just find an appropriate row in the actor
table and return the result.

Bug: T272689
Depends-On: I74d81f3f0233efb17fc8df5178e4c477cc669c6f
Change-Id: Icfa1daca960c696a8cef8adab5eab53985802858
2021-02-08 10:06:46 -06:00
jenkins-bot
7612adad28 Merge "Make RevisionRecord::getPageId() and :: getParentId take a wiki ID" 2021-02-08 14:37:52 +00:00
Peter Ovchyn
e708b1d33f Make RevisionRecord::getPageId() and :: getParentId take a wiki ID
Bug: T273284
Change-Id: Id191b54844aaefeeaca081ae00997f13cdb987cb
2021-02-08 12:09:58 +02:00
jenkins-bot
c8a32fa7e3 Merge "Use Shellbox for Shell::command() etc." 2021-02-07 20:40:03 +00:00
Reedy
729f20afc8 Tests: Mark more closures as static
Bug: T274036
Change-Id: I911d3041cebe417d162934223b46ea295c6d20e3
2021-02-07 13:26:56 +01:00
Reedy
eb41565a9a Tests: Start marking some closures as static
Bug: T274036
Change-Id: Ib738ecd3bc23d34900bc268c8246702ac3655746
2021-02-06 19:57:42 +00:00
C. Scott Ananian
0676256ccc parser: new BeforeParserFetchTemplateRevisionRecord hook
This new hook provides for the use case in T47096 (allowing the
Translate extension to transclude a page from another language) by
adding a new hook which would let us deprecate and replace two awkward
legacy hooks (one with an embarrassing capitalization issue).  The new
hook is a little more tightly scoped in terms of what it allows and
gives access to, and it uses the new RevisionRecord API.

In addition, the new hook uses LinkTarget instead of Title per
current best practices. (PageIdentity is not appropriate for
reasons documented at the hook invocation site.)

The original BeforeParserFetchTemplateAndtitle (sic) hook allowed
redirecting the revision id of a template inclusion, but not the
title. The only known current use is Extension:ApprovedRevs; the
FlaggedRevs extension replaces the entire function using
ParserOptions::setCurrentRevisionRecordCallback().

Extension:Translate would like to redirect the title as well, possibly
recursively (for a limited number of hops) to handle fallback
languages.  That is, when invoked on Foo/fr, including Template:Bar
would redirect to Template:Bar/fr -- and, if that doesn't exist, then
Template:Bar/fr would redirect to its fallback language, say
Template:Bar/en. It uses the top-level page title as context to set
the desired page language.  This would require 2 invocations of the
hook; we've set the recursion limit to 3 to provide a little bit
of future-proofing.

The hook added in this patch uses RevisionRecord instead of int
$rev_id, and thus can handle the case where the redirect is to a page
which doesn't exist (by setting the RevisionRecord to a
MutableRevisionRecord with the correct title and no main slot content)
in the fallback language case above.

The new hook deprecates BeforeParserFetchTemplateAndtitle and replaces
ParserFetchTemplate as well (deprecated in 1.35).  Code search:

https://codesearch.wmcloud.org/search/?q=BeforeParserFetchTemplateAndtitle&i=nope&files=&repos=

Bug: T47096
Change-Id: Ia5b5d339706ce4084c16948300e0e3418b11792e
2021-02-05 09:37:32 -05:00
Tim Starling
99392f3b16 Use Shellbox for Shell::command() etc.
Make Command extend Shellbox's UnboxedCommand. Only a few MediaWiki-
specific features remain in the subclass.

Also add BoxedCommand abstraction and Shellbox client.

The Result alias didn't actually work, I just had to change the return
type hint.

Bug: T260330
Change-Id: Iff7428e4c5fe3959a5cda8e113f223caa0976fc1
2021-02-05 21:51:58 +11:00
jenkins-bot
ec79efe300 Merge "Remove DeferredStringifier class" 2021-02-03 22:07:40 +00:00
vladshapik
ddb80d4f77 RevisionRecordTests: create a test case to check triggering of the warning in the RevisionRecord::getId() method
Since there is the testGetIdDeprecated() test case which tests that the deprecated functionality still works in RevisionRecordTests trait. So the new testGetIdTriggerDeprecatedWarning test case was added in order to check triggering of the warning in RevisionRecord::getId() method.

Bug: T273314
Change-Id: I7248bfa5ed8b485ea79929a3bd5f8db0156c3201
2021-02-03 10:56:55 +02:00
DannyS712
58660d6a86 Remove DeferredStringifier class
Soft deprecated since 1.31, no need for hard deprecation
since it is unused and not stable to create

Change-Id: Ie854f422870e1f7666566544d4ed5df9abe240fb
2021-02-03 07:16:19 +00:00
Cindy Cicalese
5576727771 Make UserIdentity objects aware of which wiki they belong to.
Bug: T260933
Change-Id: Ic986640cc34e6ec6be239e410a8334f0e299c682
2021-02-02 16:10:51 +00:00
Petr Pchelko
511347f32a Use DummyContentForTesting in Revision unit tests.
TextContent/WikiTextContent can actually get to initializing
the global service container, which is not good.

Change-Id: I418d0a839fc3cd154d6d02af865e53564e2805ed
2021-02-01 20:11:49 -06:00
Umherirrender
393b6fb508 Add missing @param tags in tests
And exclude the rest inline to remove global exclude

Bug: T238572
Change-Id: Ib4c207177dd73702c113e6233f59be6e571a0f6a
2021-02-01 20:38:05 +01:00
Umherirrender
f20c0ac8bb Remove incomplete @param from test function
the @dataProvider should be a enough here

Change-Id: I36549dcac027a68244de042d48d90d4070771be8
2021-02-01 20:19:22 +01:00
Umherirrender
62002cdcf1 build: Update mediawiki/mediawiki-codesniffer to 35.0.0
Change-Id: Idb413be4b8cba8611afdc022af59810ce1a4531e
2021-01-31 13:34:38 +00:00
jenkins-bot
8a03ce6564 Merge "Set empty closures in DatabaseTest to fix php8 tests" 2021-01-31 03:24:34 +00:00
jenkins-bot
eb4b304ed8 Merge "Add missing @param and @return to documentation in tests" 2021-01-30 15:22:33 +00:00
jenkins-bot
ad7717e860 Merge "DatabaseTest: Remove redundant void return type hints" 2021-01-30 01:51:36 +00:00
Ammarpad
71c60455b4 DatabaseTest: Remove redundant void return type hints
All actual test methods don't return value, and so type hints
seems quite redundant.

Change-Id: Ic771f69d64b0a319de62cdd685683eccb836cbcc
2021-01-30 01:17:05 +00:00
vladshapik
117982da96 RevisionRecord: make RevisionRecord::getId() take a wiki ID
Bug: T272485
Change-Id: Ic1a8a406c2163844b14aa34ab259f0836687887e
2021-01-29 15:01:31 +02:00
Tim Starling
ca10d04f1a objectcache: Always enable debug mode in BagOStuff
BagOStuff has a debug mode because MemcachedClient has a debug mode,
because Ryan T. Dean put one in there in 2003. It's not strictly
necessary now that we have log levels.

This means that a few existing $this->logger->debug() calls are now on
the same effective level as $this->debug() calls, they can't be enabled
separately. But that seems inconsequential.

Change-Id: I4d1cb9153559b29468b6ca530bbc56e2b35d1721
2021-01-29 05:33:41 +00:00
Petr Pchelko
1fb76fefbb Change RevisionStoreCacheRecord callback signature
In order to convert the tests into tru unit tests.

Bug: T272669
Change-Id: I6055b43381fdcc6dcdf69e9311979db0dccdb16b
2021-01-26 15:14:35 +00:00
jenkins-bot
be62b610b0 Merge "Make vast majority of RevisionRecord tests unit." 2021-01-26 14:10:20 +00:00
jenkins-bot
f5ba23f9b4 Merge "objectcache: add statsd key metrics to BagOStuff classes" 2021-01-26 00:15:06 +00:00
Aaron Schulz
57325ba3bd objectcache: add statsd key metrics to BagOStuff classes
Update SQL, REST, and redis subclasses to emit call count and
payload size metrics for cache key operations. These metrics
are bucketed by cache key collection (similar to WANCache).

Bug: T235705
Change-Id: Icaa3fa1ae9c8b0f664c26ce70b7e1c4fc5f92767
2021-01-25 14:36:29 -08:00
Kunal Mehta
e5b85ae8f9 tests: Fix invalid @covers tags
And use the MediaWikiCoversValidator trait to ensure we don't regress.

Change-Id: I60a75eaf7b6b2606355e1f549050f7b0b8a990b9
2021-01-22 12:45:24 -08:00
Petr Pchelko
30735541f4 Make vast majority of RevisionRecord tests unit.
Change-Id: Icc94fbd7090ee5f73fc1fba353ff7c936436f76f
2021-01-22 19:04:58 +00:00
Umherirrender
7691dbeca9 Add missing @param and @return to documentation in tests
Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
2021-01-22 19:57:25 +01:00