Also:
* Fix ref of CSSJanus that was meant to refer to CSSMin,
and clarify that this is about LESS specifically (not related
to CSS, and hence this is not something CSSMin can/should do),
and that it isn't specific to less.php.
* Rename and invert excludeMessagesFromBlob as pluckFromMessageBlob
so that we can express "get X" as "X" instead of "everything without Y".
* Remove the (object) cast from excludeMessagesFromBlob, which was specific
to the use case of one of its callers (getMessageBlob) where it is now
inlined.
Change-Id: Ia1667199aef6d383faeb213fb163cb0627d91f1e
It's only=scripts, not only=script. As written, following the
instructions in the comment that StartUpModule returns when you're using
it wrong doesn't work, this fixes that.
Change-Id: Ib0cb2ce18dbc446dc3c5f3c670b4c29064d000d9
Instead of hashing each file separately, hash them in a batch.
Previous research on this area of code has identified the suppressing
and restoring of warnings to have a measurable cost, which is why
this was optimised in 3621ad0f82. However, we never really made
use if it (aisde from the 2:1 change in that commit itself), because
we always call it with a single item, turn it into an array, do the
hash and then merge it again.
Instead, we now let it handle a single module's set of files all
at once. Given that this no longer exposes an array of hashes,
also update the (private) signature of getFileHashes to reflect this.
This means all file modules will have their version bumped during the
next MediaWiki release. In general this happens for most releases
and weekly branches already (due to localisation update, general
maintenance, linting changes, and other internal changes). But,
noting here for future reference as this might not be obvious from
the diff.
Change-Id: I4e141a0f5a5c1c1972e2ba33d4b7be6e64ed6ab6
* Use LanguageFallback::getAll directly instead of the
deprecated wrapper Language::getFallbacksFor.
* For the loop over package files, use foreach instead of the slower array_map.
Also incorporate a simple simple isset() check in that foreach loop,
instead of iterating the values a second time with array_filter.
This also makes the check more explicit (we discard values that have
'filePath' unset or set to null), previously array_filter rejected any
value that could indirectly cast to boolean false.
* For the safeFileHash loop, also use foreach with assignments instead
of the slower array_map. As a side-effect this now makes explicit that
we don't preserve array keys (assignments use []= to push).
This means we can remove the array_values() call, which previously performed
yet another loop and transformation on our array.
Bug: T233059
Change-Id: I3fe9f0a9ddcce8870ac02986193022a12ecc1606
These attributes are only accessed at a time when performance isn't
critical (e.g. tests), so we can skip caching them and read each
extension.json file again when we do need them.
At the same time, we want to reduce the size of the array that we're
caching due to PHP 7 performance regressions with APC (T187154).
'QUnitModules' is the first attribute to be converted into a lazy-loaded
attribute.
Bug: T220994
Change-Id: I224cdace05dbac00ff947c41daecb74b07c967bb
This protected method was forgotten to be removed in MediaWiki 1.31,
when the public ResourceLoaderModule::getHashMtime() and ::getDefinitionMtime()
methods were removed (originally deprecated in MW 1.26).
Bug: T233059
Change-Id: Ia89d9b2fad99628e60063383a3f379db3fb49c47
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
Avoid use of wfTimestamp and wfDebugLog global functions.
Also simplify some of the error messages around processing of
'packageFiles' definitions and throw generic LogicException
instead of MWException.
Change-Id: I55ce1f107f53dfdfe673cbe4411b0a7c4e24b2ea
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
All mediawiki.skinning modules are repurposed as variants of the
ResourceLoaderSkinModule and those ResourceLoader modules are marked for
deprecation. Skins will now be encouraged to use the ResourceLoaderSkinModule
class themselves as part of their own style module rather than using a
module defined in core.
Bug: T118134
Bug: T114695
Change-Id: I4bc8b9b4da1c16eed34f3a517ec695019381e764
This is to make it behave in a more object orientied way. The
goal is to make it be easier to allow extensions to mark certain
pages as requiring a different policy (For example, CodeEditor
extension uses a blob: url with a WebWorker. We don't want to
include that on the policy of every page, but allow the extension
to mark it as required whenever needed).
This commit does not change code behaviour in any way.
Change-Id: I4bf53dabb6e6c5446cea99a64db68b300cef2fd4
The PHP code handling 'packageFiles' looks like it only expects
numeric arrays, and not associative arrays. Therefore in JSON the
value for the 'packageFiles' key should be arrays and not objects.
(And a special case of a string, handled the same as single-element
array, is also accepted.)
Individual items in the array can be not only strings, but also
objects, describing data which is pulled from other sources than a
file.
* ResourceLoaderFileModule: Remove unused variable and tweak docs.
Change-Id: I6c3d186de1877f73d4a4e3fec7d6d632a5d5fa83
Currently packageFiles callbacks take 2 parameters, $context and $config.
This patch allows for specifying an extra parameter in the packageFiles
definition that will be passed to the callback. Example:
'callback' => function ( $context, $config, $extra ) { ... },
'callbackParam => [ 'this is val 1', 'this is val 2' ],
The callback will be called with the usual $context and $config
parameters, and the extra array is passed as third parameter.
Bug: T233634
Change-Id: Ie11874665f4f9a557d4e394dcab3a972887e8126
These are almost only doc changes, with two exceptions:
1-In LinkHolderArray, int-alike array keys are now cast to int, to be uniform with what we do in other code paths
2-In ExtensionRegistration, changed a line to throw an Exception
immediately, instead of an ExtensionDependencyError. This is because the
latter takes an array with msg and type, but we were passing it a plain
string (and in fact the code was bugged).
Bug: T231636
Change-Id: I8b0ef50d279c2a87490dde6a467a4e22c0710afd
getDeprecationInformation without $context is deprecated since
commit 2fc229116d (I5341f18625209446a6d00).
Depends-On: Ifa1a3bb56b731b83864022a358916c6aca5d7c10
Change-Id: Idd4aba87c65101f9ec257a7ff745fe29ed19c7c9
These were all checked with codesearch to ensure nothing is overriding
these methods.
For the most part, I've updated the signature to use nullable types; for
two Pager's, I've just made all parameters non-optional, because you're
already forced to pass them with a required parameter at the end.
Bug: T231636
Change-Id: Ie047891f55fcd322039194cfa9a8549e4f1f6f14
ResourceLoader::getLessVars is deprecated since ca510f742 included in
MW 1.32 and hard-deprecated since 1b32592d9 included in MW 1.34.
Bug: T140804
Change-Id: If88c71ed7fdf3c6a5cf89a50197e246c201ebaa2
Deprecated since MW 1.27. Mainly for internal use only by the
`mediawiki.api` module, but several uses emerged elsewhere too.
These have been migrated as of T233442 (Thanks @TheSandDoctor!)
Bug: T234576
Change-Id: Id7bb031ed1680f1a3671d338726eecb8e9152b6d
It was mentioning what ResourceLoader needs to do with the method
internally (such as "call it from getVersionHash"), but that is
irrelevant to the developer implementing the method in sub classes.
Also update the rest and make it hopefully a bit easier to follow.
Change-Id: Idc73e344bb4ffc3f83e2efcd358ca34f98bc5443