aboutsummaryrefslogtreecommitdiffstats
path: root/includes/resourceloader/ResourceLoaderFileModule.php
Commit message (Collapse)AuthorAgeFilesLines
* ResourceLoader namespace (attempt 2)Tim Starling2022-05-241-1475/+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/+1475
| | | | | | | | | | | | 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-1475/+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
* Merge "Use str_starts_with/str_ends_with"jenkins-bot2022-05-031-1/+1
|\
| * Use str_starts_with/str_ends_withAryeh Gregor2022-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All the other ways of doing it were ridiculous and much harder to read, and usually required repeating the needle expression (to get its length). I found these occurrences by grepping for various expressions, but I undoubtedly missed some. I didn't try replacing the many instances of strpos(...) === 0 with str_starts_with(...), because I think they're readable enough as-is (although less efficient). Likewise I didn't try porting strpos(...) !== false to str_contains(...). For case-insensitive comparisons, Tim Starling requested that we stick with substr_compare() because it's more efficient than calling strtolower(). On PHP < 8 these functions will be included with a polyfill via vendor/autoload.php. This is included at the beginning of includes/AutoLoader.php, so if our autoloader has been included the polyfill will be available. This means it should be safe to call these functions from any code that would not be usable without our autoloader. Three uses that Tim Starling identified as being performance-sensitive have been split out to a separate commit for porting after the switch to PHP 8. Change-Id: I113a8d052b6845852c15969a2f0e6fbbe3e9f8d9
* | Remove access to config globals from more classesdaniel2022-04-281-8/+9
|/ | | | | | Bug: T294739 Depends-On: I84056024b0d3a9dcddb1ab4dc8596118bb3fe8ea Change-Id: If005958c76bbfabba74def4215c48fe94f297797
* Use MainConfigNames instead of string literalsAryeh Gregor2022-04-111-1/+2
| | | | | | | | Part 1, proof of concept. Hundreds of files left to go. These changes brought to you in large part by vim macros. Bug: T305805 Change-Id: I44789091e9f6394c800a11b29f22528c8dcacf71
* phan: Remove PhanPossiblyUndeclaredVariable suppressionUmherirrender2022-03-301-0/+1
| | | | | | | | | Make phan stricter about conditional variable declaration Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T259172 Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
* 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
* Try not to discard Excimer timeout exceptionsTim Starling2022-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Don't catch and discard exceptions from the RequestTimeout library, except when the exception is properly handled and the code seems to be trying to wrap things up. In most cases the exception is rethrown. Ideally it should instead be done by narrowing the catch, and this was feasible in a few cases. But sometimes the exception being caught is an instance of the base class (notably DateTime::__construct()). Often Exception is the root of the hierarchy of exceptions being thrown and so is the obvious catch-all. Notes on specific callers: * In the case of ResourceLoader::respond(), exceptions were caught for API correctness, but processing continued. I added an outer try block for timeout handling so that termination would be more prompt. * In LCStoreCDB the Exception being caught was Cdb\Exception not \Exception. I added an alias to avoid confusion. * In ImageGallery I added a special exception class. * In Message::__toString() the rationale for catching disappears in PHP 7.4.0+, so I added a PHP version check. * In PoolCounterRedis, let the shutdown function do its thing, but rethrow the exception for logging. Change-Id: I4c3770b9efc76a1ce42ed9f59329c36de04d657c
* Fix typos in comments (N-R)Siddharth VP2022-01-091-2/+2
| | | | Change-Id: I2d1bdb7531ff5126114a391550c2615ea6e244b3
* resourceloader: Allow debug=2 on JavaScriptTest, and misc whitespaceTimo Tijhof2022-01-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | * Use the int result of `ResourceLoader::inDebugMode()` directly in SpecialJavaScriptTest so that debug=2 is passed on to the next request, like it does on regular page views. This is likely temporary, because part of T85805 is to make debug=true default to debug=2, and part of T250045 is to hardcode debug=2 for JavaScriptTest. * Add a few line breaks to improve HTML output readability in debug mode. This is a no-op for prod as they get minified away. Today I learned: PHP string heredoc and nowdoc syntax strip not only the shared common indentation (which I knew), it also strips the first and last newline. Hence, switching ClientHtml to use double quotes. * Document the order in which lang/skin/debugScripts execute. Bug: T85805 Bug: T250045 Change-Id: I2ad179401cee6cf6ba30c0b462f0d48a8529ba74
* Prefer is_dir/is_file to file_existsKosta Harlan2022-01-041-1/+1
| | | | | | Mirco-optimisation for performance, part II. Change-Id: Ie8d5332a510bd18456ebc4a851f4d47f6a010dcb
* resourceloader: Only load LanguageFallback data if module has languageScriptsTimo Tijhof2021-11-111-7/+13
| | | | Change-Id: I955283c9df1601ab4fa69b472268194210f30bb4
* Merge "resourceloader: Fix null type docs for FileModule::getPackageFiles"jenkins-bot2021-11-091-5/+5
|\
| * resourceloader: Fix null type docs for FileModule::getPackageFilesUmherirrender2021-11-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The null check for the class property packageFiles needs change to check the return value of the function instead, because Phan would report an issue that a null value is used in the foreach. Phan does not understand the relation between the return value and the class property. When using a local variable then Phan can check that the value is never null when used. Change-Id: I48ac8a8fe55ae7b4e13bc94d2f2d2ede01fbc68b
* | resourceloader: Fix nullable documentation for property and return typesUmherirrender2021-11-021-1/+1
|/ | | | Change-Id: Ie8566c0e441d77ecd9cdf1220996deebdcd77fa7
* ApiParse: Support hidden skinsAmmarpad2021-09-201-1/+1
| | | | | | | | | | | | | | | | Since $wgSkipSkins is meant to only 'remove skin from preferences', it should not affect parsing with them. So these skins need to be allowed here. To achive this, this patch adds getInstalledSkins() method to SkinFactory to provide the complete. The method supersedes getSkinNames() which does the same thing but with ambiguous name. Description of getAllowedSkins() has been corrected as it was slightly incorrect. Bug: T237856 Change-Id: I0889b823d27f1a2830cc0205f5a21ed4de744e08
* Merge "resourceloader: Fix debug mode for RL-to-RL cross-wiki module loads"jenkins-bot2021-09-161-4/+8
|\
| * resourceloader: Fix debug mode for RL-to-RL cross-wiki module loadsTimo Tijhof2021-08-251-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The native "foreign module source" feature, as used by the GlobalCssJs extension, did not work correctly in debug mode as the urls returned by the remote wiki were formatted as "/w/load.php...", which would be interpreted by the browser relative to the host document, instead of relative to the parent script. For example: 1. Page view on en.wikipedia.org. 2. Script call to meta.wikimedia.org/w/load.php?debug=true&modules=ext.globalCssJs.user&user This URL is formatted by getScriptURLsForDebug on en.wikipedia.org, when building the article HTML. It knows the modules is on Meta, and formats it as such. So far so good. 3. meta.wikimedia.org responds with an array of urls for sub resources. That array contained URLs like "/w/load.php...only=scripts". These were formatted by getScriptURLsForDebug running on Meta, no longer with a reason to make it a Meta-Wiki URL as it isn't perceived as cross-wiki. It is indistinguishable from debugging a Meta-Wiki page view from its perspective. This patch affects scenario 3 by always expanding it relative to the current-request's wgServer. We still only do this in debug mode. There is not yet a need to do this in non-debug mode, and if there was we'd likely want to find a way to avoid it in the common case to keep embedded URLs short. The ResourceLoader::expandUrl() method is similar to the one in Wikimedia\Minify\CSSMin. Test Plan: * view-source:http://mw.localhost:8080/w/load.php?debug=1&modules=site For Module base class. Before, the array entries were relative. After, they are full. * view-source:http://mw.localhost:8080/w/load.php?debug=1&modules=jquery For FileModule. Before, the array entries were relative. After, they are full. * view-source:http://mw.localhost:8080/wiki/Main_Page?debug=true Unchanged. * view-source:http://mw.localhost:8080/wiki/Main_Page Unchanged. Bug: T255367 Change-Id: I83919744b2677c7fb52b84089ecc60b89957d32a
* | resourceloader: Avoid same named variables in inner and outer foreachUmherirrender2021-09-041-2/+2
| | | | | | | | Change-Id: I308ba9c607ba56b6d8ebf7d5f56d9e19d217d946
* | Merge "resourceloader: Call getStyleFiles from FileModule::getFileHashes"jenkins-bot2021-09-021-13/+3
|\ \
| * | resourceloader: Call getStyleFiles from FileModule::getFileHashesArlo Breault2021-09-021-13/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | ResourceLoaderFileModule::getFileHashes had its own code to collect style files that omitted the feature files that ResourceLoaderSkinModule adds. This deduplication should fix the issue where wgParserEnableLegacyMediaDOM was adding an additional feature file but didn't seem to be invalidating the cache. Bug: T51097 Bug: T290273 Change-Id: I50cf73a79cb1ce2b3d80510e80948e3e6fc1791b
* / resourceloader: Append newline to JavaScript only if missingFomafix2021-08-281-1/+1
|/ | | | | | | | | | In debug mode of a packageFiles module there is now only one newline between the JavaScript code and the closing }. This change reuses ResourceLoader::ensureNewline and make this to a interal public static function. Change-Id: I89519896e3dc56d966c4a63102904686bff6fac9
* resourceloader: Remove isFileModule() overhead from web requestsTimo Tijhof2021-08-191-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | About 1.5% of load.php wall-time is spent in isFileModule() calls during the ServiceWiring/getResourceLoader/register call early on. Reduce the overhead of this cost by moving that logic to the Module class. There are two costs that we save this way: 1. The inherent cost of applying the skinStyles. This is now limited to only the modules that are constructed in a given web request. Thus, apart from the startup response (which constructs all modules), for regular load.php requests and all index.php page views, the vast majority of modules will never need to be constructed, and thus won't pay this cost. 2. The overhead of predicting (and class-loading) for whether a module is (or will become) a FileModule object. This is what isFileModule() does and is the main reason I wrote this patch. It involves class loading, and checks and conditions that run 1000+ times at WMF. This is eliminated now because we no longer have to calculate this decision. Instead, the logic applies when it needs to (due to FileModule implementing it), and doesn't when it doesn't! Change-Id: Ia2db14f930800c96e767b94ef62fb00e9d52725b
* Fix a bunch of random typosDannyS7122021-06-291-1/+1
| | | | | | | | | | | | | | * yeild -> yield * paramter -> parameter * seperator -> separator * neccesary -> necessary * inital -> initial * intial -> initial * repsonse -> response * retreived -> retrieved Bug: T201491 Change-Id: I461941b027590997448f3bdd8a137a48bb338beb
* Installer: Do not use `mediawiki.skinning.interface` modulejdlrobson2021-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | The `mediawiki.skinning.interface` module includes the `toc` feature which is enabled by default, which requires a working localization environment which requires DBLoadBalancer which is disabled at this entry point. Instead use ResourceLoaderSkinModule directly with an opt-in policy where toc feature is not disbled. This means the definition in Resources.php is no longer necessary so it is marked for deprecation. The installer now works. A unit test is added to make sure the installer stylesheet doesn't break again. Bug: T270027 Change-Id: I851fcd0e50e3a70158d5bfa1fdcae3cd278694d6
* Fix typo in code 'defintion'anjali0412021-04-101-1/+1
| | | | | | | Changed the typo 'defintion' to 'definition' Bug: T201491 Change-Id: I6e866283b5fd8a2b2f237a770942ac03f735c138
* Merge "resourceloader: Allow modules to mark themselves as ES6-only"jenkins-bot2021-03-071-0/+8
|\
| * resourceloader: Allow modules to mark themselves as ES6-onlyRoan Kattouw2021-03-041-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modules that set "es6": true in their module definition will error when a non-ES6 client tries to load them. To detect ES6 support, this looks for native Promise support, RegExp.prototype.flags, and non-BMP characters in variable names. All browsers that lack full ES6 support fail at least one of those checks. To flag modules as requiring ES6, this adds a ! to the end of their version string. This takes up much less space than adding another register() parameter (which would have to be at the end). It's hacky, but we expect this feature to be relatively temporary, until we require ES6 for running any JS at all (probably in about a year). For distinguishing different types of errors thrown from sortDependencies(), use e.name. We can't subclass Error properly because that requires ES6. Bug: T272104 Change-Id: I45670c910ff12eb422ae54c9fcf372e45c7b2bf1
* | resourceloader: Add wikimedia/minify package and remove local copiesTimo Tijhof2021-02-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - JavaScriptMinifier: The public interface for this internal class is ResourceLoader::filter which, except for one caller (minify.php) is indeed consistently used already, no other callers need replacing. - CSSMin: Idem for minification, however, this class has some other method as well, which have a number of internal users, but none outside core. These have all been replaced in this commit. - Remove pear/net_url2 as own dependency as this was only used by CSSMin and recently added there. This is now a dependency of wikimedia/minify instead. This was not part of the public API and no longer mentioned here in composer.json or RELEASE-NOTES. (It remains pinned in mediawiki-vendor, however.) Bug: T273247 Depends-On: Iadff8c2112d5e53bd994ab4882006e8c644a2379 Depends-On: Id3c6dcc0b952a9efe34b3a9ed88b716101a51f87 Depends-On: I589be910f57289fd908b22db87241b0e52da60d4 Change-Id: I8d71fc64aeecdb31db218b02e361ae9bb0d19b48
* | resourceloader: Fix FileModule resource URLs for document root wikisTim Starling2021-02-241-1/+5
|/ | | | | | | | | | | Per the comment in extractBasePaths(), remoteBasePath is typically '/' when MediaWiki is installed in the document root. CSSMin knows what to do with that, but getRemotePath() was getting it wrong, generating an invalid protocol-relative URL. So, add a simple hack for this case. Change-Id: I16abf482e3a1a4a548c571de0e81cb3c1bdf55e1
* Use static closures where safe to useUmherirrender2021-02-111-1/+1
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Merge "Update a lot of unspecific "array" types in PHPDocs"jenkins-bot2020-11-131-16/+17
|\
| * Update a lot of unspecific "array" types in PHPDocsThiemo Kreuz2020-10-281-16/+17
| | | | | | | | | | | | | | | | | | This includes fixing some mistakes, as well as removing redundant text that doesn't add new information, either because it literally repeats what the code already says, or is actually duplicated. Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
* | resourceloader: Remove wfExpandUrl() coupling from CSSMinBrad Jorsch2020-11-051-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are three cases in CSSMin::remap where performs path resolution. 1. Absolute local path URLs to full URL. Example: url(/static/foo.png), url(/w/index.php?…), etc. These previously used wfExpandUrl(), which got the server name and protocol directly from $wgServer. We will now use the $remote parameter to get this information instead, which is generally set to something like https://wiki/w/resources/foo, and thus naturally contains the server name and protocol. The resolution is powered by the Net_URL2 library, allowing this to work outside Mediawiki as well. Some tests needed to change because they were calling CSSMin::remap with an incomplete $remote dummy values like "/" or "/w, because the test author (past me) was trying to be clever by not supplying it, knowing MW would ignore it. Now that it is consistently used, like normal calls from ResourceLoader would, the expected values will always be based on http://localhost/w, instead of sometimes the competing $wgServer value of `https://expand.example`. 2. Relative local path to full URL Example: url(foo.png), url(../foo.png), url(bar/foo.png) These were already using $remote. The only change is that they now use Net_URL2 library instead of blind string concatenation. One of the benefits of this is that we will no longer need to call wfRemoveDotSegments() to get rid of things like double slashes or redundant "../" sequences. Previously, thing like "foo//bar" or "foo/../bar" were cleaned up only due to wfRemoveDotSegments(). This is now naturally handled by Net_URL2. 3. Remote URLs Example: url(http://example.org/bar.png), url(//example.org/bar.png) This is generally not used in source code, but gadgets may use this, e.g. for upload.wikimedia.org or cross-wiki imports. Other changes: * One test case used spaces within the URL string in CSS, which the net_url2 library represents with percent-encoding instead. Same thing either way. Bug: T88914 Change-Id: Ibef70cc934c0ee8260a244c51bca9fb88c1c0d88
* | Remove documentation that literally repeats the codeThiemo Kreuz2020-10-271-1/+0
|/ | | | | | | | | | | | | | | For example, documenting the method getUser() with "get the User object" does not add any information that's not already there. But I have to read the text first to understand that it doesn't document anything that's not already obvious from the code. Some of this is from a time when we had a PHPCS sniff that was complaining when a line like `@param User $user` doesn't end with some descriptive text. Some users started adding text like `@param User $user The User` back then. Let's please remove this. Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
* resourceloader: Add skin-based 'mediawiki.skin.variables.less' importTimo Tijhof2020-09-151-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the SkinLessImportPaths attribute for skin-specific LESS import paths, which skins can use to override the mediawiki.skin.variables.less file. As a starting point, add the following 5 variables: * device widths (3x) To help phase out 'mediawiki.ui/variables'. These are commonly used by MobileFrontend. * @font-family-sans Recommended by Volker. Used by multiple skins. * @border-radius-base Recommended by Volker as example of something that we currently hardcode in MediaWiki core for Vector and OOUI/WikimediaUI in 'mediawiki.widgets.datetime' but should instead be allowed to vary by skin and OOUI theme. Remove the hardcoded value for '@border-radius-base' in various places in favour of importing from mediawiki.skin. The default is a bare default of 0 (as border-radius is off by default in the browser). The value for Vector is restored there by I47da304667811. The value for MonoBook is improved by I000f319ab31b. Bug: T112747 Change-Id: Icf86c930a3b5524254bb549624737d3b9dccb032
* Deprecate Skin methods moved to SkinFactoryAmmar Abdulhamid2020-08-261-1/+3
| | | | | | | | | | | | | * Skin::getAllowedSkins * Skin::getSkinNames Both are hard-deprecated and their equivalents in SkinFactory should be used instead. Bug: T257993 Depends-On: Ib8e4ec28f6755abec7e33476efefa78dcc2c6b78 Depends-On: Icc945ce1e3287a3b25152702818e5b2a90232677 Change-Id: I9595248ae5410361a5db50d1b95df1e513ac5a2c
* resourceloader: store relative paths in less compilation cacheAaron Schulz2020-07-211-28/+33
| | | | | Bug: T253055 Change-Id: Iac911eaeaf26ff8b85642dbc908a8a1e08d0d234
* Merge "resourceloader: Add some typehints and misc clean up"jenkins-bot2020-07-021-2/+1
|\
| * resourceloader: Add some typehints and misc clean upTimo Tijhof2020-07-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | phan: Enable redundant_condition_detectionUmherirrender2020-07-011-1/+1
|/ | | | | | | | Remove duplicate casts Suppress false positives Bug: T248438 Change-Id: I2f89664a4bcd3b39b15e7cf850adda2f0c90ae6f
* VueComponentParser: Use RemexHtml instead of PHP's HTML parserRoan Kattouw2020-06-221-5/+5
| | | | | | | | | | | | | | | | | | | This fixes an issue with HTML tags inside the <script> tag. Remex also doesn't throw errors on attributes like @click, although it does mangle them when producing DOM. To work around this, don't use DOM serialization for the template HTML, but parse everything again using a Remex parse+serialize pipeline that extracts the template and (optionally) removes comments and strips whitespace. One important effect of this change is that we'll have to forbid self-closing tags in Vue templates, because Remex doesn't handle those correctly (or rather, handles them *too* correctly). But on the up side, we can now allow shorthands for v-bind/v-on/v-slot again. Bug: T253334 Bug: T255587 Depends-On: I2253a2317187fe0d781ba5bfefab95e0f97d0a80 Change-Id: Id9a9728b7163601cc60bc587be07b70977d41970
* resourceloader: Improve packageFiles/skinScripts error messageTimo Tijhof2020-06-111-4/+1
| | | | | | | | | The uppercase spelling would I think be confusing, as the actual options are lowercase, which should be quoted when referred to in natural language. Bug: T251957 Change-Id: Ib97a2bc790799990f3e4b622b20636965a93fca1
* resourceloader: skinScripts cannot be used alongside packageFilesVas Jaremchuk2020-06-111-0/+6
| | | | | | | | The new exception was added in ResourceLoaderFileModule.php that packageFiles and skinScripts are incompatible. Bug: T251957 Change-Id: Id51763b9049b9b2041c4c1c47575d1a6cb3452b0
* resourceloader: Add more $wgResourceModules documentationHolger Knust2020-03-261-61/+3
| | | | | | | | Added documentation markup for $wgResourceModules in DefaultSettings.php and added a reference to it in ResourceLoaderFileModule.php. Bug: T232566 Change-Id: Ib4c0bd55cc2a06f48ef36ceb069906f1d3a22826
* resourceloader: Support single-file component .vue filesRoan Kattouw2020-03-121-5/+83
| | | | | | | | | | | | | | | | | | | | | | Allows .vue files to be used in package modules as if they were .js files: they can be added to the 'packageFiles' array in module definitions, and require()d from JS files. In the load.php output, each .vue file is transformed to a function that contains the JS from the <script> tag, then a line that sets module.exports.template to the contents of the <template> tag (encoded as a string). The contents of the <style> tag are added to the module's styles. Internally, the type of a .vue file is inferred as 'script-vue', and the file is parsed with VueComponentParser, which extracts the three parts. After the transformation, the file's type is set to 'script+style', and files of this type contribute to both getScript() and getStyles(). This change also adds caching to getPackageFiles(), because it now needs to be called twice (in getScript() and getStyles()). Change-Id: Ic0a5c771901450a518eb7d24456053956507e1ed
* resourceloader: Error in FileModule if provided path is a directoryJames D. Forrester2020-03-121-2/+4
| | | | | | | Pre-PHP74, these would silently return false; now they throw an error. Bug: T233012 Change-Id: I9bcb98fa1189c3d59a67a054c5b807d1495d82bb
* resourceloader: Factor out file loading in ResourceLoaderFileModuleJames D. Forrester2020-03-121-27/+26
| | | | | | | | This file had six different almost-identical calls to the system call file_get_contents(), which makes it hard to fix all nine of them neatly. Change-Id: I607f3cd3dbfa0f47f8d9766a27e581fdc127a0cf