Commit graph

1282 commits

Author SHA1 Message Date
jenkins-bot
5e31eeea66 Merge "resourceloader: Document variable escape logic in LessVarFileModule" 2019-12-20 16:57:38 +00:00
jenkins-bot
bd5fbc9c4a Merge "resourceloader: Fix typo in StartUpModule dummy output" 2019-12-19 17:38:41 +00:00
Timo Tijhof
fe11acb2a7 resourceloader: Document variable escape logic in LessVarFileModule
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
2019-12-18 23:06:01 +00:00
jenkins-bot
1c3383bac3 Merge "resourceloader: Use FileContentsHasher batching in FileModule::getFileHashes" 2019-12-17 12:11:58 +00:00
jenkins-bot
2e09c3f0d4 Merge "resourceloader: Various optimisations in FileModule::getFileHashes()" 2019-12-17 12:07:41 +00:00
Roan Kattouw
4bcfeba16e resourceloader: Fix typo in StartUpModule dummy output
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
2019-12-17 12:56:53 +01:00
Timo Tijhof
6bf01cfaa3 resourceloader: Use FileContentsHasher batching in FileModule::getFileHashes
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
2019-12-17 11:56:22 +00:00
Timo Tijhof
b18fe40fcc resourceloader: Various optimisations in FileModule::getFileHashes()
* 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
2019-12-17 12:53:39 +01:00
jenkins-bot
6b8ab97ac7 Merge "resourceloader: Remove ResourceLoaderModule::safeFilemtime()" 2019-12-17 11:46:22 +00:00
Kunal Mehta
d6390ba1ee registration: Implement lazy-loaded attributes
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
2019-12-15 19:04:50 +00:00
Timo Tijhof
bfa03f8bfa resourceloader: Remove ResourceLoaderModule::safeFilemtime()
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
2019-12-15 18:53:55 +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
Timo Tijhof
9c0dee3965 resourceloader: Use ConvertibleTimestamp and Logger directly
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
2019-12-04 16:24:40 -08:00
jenkins-bot
7eb2495e77 Merge "LocalisationCache: Don't instantiate ResourceLoader" 2019-12-01 20:15:05 +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
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Umherirrender
337ecb0514 Add missing @param and @return to documentation
Change-Id: Ibc5849cc8ea7e7c4eb30ded9c1cfa5f52187c377
2019-11-10 22:12:58 +00:00
jdlrobson
6845912bcf ResourceLoaderSkinModule: Provide optional mediawiki.skinning styles
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
2019-11-08 04:25:50 +00:00
Timo Tijhof
ae08640853 OutputPage,ResourceLoaderStartupModule: Separate internal from public config vars
Change-Id: Ic54d3b36fb379d77139b21b46db7da9f78869e37
2019-10-31 19:35:45 -07:00
jenkins-bot
17b931caf6 Merge "Remove Language::factory and getParentLanguage use" 2019-10-29 09:25:29 +00:00
Brian Wolff
67ea4f5747 Mild refactoring of ContentSecurityPolicy
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
2019-10-28 09:02:14 -07:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
jenkins-bot
44f51fcf90 Merge "resourceloader: Use PHP7 return hints in StartupModule and Context" 2019-10-27 10:01:05 +00:00
Timo Tijhof
3ef19d20fb resourceloader: Restore test case for ResourceLoaderImage
Follows-up 043d88f680 which had to disable this due to changes
in Language.php internals.

Change-Id: I5272142a8291449619bbcad8c99c751bdc51d757
2019-10-25 01:22:23 +00:00
Bartosz Dziewoński
d50c7f5b56 extension.schema.v2: Fix schemas for 'packageFiles'
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
2019-10-24 22:30:10 +02:00
Daimona Eaytoy
b5f0d61ee4 Fix new phan errors, part 8
Bug: T231636
Change-Id: I61852ba55362ab9ae8cc8c1ab6b27565ce1d08e7
2019-10-22 10:09:13 +02:00
jenkins-bot
23dfdf865f Merge "Fix new phan errors, part 7" 2019-10-21 23:00:40 +00:00
Daimona Eaytoy
b1a5367ec8 Fix new phan errors, part 7
Bug: T231636
Change-Id: Ia5e0abee7163c5a1abd0bb53b89603cc2e7a9b5c
2019-10-21 22:10:20 +00:00
jenkins-bot
fec45ad99a Merge "resourceloader: Support passing extra arguments to packageFiles callback" 2019-10-21 22:08:09 +00:00
Andrew Otto
e35f53316c resourceloader: Support passing extra arguments to packageFiles callback
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
2019-10-21 15:07:53 -04:00
Ammar Abdulhamid
0454b34c4d resourceloader: Simplify $wgResourceLoaderMaxage config
Remove support for the 'client' and 'server' subkeys.

