Commit graph

284 commits

Author SHA1 Message Date
ArtBaltai
272e941b7f Use ObjectFactory to construct ContentHandlers
Changed
 - ContentHandlerFactory with legacy support
 - ContentHandlerFactoryTests
Added
 - MediaWikiIntegrationNoDbTestCase for test without preparing DB
New
 - tests

Bug: T243560
Change-Id: I693dda56af55bd03e48d62a2f1ade42f65a8fac9
2020-02-10 21:36:36 +03:00
ArtBaltai
30e54b3962 Introduce ContentHandlerFactory
Added:
- ContentHandlerFactory
Tests:
- PHPUnit
Changed
- Calls of changed and deprecated
- DI for some service/api
Deprecated:
- ContentHandler::* then similar to ContentHandlerFactory
- ContentHandler::getForTitle
- ContentHandler::$handlers

Bug: T235165
Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
2020-02-07 00:53:51 +03:00
Peter Ovchyn
50e3bd4fac parser: Inject a LanguageConverterFactory through DI containers:
1. into class Parser
2. into class LinkHoderArray
3. into class DefaultPreferencesFactory

Add more tests for DefaultPreferencesFactory:
1. testVariantsSupport verifies that converter with variants is used correctly.
2. Test testUserGroupMemberships verifies that membership is used correctly

Bug: T243320, T243321, T243317
Change-Id: I1e5c37e18332d0d32391c74c06e3d84862e48df8
2020-02-04 14:42:03 +02:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment  the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code

Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
2020-02-03 11:38:03 +02:00
C. Scott Ananian
0eb9f18d8d Remove all traces of preprocessorClass from $wgParserConf
Bug: T204945
Followup-To: I727f003f9a42d0c92bcbcce8a8289d5af6cd1298
Change-Id: I23821686ad666728d7d196e089f40be4b76b7390
2020-01-25 13:15:16 -05:00
Derick N. Alangi
42a5a29095 ServiceWiring: Cleanup unused closure signatures in serivice wires
* ActorMigration - use of $services was removed in c29909e but
  not removed in the closure signature

and other wires in the file whose closure signatures are not used
in the closure.

Change-Id: I5f24cbbb72433ecfa6bd0df3ef37ffe984c70cf3
2020-01-19 15:48:00 +01:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
mainframe98
297a89069a Add LinkBatchFactory to inject services into LinkBatch
All services required by LinkBatch are now injected by the
LinkBatchFactory. The constructor for LinkBatch has been
soft-deprecated, but the required services are still optional.

Bug: T239855
Depends-On: If49cbb730d4ac48586b891908cf24601efbc5d6a
Change-Id: I93d931ab60305ad49a6e419f8269c77791a3938d
2020-01-06 17:02:31 +01:00
DannyS712
f6417508c2 Remove FileBasedSiteLookup class, deprecated and unused
Bug: T241356
Change-Id: I252904b6b4c31a0ac42cbfbe7875a23c727150c1
2020-01-03 23:59:16 +00:00
DannyS712
f55e279d8f Follow-up 94582698c3: Fix references to injection.txt, now Injection.md
Change-Id: Ia7e653e0af0aca527e3e7c7625b669a10fc6d500
2019-12-14 20:19:56 +00:00
Daimona Eaytoy
598c4d7fcb build: Upgrade phan to 0.9.0
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.

Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.

Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.

Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
2019-12-07 20:16:19 +00:00
daniel
41415deda4 LocalisationCache: Don't instantiate ResourceLoader
When clearing the LocalisationCache, avoid instantiating a ResourceLoader
instance. Doing so introduces a circular dependency among service
instances.

This patch introduces a static method for clearing the MessageBlobStore
without the need for a ResoruceLoader instance.

Bug: T231866
Change-Id: I404e64713fee6a534ba014981cef78af0b91f2aa
2019-11-29 11:39:32 +01:00
Aryeh Gregor
84cf385db0 Deprecate FileJournal::factory
Instead, the constructors for FileJournal and NullFileJournal should be
treated as stable. I would have added @stable, but our linting doesn't
recognize it yet and doesn't let.

Bug: T235066
Change-Id: I7741055b4f00197d1346ebbfebc14f20238a06f3
2019-11-04 15:17:56 +01:00
Aryeh Gregor
537bdc2d7d Deprecate Language::getMessage*For()
These call the deprecated Language::getLocalisationCache() method and
thereby indirectly access MediaWikiServices. Callers should be changed
to inject a LocalisationCache and use that directly.

There are only a few callers in code search, so it didn't seem worth
adding convenience methods to LocalisationCache. The one caller that was
already using DI was MessageCache, and I injected LocalisationCache
there.

