aboutsummaryrefslogtreecommitdiffstats
path: root/includes/resourceloader/MessageBlobStore.php
Commit message (Collapse)AuthorAgeFilesLines
* ResourceLoader namespace (attempt 2)Tim Starling2022-05-241-250/+0
| | | | | | | | | | | | | | | | | | Move ResourceLoader classes to their own namespace. Strip the "ResourceLoader" prefix from all except ResourceLoader itself. Move the tests by analogy. I used a namespace alias "RL" in some callers since RL\Module is less ambiguous at the call site than just "Module". I did not address DependencyStore which continues to have a non-standard location and namespace. Revert of a241d83e0a6dabedf. Bug: T308718 Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
* Revert "ResourceLoader namespace"Lucas Werkmeister (WMDE)2022-05-161-0/+250
| | | | | | | | | | | | This reverts commit e08ea8ccb9932f9924a613056afcb2d01c8c7b39. Reason for revert: Breaks Phan in extensions, and as far as I’m aware, this change isn’t urgently needed for anything, so the simplest fix is to revert it again for now. After PHP 7.4 it should be safer to try this again (we hopefully won’t need the two “hack” classes by then). Bug: T308443 Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
* ResourceLoader namespaceTim Starling2022-05-161-250/+0
| | | | | | | | | | | | | | | | Move ResourceLoader classes to their own namespace. Strip the "ResourceLoader" prefix from all except ResourceLoader and ResourceLoaderContext. Move the tests by analogy. I used a namespace alias "RL" in some callers since RL\Module is less ambiguous at the call site than just "Module". I did not address DependencyStore which continues to have a non-standard location and namespace. Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
* 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
* resourceloader: Fail gracefully if a LESS message is not foundTimo Tijhof2021-01-071-0/+2
| | | | | | | | | | | | | | | | | | The message cache is originally meant for mw.messages in JS, which expects non-existent messages to be cleanly omitted. There is minimal server-side and client-side handling in place for this. For LESS, however, we were assuming that the blob is complete, thus not feeding anything to the LESS compiler, thus leading to a run-time failure where the LESS file can't be parsed at all due to an undeclared variable. This could happen sometimes during development or after upgrading a wiki with a stale LocalisationCache that is still being updated at that time. Bug: T267785 Change-Id: I60ff4eb7dce1fee56470acc177afd29ee14b764f
* resourceloader: Add some typehints and misc clean upTimo Tijhof2020-07-021-17/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a void return hint to methods that are not meant to return anything. This helps catch accidental return statements in the future, lets Phan better understand how methods are meant to be used, and might also allow PHP to better optimise the compiled code form (speculation). I did not, however, add it to publicly extended methods as that might mess with strict mode. * Remove the internal getResourceLoader() method from MessageBlobStore. This has been redundant since 3edaa0b37c1e2684. The method was protected, and not considered stable to subclass for extensions. Hence not a breaking change. * Add Throwable typehint to formatException() and friends. This is the narrowest one I could add given that the methods called from here already enforce the same typehint. Update the doc to match for now. There isn't a reason right now to limit this only to Exception, and given this is the method and not the catch statement itself, does not change behaviour. * Remove unused ResourceLoader->getHookContainer(). Added within 1.35 cycle, safe to remove. * Remove unexpected `@since` for `@internal` getHookRunner(). * Remove redundant `@internal` from ResourceLoaderMwUrlModule methods, which itself is already `@internal`. Change-Id: I68d33ff6feca7ef95282a7ff03eb9332adfde31c
* resourceloader: Add more granular phan type information in various classesTimo Tijhof2020-02-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * Where possible and easy to figure out, change `array` to something like `array<K,V>` or `V[]` for improved static analysis to catch/prevent regressions in CI. * Minor doc improvements: - consistently use the imperative mood for method briefs, - consistently use @internal instead of @private, - explain in @throws why they happen to inform when they should be caught (and remove if they are not meant to be caught/handled by any caller). * Simplify addSources() implementation as a simple loop instead recursing (not worth the complexity, only called once or twice at runtime). * Use more granular exceptions to distinguish between errors that indicate a mistake on the caller (logic/invalid arguments error), and runtime errors (which are more circumstantial). * Update register() unit test for bad 'moduleInfo' type to use a nested value, given that the second-parameter level type is now verified by the signature already. Change-Id: Id98ba1f28cb7f1c72f0a3e82f4151bcbd0f3db77
* resourceloader: Dependency inject WANObjectCache into MessageBlobStoreDerick A2020-02-121-2/+8
| | | | Change-Id: I0f4c4e0e753574cf060331c944f44318eaca1fec
* LocalisationCache: Don't instantiate ResourceLoaderdaniel2019-11-291-2/+15
| | | | | | | | | | | | 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
* resourceloader: Add Doxygen group and improve overall docsTimo Tijhof2019-09-141-3/+6
| | | | | | | | | | | | | | | | | | | * Add license header where missing. * Add missing `@since` (1.17 for most classes), except ResourceLoaderLessVarFileModule since 1.32 (1bc62c548c). * Remove duplicate file-level description for class-only files, merge with the class description instead. * Remove my own `@author` annotation from one file. * Mark core's own FileModule subclasses as `@internal`, except for the following which we support use of in extensions: ResourceLoaderLessVarFileModule, ResourceLoaderOOUIIconPackModule, and ResourceLoaderWikiModule. Change-Id: I336af2e4ccdbe2512594e8861b72628d24194e41
* resourceloader: Avoid escaping of UTF-8 characters in messagesFomafix2019-08-011-1/+1
| | | | | | | | | | | It's not needed to escape UTF-8 characters in messages. The characters '&', '<' and '>' are still escaped. For the output in load.php this escaping is not necessary but messages can also embedded into <script> tags and here are the characters '<' and '>' problematic. Bug: T229301 Change-Id: If424a21df4a813ba6cb79b939f0857d96f162a17
* objectcache: reorganize WANObjectCache fields and avoid exposing internal ↵Aaron Schulz2019-07-201-1/+1
| | | | | | constants Change-Id: I95771fc8d032939e71adba3a416894004ea0847d
* Remove `@author Timo Tijhof` from various file headersTimo Tijhof2019-07-081-3/+0
| | | | | | | Also remove a few redundant file-level descriptions in favour of their class entity describing the same already. Change-Id: I1a43fc402b5bd106931062a399952ba1e48beb48
* resourceloader: Make MessageBlobStore global check key actually globalTimo Tijhof2019-05-221-4/+9
| | | | | | | | | | Because it was still per-wiki, which isn't useful and makes it really slow to invalidate by requiring a 900-wiki iteration during deployments all of which fully initialise MW just to send a single Memcached command basically. Bug: T222539 Change-Id: I02a3e7d83172ccd7d8d0fba3be1e3f1ebb77efb2
* resourceloader: Omit non-existent messages in MessageBlobStoreTimo Tijhof2019-04-191-3/+8
| | | | | | | | | | Previously, it was exporting the result of $msg->plain() regardless of $msg->exists(). This meant that, client-side, via mw.message the message would always make mw.Message#exists return true, even if in fact it did not exist. Bug: T221294 Change-Id: I77122777ddaaa2d43f8385df9292540a8d21b328
* resourceloader: Remove deprecated MessageBlobStore::getBlobTimo Tijhof2019-03-301-8/+0
| | | | | | | | | | | This class is basically `@internal`, but not yet marked as such. The only non-core use case is a WikimediaMaintenance script, so I suppose we can keep it public. It's purpose is for batching, the single blob method is not used anywhere in Wikimedia Git. Change-Id: If2a0497b1412efbfd55b34b512d2b9e5346359fb
* resourceloader: Improve test cases for MessageBlobStoreTimo Tijhof2019-03-271-0/+240
Move source code to includes/resourceloader to match test case. This is part of ResourceLoader and not meant to be used elsewhere. Merge two similar test cases for getting blobs and fetching messages which were doing the same thing. Rewrite the test names to be a better reflection of the stories they test, add comments for why, and re-order them to put related tests together. Move test-utilities to the bottom and make them actually private. Change-Id: I7a437eebf3ba6a722e286dfe77c2f9fe49ad222f