aboutsummaryrefslogtreecommitdiffstats
path: root/includes/cache/localisation/LocalisationCache.php
Commit message (Collapse)AuthorAgeFilesLines
* language: Move l10n-related classes from /cache to /languageTimo Tijhof2022-06-281-1125/+0
| | | | | | | | | | | | | | | | * Make the code easier to own and maintain by being part of a topical area of expertise rather than a generic catch-all bucket. This also helps Gerrit team dashboards, [[mw:Git/Reviewers]] subscription patterns, more meaningful component prefix for [[mw:Commit_message_guidelines]]. * Prep for possible CODEOWNERS adoption. * Prep for T166010 to give us better PSR-4 namespaces that we won't have to break/migrate again shortly after for the above. Bug: T225756 Change-Id: I62c701d574d2a79365b1c5350f92bef47770e3ce
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-261-5/+6
| | | | | | | | | | | | | | | | | | | | | Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
* phan: Remove PhanTypePossiblyInvalidDimOffset suppressionUmherirrender2022-03-281-0/+1
| | | | | | | | | | | Make phan stricter about array keys Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T304887 Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1 Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385 Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
* Avoid references to DefaultSettings.daniel2022-02-221-2/+2
| | | | | | | | | | | | | | This replaces references to DefaultSettings with references to config-schema.yaml where appropriate. NOTE: this does not yet change Setup.php. DefaultSettings.php remains intact and is still being used. NOTE: this does not remove usages in the installer, see I5d8843a1062fbf for that. Bug: T300129 Change-Id: Ie6152cf510c3be61bc22167ca6d90dfc28910a45
* Prefer is_dir/is_file to file_existsKosta Harlan2022-01-041-1/+1
| | | | | | Mirco-optimisation for performance, part II. Change-Id: Ie8d5332a510bd18456ebc4a851f4d47f6a010dcb
* Remove or replace usages of "sanity"Reedy2021-11-211-1/+1
| | | | | | | Still some more to go... Bug: T254646 Change-Id: Ia117f01e443c35b4765f3275cab4f2707e1be96f
* localisation: Remove conditional for `plurals-mediawiki.xml` fileTimo Tijhof2021-08-051-15/+18
| | | | | | | | | | | | | Follows-up bbbcf089dbbb84d. 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
* Remove capitalize-all-nouns CSS class supportJack Phoenix2021-07-301-1/+1
| | | | | | | | Functionality has been moved to MonoBook. Bug: T97892 Change-Id: I3d4d74a2caa77f975b415af5977253ddeff6af21 Depends-On: I598c4469c46d284562ea3aec79330f9a1f40d2ce
* build: Updating dependencieslibraryupgrader2021-07-221-1/+1
| | | | | | | | | | | | | | 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
* Use array_fill_keys() instead of array_flip() if that reflects the ↵Tim Starling2021-06-151-2/+2
| | | | | | | | | | | | | | | | | | 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
* Remove unused default values from class propertiesThiemo Kreuz2021-05-121-1/+1
| | | | | | | | 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
* Remove unneeded isset() before unset()Lucas Werkmeister2020-11-101-3/+1
| | | | | | | | unset() does not throw an error if the value to be unset does not exist in the first place, so guarding it with an isset() check is unnecessary. Remove a few ifs that didn’t do anything else. Change-Id: Ie5493c8a4c4d25e12a029d0257374527cd12303d
* Mark CONSTRUCTOR_OPTIONS as internalAryeh Gregor2020-08-211-2/+1
| | | | | | | | These were never meant to be part of the public interface and should not ever have been marked with @since. They're only useful for constructing the respective objects, which no outside users should be doing. Change-Id: I86e01272d46fc72af32172d8a12b9180971d4613
* includes: Use expression assignment operator += or |= where possibleUmherirrender2020-07-311-2/+1
| | | | | | It is easier to read. Change-Id: Ia3965b80153d64f95b415c6c30f526efa252f554
* Revert "Add a new type of database to the installer from extension"Kunal Mehta2020-07-221-24/+1
| | | | | | | | | | | | | | | It caused a 20% latency regression by unconditionally parsing extension.json files on every single load instead of using the existing caching infrastructure. There are further problems with the use of parsing/loading extension.json files in a method that is incompatible with the existing architecture. This primarily reverts commit 46eabe275c923ca7827435a36d6576150cea8899. Also needed to revert 16381261ae and 7c72347ec1. Bug: T258664 Change-Id: I34a783c3f0df0447876a26441bb2d12e02368871
* Merge "phan: Enable redundant_condition_detection"jenkins-bot2020-07-021-0/+3
|\
| * phan: Enable redundant_condition_detectionUmherirrender2020-07-011-0/+3
| | | | | | | | | | | | | | | | Remove duplicate casts Suppress false positives Bug: T248438 Change-Id: I2f89664a4bcd3b39b15e7cf850adda2f0c90ae6f
* | Add a new type of database to the installer from extensionArtBaltai2020-06-261-1/+24
|/ | | | | | | | | | | | | Decouple Installer services Implement injection class Autoloader and i18n messages from extension.json Implement extension selector by type Add i18n message key `version-database` Extensions for testing: - https://github.com/MWStake/PerconaDB - real Percona extension - https://github.com/killev/mediawiki-dbext2 - fake extension for test Bug: T226857, T255151 Change-Id: I9ec8a18ad19283f6be67ac000110ac370afc0815
* Hooks::run() call site migrationTim Starling2020-05-301-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Fix even more PSR12.Properties.ConstantVisibility.NotFoundReedy2020-05-161-1/+1
| | | | Change-Id: I4a30a44bc33fc98479799438d65342f6529e14f9
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-7/+7
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUseJames D. Forrester2020-01-101-1/+1
| | | | Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
* Set method visibility for various constructorsUmherirrender2019-12-031-1/+1
| | | | Change-Id: Id3c88257e866923b06e878ccdeddded7f08f2c98
* ParamValidator: Use MessageValue!Brad Jorsch2019-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Trying to get away with returning a single code and parameter-list that was supposed to represent both human-readable and machine-readable data was a mistake. This patch converts it to use DataMessageValue, which represents the two separately and also provides guidance for supplying translations of all the error codes. This also eliminates the "describeSettings()" method that was trying to serve multiple use cases (in terms of the Action API, action=paraminfo and action=help). It's replaced by two methods that each serve one of the use cases. Also some of the functionality was moved out of the TypeDef base class into ParamValidator, to better match where the constants themselves live. Also I wound up creating a NumericDef base class so FloatDef can share the same range-checking logic that IntegerDef has. I probably should have done that as a separate patch, but untangling it now would be too much work. Bug: T235801 Change-Id: Iea6d4a1d05bb4b92d60415b0f03ff9d3dc99a80b
* Split rest messages from the main en.jsonAmir Aharoni2019-10-221-0/+1
| | | | | Bug: T233192 Change-Id: I3990ae4e34a51e7648f74a05a4b7ac744fa9b9c4
* Merge "Split some Language methods to LanguageNameUtils"jenkins-bot2019-10-081-4/+11
|\
| * Split some Language methods to LanguageNameUtilsAryeh Gregor2019-10-071-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 2e52f48c2ed and reverted because it depended on e4468a1d6b6, which had to be reverted for performance issues. There should be no changes other than rebasing. Bug: T201405 Change-Id: Ifa346c8a92bf1eb57dc5e79458b32b7b26f1ee8a
* | Services: Convert LocalisationCache's static to a const now HHVM is goneJames D. Forrester2019-10-081-4/+2
|/ | | | Change-Id: If5c015debed7efc034613b976bc5292ac30036d7
* Make LocalisationCache a serviceAryeh Gregor2019-10-071-65/+82
| | | | | | | | | | | | | | | | | | | | | 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 (e4468a1d6b6) 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
* localisation: Remove PHP5-specific perf optimisationTimo Tijhof2019-09-211-9/+0
| | | | | | | | | | | | The `apc.cache_by_default` setting is a PHP5-era setting relating to the part of php5-apc now known as opcache (as opposed to the part now known as apcu). This setting doesn't exist in PHP 7, and trying to set it doesn't do anything useful. Bug: T206986 Change-Id: I46a91897b2b33b5ce6505beb74d404982cb0641c
* Unsuppress more phan issues (part 3)Daimona Eaytoy2019-08-311-20/+14
| | | | | | Bug: T231636 Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd Change-Id: I58e67c2b38389df874438deada4239510d21654f
* Revert "Make LocalisationCache a service"Amir Sarabadani2019-08-261-90/+68
| | | | | | | | | | | | This reverts commits: - 76a940350d36c323ebedb4ab45cc81ed1c6b6c92 - b78b8804d076618e967c7b31ec15a1bd9e35d1d0 - 2e52f48c2ed8dcf480843e2186f685a86810e2ac - e4468a1d6b6b9fdc5b64800febdc8748d21f213d Bug: T231200 Bug: T231198 Change-Id: I1a7e46a979ae5c9c8130dd3927f6663a216ba753
* Pass correct store to rebuildLocalisationCache.phpAryeh Gregor2019-08-261-0/+32
| | | | | | | | | e4468a1d6b6 completely broke rebuildLocalisationCache.php by unconditionally passing in LCStoreDB( [] ) instead of constructing the correct object. Bug: T231183 Change-Id: I0d52662e8745cf0e10091169b3b08eff48ef2b8f
* Split some Language methods to LanguageNameUtilsAryeh Gregor2019-08-231-4/+11
| | | | | | | | | | | | | | 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. Change-Id: I245ae94bfc1f62b6af75ea57525139adf2539fe6
* Make LocalisationCache a serviceAryeh Gregor2019-08-221-69/+52
| | | | | | | | | 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. Change-Id: Iaa86c48e7434f081a53f5bae8723c37c5a34f503
* Drop newlines in LocalisationCache debug logsAntoine Musso2019-07-241-5/+5
| | | | | | | | 316d205115c migrated LocalisationCache from wfDebugLog() to the Logger interface which no more requires the messages to be terminated with a new line. Change-Id: Ibe2f750e7ab16cf91801988cb726adb67f7cd9d2
* Remove $purgeBlobs parameter from LocalisationCacheRecache hookRoan Kattouw2019-07-151-3/+3
| | | | | | | | No longer allow hook functions to prevent message blobs from being purged. Pass in an always-true variable for backwards compatibility, which is then ignored. Change-Id: I27ac9599711f2f0df2514a3934270af0ce03da7f
* Stop using wfDebugLog in LocalisationCacheAmir Sarabadani2019-07-111-8/+14
| | | | | | | | Using logger interface, this would fix some unit tests, plus it avoids using global functions and ease the way for proper dependency injection Change-Id: I9a545c70ace08e2fd0b832d75d6a2362a83af21e
* languages: Hard deprecate Language::getExtraUserToggles() methodDerick Alangi2019-05-241-9/+10
| | | | | | | | | This seems to be still used internally in core but in no extension. Also, this function really doesn't do anything so hard deprecating in preparation for removal. Bug: T62260 Change-Id: I568789483084a97e5b3b462235f3d00c3cb87cf9
* localisation: Inject 'directory' option to LCStore classesTimo Tijhof2019-05-141-7/+5
| | | | | | | Avoid globals for this, inject them from the factory function instead. Bug: T218207 Change-Id: Ia961e8e08dcf1ca154d74ea6a3dadd2d59c1299c
* localisation: Improve documentation around wgLocalisationCacheConfTimo Tijhof2019-05-071-6/+6
| | | | | Bug: T218207 Change-Id: I15a77d5df7b358b69cd9049036a69a28d31ebaae
* Obtain MessageBlobStore instance in a consistent wayRoan Kattouw2019-05-071-3/+1
| | | | | | | | Use MediaWikiServices (not OutputPage) to obtain a ResourceLoader instance, then call ->getMessageBlobStore() to obtain its MessageBlobStore instance (don't construct a new one). Change-Id: I6b8bacac9888b5807328eece01134a6c5747dc72
* Upgrade to newer phanKunal Mehta2019-03-231-1/+0
| | | | | | | | | | | | | | | | | | | | | | MediaWiki core now runs phan 1.2.6, bringing in nearly 2+ years of upstream fixes. Configuration was moved from `tests/phan` to `.phan/`. The legacy bash wrapper script is still kept in the repository in its own location for any extensions that are still using it. It should be removed before 1.33 is released. Since there's a lot of new issues being flagged, all currently failing issues are suppressed, and will be fixed in follow-up patches. We're dropping the jetbrains/phpstorm-stubs repository in favor of just the minimal stubs we need. Stubs for PHP extensions are kept in the new `.phan/internal_stubs` directory, since they're in a slightly different format than normal stubs. Normal stubs are kept in `.phan/stubs`. wikidiff2 and excimer are kept with these since we're also the upstream for them. Change-Id: I3fe437befa17f4fbaf97aa6271f659b56021f396
* resourceloader: Make $rl parameter mandatory for MessageBlobStoreTimo Tijhof2019-02-191-1/+3
| | | | Change-Id: I851b2417b7e495a1d0c7ee1aa8be2b2e970840bb
* build: Updating mediawiki/mediawiki-codesniffer to 24.0.0Kunal Mehta2019-02-071-8/+8
| | | | Change-Id: I66b1775b7c1d36076d9ca78cbeb42787a743f2aa
* Move exif messages to a separate i18n fileAmir Aharoni2018-12-271-0/+1
| | | | | Bug: T167762 Change-Id: I17900ff07cd9b15f00c7118b4206cf1cdc074469
* LocalisationCache: Avoid use of compact()Kunal Mehta2018-10-151-7/+12
| | | | | | | | | In PHP 7.3, compact() now raises notices if the variable is undefined, which is something that we expect. So we can check whether the key exists instead of bothering with compat() and suppressing warnings. Bug: T206979 Change-Id: I612049db4debd850a2e6d10bc631d31aa17be898
* Define which languages explicitly fallback to 'en'Ed Sanders2018-09-191-8/+14
| | | | | | | | | | | | In the message store, all messages fall through to English, but only a few languages should actually explicitly fallback to English (English variants and dialects). These new explicit fallbacks are used by ResourceLoaderImageModule, and this change doesn't affect the message fall through system. Bug: T203350 Change-Id: I6b68a17f4d69341bccdae748727b5133a600d8bc
* resources: Rename oojs-ui file paths to ooui per general brandingJames D. Forrester2018-09-101-1/+1
| | | | | | No change to the module names yet. Change-Id: Ica33520b0128bd56dc06c8951bdc6932fce041fe
* Move l10n_cache table to a separate DB for sqlite via the installerAaron Schulz2018-08-141-0/+2
| | | | | | | | | | This does not set 'db' as the cache type so that admins can still easily set the cache directory to use the file-based cdb system. If they do not, then at least the second DB file will be used to avoid heavy contention. Bug: T93097 Change-Id: Ib3912f00cf12de99801ebda4f06135b2987ce71a