Bug: T201405
Change-Id: I01919fba5685fc5e0a31f739714f125a22de8939
2019-10-29 11:52:07 +02:00
jenkins-bot
979465a0e1 Merge "Convert FileBackendGroup to service" 2019-10-29 09:46:26 +00:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Aryeh Gregor
0d3d6be18d Convert FileBackendGroup to service
Bug: T234228
Change-Id: I25575f565eba122cdf971a5945572811d17fa3e1
2019-10-25 10:46:20 +03:00
Aryeh Gregor
e787246ce8 LanguageFactory to replace Language::factory()
Languages with variants no longer can override the parent's constructor
(which is now used for injecting services). Instead, they need to
override Language::newConverter().

Bug: T201405
Change-Id: I923400d61763cf1db88cb0c3f684c9c10e58032d
2019-10-23 10:48:23 -07:00
jenkins-bot
0915ac1713 Merge "Add TitleFactory" 2019-10-21 18:02:41 +00:00
jenkins-bot
b1a8bd2264 Merge "mediawiki.messagePoster: Introduce 'MessagePosterModule' extension attribute" 2019-10-18 19:36:12 +00:00
Gergő Tisza
95586dd937
Add TitleFactory
Makes it possible to mock static Title methods in tests, where
they are one of the more common reasons for not being able to
use MediaWikiUnitTestCase.

Actually introducing dependency injection to Title is left for
the future.

Change-Id: I959ba87f8e283da9549b6bfcefd338e60b00be8f
2019-10-18 00:00:46 +02:00
Timo Tijhof
34bff221ba mediawiki.messagePoster: Introduce 'MessagePosterModule' extension attribute
This allows extensions to add additional files or dependencies to
the 'mediawiki.messagePoster' module bundle.

Bug: T235315
Change-Id: I17c34cbb26e786328d3d99beb0c0fa65e15ea084
2019-10-17 18:00:10 +00:00
Timo Tijhof
156e0aed63 localisation: Convert MessageCache to PSR-3 logging
Change-Id: I9eaf8e419cf2895733fce1bff83aa81a3d21c39c
2019-10-12 17:38:59 +01:00
Timo Tijhof
8e9adb9486 localisation: Log debug message for backend of MessageCache
Bug: T234361
Change-Id: I697626a83cca4c6893cc30ca6ae118f10195624c
2019-10-12 00:27:10 +01:00
jenkins-bot
3300dc7b17 Merge "objectcache: Log debug message for backend of MainObjectStash" 2019-10-11 15:43:53 +00:00
James D. Forrester
b83a3e3e3a Follow-up Ifa346c8a92: LanguageNameUtils: CONSTRUCTOR_OTPIONS, not constructorOptions
Change-Id: I357dddf39834e9eed4b173245033d2f27edab329
2019-10-10 17:01:49 -07:00
Timo Tijhof
bd16c5eb34 objectcache: Log debug message for backend of MainObjectStash
Bug: T234361
Change-Id: I8e33591dc92198269f45a25d14014af633a351f2
2019-10-10 21:30:47 +01:00
Daimona Eaytoy
69cadf44a9 Unsuppress PhanParamsTooMany
This is the last repo-wide suppressed issue. Hurrah.

Bug: T231636
Change-Id: I3dc939f115bea14848c9c40bc52a7601f86ca0a7
2019-10-10 12:44:08 -07:00
jenkins-bot
22da7b437d Merge "objectcache: Log debug message for backend of WANObjectCache" 2019-10-10 08:39:33 +00:00
James D. Forrester
74f8ae0a24 [BREAKING CHANGE] Services: Convert Parser's static to a const now HHVM is gone
Change-Id: I54eafc84694bf68fe791b482865a1763c0439cbf
2019-10-09 12:26:48 -07:00
James D. Forrester
0316af2431 [BREAKING CHANGE] Services: Convert SpecialPageFactory's static to a const now HHVM is gone
Change-Id: Ifd939ddc60564b57c12dc5b9474f4a156ccb1f51
2019-10-09 12:24:27 -07:00
Timo Tijhof
3828558140 objectcache: Log debug message for backend of WANObjectCache
While at it, disuse the static newWANCacheFromParams function
which was only used by ServiceWiring (can now be deprecated,
but done separate for easier backporting).

Now that it is inlined, there is easy access to its logger.

Bug: T234361
Change-Id: I118b6f01e49405984310030d44ee319bb25bfcdb
2019-10-09 19:22:15 +01:00
jenkins-bot
a543d68c65 Merge "New LanguageFallback service" 2019-10-08 22:58:22 +00:00
Aryeh Gregor
8c4f59db64 New LanguageFallback service
This replaces the static Language methods getFallbackFor(),
getFallbacksFor(), and getFallbacksIncludingSiteLanguage(). There is
100% unit and integration test coverage for the new class.

One deliberate functional change: I changed one place where we threw
MWException to InvalidArgumentException.

