aboutsummaryrefslogtreecommitdiffstats
path: root/includes/ResourceLoader/Module.php
Commit message (Collapse)AuthorAgeFilesLines
* ResourceLoader: Add page title to user script syntax errorTimo Tijhof2025-03-261-9/+12
| | | | | | | | | | | | | | | | | | | | | | This follows-up Ie309e761f (53a3c8b417), in which we switched from calling JsMinPlus/JSParser (which took $fileName as argument, and throw an exception that already included "on line N in X.js") to calling Peast. That patch formatted the error as "on line N" but forgot to include "in X.js". Test plan: * Log in as admin and create "MediaWiki:Common.js" with "foo/;", which is invalid syntax. Then browse the main page and check the browser console. * Before: "Parse error: Unexpected: ; on line 1" * After: "Parse error: Unexpected: ; on line 1 in MediaWiki:Common.js" While at it, document why this cache key is not purely MD5-based, but also includes wiki and page title. Change-Id: I16c3b1dacd02ee26a254809e6a9ac60f72aba4da
* resourceloader: Remove getScriptURLsForDebug()Hannah Okwelum2025-02-171-44/+0
| | | | | Bug: T367441 Change-Id: I16db275bf60b80954b7e271fbeb3a86a9b8bf11e
* ResourceLoader: Remove Debug mode v1Hannah Okwelum2025-02-141-10/+3
| | | | | Bug: T367441 Change-Id: I1c6d7289c7542976393521c8d57f43a4711cc3d6
* ResourceLoader: Simplify injection of DependencyStore to Module objectHannah Okwelum2024-10-261-57/+23
| | | | | Bug: T371152 Change-Id: I789c125a37f0d3549922060894f863bab146d948
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-1/+1
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* ResourceLoader: Improve documentation for "group" property of a modulethiemowmde2024-07-211-1/+5
| | | | Change-Id: Ib5f8a8d9d26850543b5e4b2bf22620c2beb29f94
* Merge "ResourceLoader: Add module property skipStructureTest"jenkins-bot2024-03-131-0/+12
|\
| * ResourceLoader: Add module property skipStructureTestTim Starling2024-03-111-0/+12
| | | | | | | | | | | | | | | | | | Allow extensions with very special modules that can't be called in a testing environment to skip ResourcesTest::testRespond(). Needed by If1186797fd047d4f for ext.wikisource.OCR. Change-Id: Id02915d9633c2d8209d2ff2e60f6748095ec10fe
* | resourceloader: Raise USERJSPARSE_CACHE_VERSION following Peast upgradeSiddharth VP2024-03-071-1/+1
|/ | | | | | | | This ensures the validation results produced by the older version of Peast are discarded. Bug: T359014 Change-Id: Iddc780a42d0faf448fe5c693a3b85b5d6da3469d
* ResourceLoader: Follow-up resourceloader_build metric changeTimo Tijhof2024-02-071-3/+5
| | | | | | | | | | | * $statName should be set, and was/is unconditionally used as a string. The added `?: 'na'` appears not to be needed. Follows-up Ida57415073 (1204f0dee4). * Fix lazy setName() calls in tests to actually pass a valid non-empty string, like other tests do. Follows-up I1c03e3f470 (3a9744921d). Change-Id: I1c8cd7d8c043845c0373a457b389213e5111976b
* Drop old ResourceLoader class aliases, deprecated since 1.39James D. Forrester2024-01-311-3/+0
| | | | | | | Depends-On: Iff15a2e13a3507ef1ab5cfa504ca1a1c8d2b2a60 Depends-On: Icf8331e35acf6fe51a8303ee639921b9e4f3e6bb Depends-On: I5a5af003026db69b279ddde0b0dedbfcfe7d70fd Change-Id: I5929a2f760c8d21c1cb2542a19220a91ac7240e4
* ResourceLoader: Convert resourceloader_build metric to statslibKeith Herron2024-01-311-5/+8
| | | | | Bug: T355960 Change-Id: Ida574150735560f8265133754cf27d12cb7a4221
* ResourceLoader: Drop targets system, deprecated in 1.41James D. Forrester2024-01-121-12/+0
| | | | | | Bug: T340802 Depends-On: Ie936afed7042d5a4713b027c30d7487565a35eaf Change-Id: Icad30d62301be5d7390ebdf34e818519e3fe56c4
* ResourceLoader: Switch validateScriptFile() from JSMinPlus to PeastTimo Tijhof2024-01-061-11/+6
| | | | | | | | | | This adds support for ES6 and ES7 syntax to user scripts, thus matching the wikimedia/minify library. Bug: T75714 Depends-On: I43d4619a32e37eb42e1aaa55a1f602962609c52b Depends-On: If3b2b4a75013baeaa0d9b92cd10dfb06e5534153 Change-Id: Ie309e761f8b20640f7c0e85def0a3d1ccc8a658e
* Namespace Config-related classes under \MediaWiki\ConfigJames D. Forrester2023-09-211-1/+1
| | | | | Bug: T166010 Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
* ResourceLoader: Have FileModule deliver additional path informationTim Starling2023-08-231-12/+23
| | | | | | | | | | | | | | | | * Have FileModule::getScript() always return an array with a filePath or fakeFilePath, not a string. This allows source maps to be constructed. * Make the scripts returned from Module::buildContent() always be an array. Module::getScript() may still return a string for b/c. * In makeLoaderImplementScript(), interpret the new plainScripts array. Factor out the package file normalization loop from makeLoaderImplementScript(). * Fix missing base path in mediawiki.base. * Improve relevant doc comments. Bug: T47514 Change-Id: I392a8cce9a0febc707b6cb17412e3b723c9cc686
* ResourceLoader: wrap module definitions in functionsTim Starling2023-08-111-1/+1
| | | | | | | | This is an intermediate step towards the linked bug, to help untangle the performance impacts. Bug: T343407 Change-Id: I086f173f811fb44683f4a67bf6bc415d7e27f593
* ResourceLoader: deliver deprecation warnings as stringsTim Starling2023-08-031-5/+25
| | | | | | | | | | | | | | | | | | | It's awkward to construct a source map when the file contents is modified after loading. Delivering deprecation warnings as JS code seems like an odd convention anyway. So, send the module deprecation warning as an additional parameter to mediawiki.loader.implement(). Deprecation warnings are no longer displayed in only=scripts mode. Remove deprecation tests from FileModuleTest since FileModule no longer has any relevant deprecation code. Add tests to ModuleTest. Deprecate Module::getDeprecationInformation(). Bug: T47514 Change-Id: I20938cf4ab78afc9a2d72fbd163a7c5f21755820
* ResourceLoader: Factor out the loop body of makeModuleResponse()Tim Starling2023-07-241-0/+1
| | | | | Bug: T47514 Change-Id: Ia33ce18812b31d26b6b7ab6e50639c01c9353389
* ResourceLoader: Remove Module::getName check before $stats->timing()Timo Tijhof2023-04-141-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Follows-up 2c93649672b (I2b2905d7452bd2), which added the conditional in order to silently accept case where setName was not called. getName() is not conditinally accessed elsewhere. It being undefined would be an error condition on the part of the caller. In this case, Wikibase forgot to call setName, which I1cc5c54db42ca fixes. See also ResourceLoader::getModule(), which indicates values that must be injected in production code. In tests we can sometimes be lazy and skip a required injection, such as Config and HookContainer, that we only use in certain methods that perhaps your test doesn't call. However, upon finding that a test starts exposing such need, the test need to be updated to provide or mock that value, instead of tolerating the absence in production code. This change also fixes a bug in the previous change which would have theoretically emitted 'all' without the per-module metric, which would invalidate percentage-based calculations in Graphite as the total would no longer be equal to the sum. Depends-On: I1cc5c54db42ca3a9da38ab56cf88cd71dc5b8343 Change-Id: I3c9b7a17b1331750c631b8dc3e9e7ee04d79884f
* ResourceLoader: tweak comments and error messagesTim Starling2023-04-031-3/+2
| | | | Change-Id: Ifcaefedf65b090a87ec1417808277ae6451302dc
* ResourceLoader: Raise MW JavaScript startup requirement to ES6James D. Forrester2023-03-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The UA sniffs that overrode the feature tests are no longer needed. * MSIE 10: Fine, rejected by feature checks. * UC Mini "Speed Mode": Redundant, the version that this sniff matched is pre-ES6. Current versions of UC Mini don't appear to support enabling "Speed Mode" on random websites nor does it offer it for Wikipedia specifically. Details at https://phabricator.wikimedia.org/T178356#8740573. * Google Web Light: Redundant, shutdown as of 2022. Any references or extensions that still reach the proxy, get redirected to our online URLs https://googleweblight.com/?lite_url=https://en.m.wikipedia.org/wiki/Banana https://phabricator.wikimedia.org/T152602 https://en.wikipedia.org/wiki/Google_Web_Light * MeeGo: Redundant, discontinued and presumed rejected. Either way, unsupported. * Opera Mini: Fine, rejected by checks. Details at https://phabricator.wikimedia.org/T178356#8740573. * Ovi Browser: Redundant, discontinued and presumed rejected. Either way, unsupported. * Google Glass: Improve UX (since 2013, T58008). * NetFront: Redundant. Old versions are presumed rejected. Current versions are Chromium-based and presumed fine. The exclusion was not UX based, but due to jQuery explicitly not supporting it in 2013. This is no longer the case, so we can let the feature test lead the way here. * PlayStation: Redundant, same story as NetFront. The version that matched the sniff is presumed rejected. Current versions probably fine, but even not, don't match our sniff so are already enabled today. Bug: T178356 Change-Id: Ib6263ce3ffd11af5e501de8857f3e48a248c6210
* Adjust default targets in RL/ModuleKosta Harlan2023-02-011-1/+1
| | | | | | | | | | | | | | | | | | | In Ia062ff2d8b8732b0d3498c1a614bbf6a3e3a7ddb, we changed the default targets to desktop/mobile. This broke CI for PageTriage, which has a RL module that extends ResourceLoader\Module, and which sets the default targets for "desktop" only. I am not sure if leaving ResourceLoader\Module as "desktop" only was a deliberate choice or an oversight, but it seems to be more consistent to have it defined as desktop/mobile. This will fix the issue for PageTriage and other extensions that extend ResourceLoader\Module and don't have any targets explicitly defined for their RL modules. Follows-Up: Ia062ff2d8b8732b0d3498c1a614bbf6a3e3a7ddb Bug: T127268 Bug: T328497 Change-Id: I48ed19912610a74af66d620510c192c7ba87039a
* Don’t track build statistics for unnamed modulesLucas Werkmeister2022-11-021-2/+5
| | | | | | | | | | | | Module::getName() is allowed to return null (and there are some existing modules where it returns null, such as Wikibase’s SitesModule). Passing the null name directly into strtr() produces a warning in PHP 8.1, but more importantly, it will also result in tracking the metric `resourceloader_build.` without any stat name (under any PHP version). Fix this by not tracking the individual module in this case. Bug: T319219 Change-Id: I2b2905d7452bd2694c5c1af3272e0fb0e95ff144
* ResourceLoader: readability cleanup and simplification in Module classDannyS7122022-06-281-45/+40
| | | | | | | Use early returns to reduce nesting, unhoist variables, should be a no-op in terms of functionality. Change-Id: Ic6a63dccb982615b8b3e70aabd059dec70244374
* ResourceLoader: Remove unchecked exception annotationsAdam Wight2022-06-221-9/+6
| | | | | | | | Also repair two `@see` annotations referring to methods that didn't exist. Bug: T240672 Change-Id: I2edb39554bcf46fdc83bd138ef7bb9065c2c0696
* ResourceLoader namespace (attempt 2)Tim Starling2022-05-241-0/+1128
| | | | | | | | | | | | | | | | | | 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-1128/+0
| | | | | | | | | | | | 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-0/+1128
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