Bug: T235314
Change-Id: Ibeb2404b0f7dc8a9198e73344d54a3cb0176de08
2019-10-19 21:28:58 +01:00
Timo Tijhof
d3fdd4a3e7 resourceloader: Use PHP7 return hints in StartupModule and Context
Change-Id: I1aaa3a7274e84d2c872d7b75ea602aeeddd0a0c0
2019-10-19 00:33:35 +01:00
jenkins-bot
d5a1f9c6ff Merge "resourceloader: Expose StartupModule::getConfigSettings for internal use" 2019-10-16 20:21:37 +00:00
Timo Tijhof
15fb9f22db resourceloader: Expose StartupModule::getConfigSettings for internal use
Bug: T235350
Bug: T229836
Change-Id: Ia368ddcc650cdad07c48a93c6aaae24627e73458
2019-10-12 20:49:12 +00:00
Daimona Eaytoy
bd5b6f98ba Fix new phan errors, part 3
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
2019-10-12 10:35:22 +00:00
jenkins-bot
41ee29ac7a Merge "resourceloader: Require $context in getDeprecationInformation" 2019-10-11 03:49:39 +00:00
Fomafix
e5eb3568be resourceloader: Require $context in getDeprecationInformation
getDeprecationInformation without $context is deprecated since
commit 2fc229116d (I5341f18625209446a6d00).

Depends-On: Ifa1a3bb56b731b83864022a358916c6aca5d7c10
Change-Id: Idd4aba87c65101f9ec257a7ff745fe29ed19c7c9
2019-10-11 03:36:04 +00:00
Daimona Eaytoy
e3412efac3 Unsuppress PhanParamReqAfterOpt, use PHP71 nullable types
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
2019-10-10 11:53:58 +02:00
Fomafix
705146d102 resourceloader: Add array type hints (2)
This change is a follow-up to a9823d16f6.

Change-Id: I80f570a98c02aa5521504262a6839e9241936db1
2019-10-10 04:58:16 +00:00
Fomafix
7c7f3efcb8 resourceloader: Drop deprecated ResourceLoader::getLessVars
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
2019-10-09 22:31:52 +00:00
jenkins-bot
d5af78f348 Merge "resourceloader: Remove 'editToken' from mw.user.tokens" 2019-10-06 18:57:28 +00:00
Umherirrender
8752df6592 Use varargs for MessageLocalizer::msg and similar
Bug: T191666
Change-Id: I59f2ae1a96af392026fc106e57d23553003c16b8
2019-10-05 17:47:49 +00:00
Fomafix
a9823d16f6 resourceloader: Add array type hints
Change-Id: I4844eae68e85adc46e52646ea066b459bbabdcce
2019-10-05 15:26:56 +00:00
Timo Tijhof
a0447d3a67 resourceloader: Remove 'editToken' from mw.user.tokens
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
2019-10-04 01:05:56 +01:00
Timo Tijhof
578703a146 resourceloader: Improve getDefinitionSummary() docs
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
2019-10-03 22:38:00 +01:00
Aaron Schulz
a65edcffc0 Avoid dynamic call to static method in ResourceLoaderModule::buildContent()
Change-Id: I4e3d944b6468ad2f4bfc39532498d8ca38617689
2019-09-30 16:08:05 -07:00
Fomafix
1b32592d9c resourceloader: Hard deprecate ResourceLoader::getLessVars
ResourceLoader::getLessVars is already deprecated since MW 1.32.

Change-Id: If2fbe7828d8cde73575c0306486835fa1ea06b84
2019-09-30 00:07:30 +00:00
jenkins-bot
565925035a Merge "resourceloader: Add version to ResourceLoaderImage urls for long-cache" 2019-09-28 20:20:32 +00:00
jenkins-bot
e1724b7a10 Merge "resourceloader: Simplify makeLoaderStateScript and makeLoaderSourcesScript" 2019-09-28 20:02:18 +00:00
jenkins-bot
6f54a1695b Merge "resourceloader: Remove support for $context === null in getContentObj" 2019-09-28 20:00:24 +00:00