Bug: T201405
Depends-On: Ie7a89f6ed7d52a0bc01672019ff92e7ee105a1f3
Change-Id: I49222eb55f1feec5b1dcd40f364cffe0c8801855
2019-10-08 15:11:39 -07:00
James D. Forrester
6898ba7232 Services: Convert MWLBFactory's static to a const now HHVM is gone
Change-Id: I2b5c77c304e03af31bc3f15f2e3f6002ca2f2647
2019-10-08 21:14:19 +00:00
jenkins-bot
52b44696ba Merge "Split some Language methods to LanguageNameUtils" 2019-10-08 21:10:07 +00:00
jenkins-bot
7982ca36bc Merge "Services: Convert DefaultPreferencesFactory's static to a const now HHVM is gone" 2019-10-08 20:45:53 +00:00
jenkins-bot
66f65e3a22 Merge "Services: Convert BlobStoreFactory's static to a const now HHVM is gone" 2019-10-08 19:47:57 +00:00
jenkins-bot
8db7eb1139 Merge "Introduce a formatter service for block errors" 2019-10-08 19:42:53 +00:00
James D. Forrester
17f3f9cee3 Services: Convert DefaultPreferencesFactory's static to a const now HHVM is gone
Change-Id: If24c5f120cb96311b50750c5b3022664dc6b20e5
2019-10-08 11:28:15 -07:00
James D. Forrester
4afe9030c2 Services: Convert BlobStoreFactory's static to a const now HHVM is gone
Change-Id: Ia319c881f0457fde71e355eca4873ac157e605d3
2019-10-08 11:27:22 -07:00
James D. Forrester
662b27776b Services: Convert PasswordReset's static to a const now HHVM is gone
Change-Id: I77e0d9ce86cf96824eb672d0f35c32b5f4c484be
2019-10-08 11:26:17 -07:00
James D. Forrester
ebac0247cf Services: Convert LocalisationCache's static to a const now HHVM is gone
Change-Id: If5c015debed7efc034613b976bc5292ac30036d7
2019-10-08 11:25:30 -07:00
James D. Forrester
40c35286cb Services: Convert BlockManager's static to a const now HHVM is gone
Change-Id: I01d6e18fc30bd61ba7ea5ce1c7c646524579c4ba
2019-10-08 11:24:22 -07:00
James D. Forrester
9cba9f8567 Services: Convert PermissionManager's static to a const now HHVM is gone
Change-Id: Ib75b6f5d6b3e793ddbce42951693d8c99e6b7e57
2019-10-08 11:23:08 -07:00
Thalia
df20197250 Introduce a formatter service for block errors
The main reasons for adding this service layer are:
* It allows error messages to be more consistent, by defining
  a set of reportable information that can describe any block
  type and is consistently formatted.
* It decouples formatting from the block classes, removing
  their dependency on language, for the most part.

The service provides one public method, getMessage, which
returns a Message object whose key and parameters are
determined by the type of block. This should be used instead
of the deprecated AbstractBlock::getPermissionsError and
AbstractBlock::getBlockErrorParams.

Calls to AbstractBlock::getPermissionsError are replaced in
this patch.

Bug: T227174
Change-Id: I8caae7e30a46ef7120a86a4e5e6f30ae00855063
2019-10-08 12:29:23 +01:00
Aryeh Gregor
6d80b6c082 Split some Language methods to LanguageNameUtils
These are static methods that have to do with processing language names
and codes. I didn't include fallback behavior, because that would mean a
circular dependency with LocalisationCache.

In the new class, I renamed AS_AUTONYMS to AUTONYMS, and added a class
constant DEFINED for 'mw' to match the existing SUPPORTED and ALL. I
also renamed fetchLanguageName(s) to getLanguageName(s).

There is 100% test coverage for the code in the new class.

This was previously committed as 2e52f48c2e and reverted because it
depended on e4468a1d6b, which had to be reverted for performance
issues. There should be no changes other than rebasing.

Bug: T201405
Change-Id: Ifa346c8a92bf1eb57dc5e79458b32b7b26f1ee8a
2019-10-07 15:20:52 -07:00
Aryeh Gregor
043d88f680 Make LocalisationCache a service
This removes Language::$dataCache without deprecation, because 1) I
don't know of a way to properly simulate it in the new paradigm, and 2)
I found no direct access to the member outside of the Language and
LanguageTest classes.

An earlier version of this patch (e4468a1d6b) had to be reverted
because of a massive slowdown on test runs. Based on some local testing,
this should fix the problem. Running all tests in languages is slowed
down by only around 20% instead of a factor of five, and memory usage is
actually reduced greatly (~350 MB -> ~200 MB). The slowdown is still not
great, but I assume it's par for the course for converting things to
services and is acceptable. If not, I can try to optimize further.

Bug: T231220
Bug: T231198
Bug: T231200
Bug: T201405
Change-Id: Ieadbd820379a006d8ad2d2e4a1e96241e172ec5a
2019-10-07 13:18:47 -07:00
Max Semenik
0809a10b90 MovePageFactory: make $constructorOptions a constant
Change-Id: Ia24add9d2805f61aae65bb1a56e13221f57d4547
2019-10-05 12:55:01 -07:00
Max Semenik
2f749f7cb3 NamespaceInfo: use array constants now that we can
Change-Id: I676a68fdc42ff2f37c7e4a2700b7c0c448155d47
2019-10-05 00:26:56 -07:00