Commit graph

19 commits

Author SHA1 Message Date
jenkins-bot
c903124b77 Merge "Make use of ?:, ?? and ??= operators in mostly trivial cases" 2022-12-16 02:51:26 +00:00
Matěj Suchánek
a592d47e91 Clean up redundant array manipulation
PHP does this implicitly.

Change-Id: I009a7c93d44fb5e8c430c971cfc637fa04a8e68d
2022-12-11 12:42:29 +01:00
Kosta Harlan
e596af730d Revert "resourceloader: Modern ES6 code should be forced to target mobile"
This reverts commit 15622ea09a.

Reason for revert: T324525

Bug: T323542
Change-Id: I496ce3589f0322e7ac0f109081fa5e0587f48f94
2022-12-06 08:19:03 +00:00
thiemowmde
70aa9c8e35 Make use of ?:, ?? and ??= operators in mostly trivial cases
The motivation is to make the code less confusing. I hope this is the
case.

?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.

Change-Id: Id807affa52bd1151a74c064623b41d950a389560
2022-12-05 21:37:13 +01:00
Jon Robson
15622ea09a resourceloader: Modern ES6 code should be forced to target mobile
First step towards constraining how the targets system can be used
with the eventual goal of dismantling target system altogether.

As part of the many modernization efforts in place, we should
be targeting mobile experiences by default. For now I am
targeting only modules that are writing ES6 code for desktop
only. In future this should be expanded to modules using
packageFiles and modules targetting mobile only.

The implication of this change is that any ES6 module that has
not specified targets, will now automatically load on mobile site.

In the case of the 3 depends-on there doesn't seem to be any
problem with targeting mobile as the way these modules are
loaded is restricted based on context.

We will log warnings to inform us where modules disobey this
rule.

Bug: T323542
Depends-On: I2e31ba2bd2aea192f428531f6c92afa551448fef
Change-Id: Iff6bfbba406dec5b8c8be644dbf21ee3b3879fda
2022-11-30 20:34:49 +00:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
Umherirrender
5c5498a202 Remove unused key variable from foreach loops
Change-Id: Id2d91e30a6f7cc4eb93427b50efc1c5c77f14b75
2022-09-21 21:18:43 +02:00
jenkins-bot
42d35cbc30 Merge "ResourceLoader: replace FileModule::collateFilePathListByOption with private helper" 2022-06-23 03:46:42 +00:00
DannyS712
9177d32415 ResourceLoader: replace FileModule::collateFilePathListByOption with private helper
All callers provide 'media' for $option and 'all' for $default, just use
those values directly. Class is not stable to extend so this protected
method is not part of the stable interface, codesearch shows no
code on gerrit outside of core that calls the method. Since the $option
parameter is removed, the name no longer makes sense, renamed and
made private.

Change-Id: I875942d5b8c339031fd302f547c9cf16328c9bf2
2022-06-23 03:28:22 +00:00
jenkins-bot
08af445652 Merge "FileModule: replace 'master' with 'primary' in comments" 2022-06-22 09:32:03 +00:00
DannyS712
7c89961a8b Remove deprecated and unused FileModule::compileLessFile()
Deprecated since 1.35

Change-Id: If2c86c1cd269e814257d43a1c9dd0c35fc15e55f
2022-06-22 01:03:08 +00:00
DannyS712
ff82f1e18c FileModule: replace 'master' with 'primary' in comments
Bug: T254646
Change-Id: Iaf61e868ffa4e70e518a74f679cf7cd0df5e6834
2022-06-22 00:50:17 +00:00
Adam Wight
360343afb3 ResourceLoader: Remove unchecked exception annotations
Also repair two `@see` annotations referring to methods that didn't
exist.

Bug: T240672
Change-Id: I2edb39554bcf46fdc83bd138ef7bb9065c2c0696
2022-06-22 00:25:57 +01:00
Timo Tijhof
10805be34b resourceloader: Improve internal type hints in FileModule class
Follows-up I56a0ee74595404e1, I38a0761ae4633 and I6c3d186de1877f73d4.

Remove most "Usage" examples as these are internal and
mostly-normalized class fields. This is not where end-users should
look for documentation. Besides, many of the examples were wrong or
outdated, and almost all were incomplete. It also had an inherent
dilimma between describing all possible valid input and describing
what we actually store in that instance variable after normalization
in the class constructor. The usage docs have long been moved
to the MW config file, so we can omit that.

In its stead, place more complete and accurate type hints for Phan
to understand the possible code paths, in particular to reflect
the use of FilePath objects.

Change-Id: I1cc002f350785d3f46f79be5defb7b3cadbebf34
2022-05-29 16:41:09 +00:00
Bartosz Dziewoński
7f9aaf26e3 resourceloader: Allow using FilePath directly in 'packageFiles' array
This already works in 'scripts', 'styles' etc.

Change-Id: I56a0ee74595404e1c40483b84400056d6f87b07d
2022-05-27 21:41:13 +00:00
Bartosz Dziewoński
566b185e9c resourceloader: Tweak RL\FilePath handling in packageFiles
ResourceLoader's FilePath is designed to allow a FileModule
to include files that exist outside of the module's localBasePath,
to allow skins and extensions to extend core MediaWiki modules.
This is accomplished by having the FileModule use the FilePath's
localBasePath instead, in FileModule::getLocalPath.
(Similarly for remoteBasePath, but these are going out of fashion.)

However, the code processing 'packageFiles' did not handle this right:
it used FilePath's localBasePath when it appeared as a 'file',
but not when it was returned by a 'callback' or 'versionCallback',
using the FileModule's localBasePath instead in that case. Most
existing uses of FilePath in 'packageFiles' required the same base
path as the module, so it was convenient to avoid providing it twice.

To keep that convenience (already relied on by some extensions too)
while also allowing skins and extensions to add files from their own
directories to existing modules, the code processing 'packageFiles'
now uses FilePath's base paths in all cases, but they are optional,
and will fall back to the FileModule's paths when not provided.

Follow-up to 2890bca27d.

Change-Id: I38a0761ae4633a567b685b52c1d73b6ce280ffb7
2022-05-27 22:40:41 +01:00
Tim Starling
3e2653f83b ResourceLoader namespace (attempt 2)
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 a241d83e0a.

Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
2022-05-24 15:41:46 +00:00
Lucas Werkmeister (WMDE)
a241d83e0a Revert "ResourceLoader namespace"
This reverts commit e08ea8ccb9.

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
2022-05-16 14:43:33 +00:00
Tim Starling
e08ea8ccb9 ResourceLoader namespace
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
2022-05-16 14:41:27 +10:00
Renamed from includes/resourceloader/ResourceLoaderFileModule.php (Browse further)