aboutsummaryrefslogtreecommitdiffstats
path: root/includes/ResourceLoader
Commit message (Collapse)AuthorAgeFilesLines
* resourceloader: Remove getScriptURLsForDebug()Hannah Okwelum2025-02-172-65/+0
| | | | | Bug: T367441 Change-Id: I16db275bf60b80954b7e271fbeb3a86a9b8bf11e
* ResourceLoader: Remove Debug mode v1Hannah Okwelum2025-02-143-19/+6
| | | | | Bug: T367441 Change-Id: I1c6d7289c7542976393521c8d57f43a4711cc3d6
* Replace call_user_func with dynamic function callUmherirrender2025-02-132-5/+6
| | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I9ef131032a662a3b8db69aa7079dbd51f88f575a
* Merge "PageUpdater: move more updates to ingress objects"jenkins-bot2025-02-081-0/+49
|\
| * PageUpdater: move more updates to ingress objectsdaniel2025-02-061-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | This moves the following update logic out of DerivedPageDataUpdater::doUpdates into listeners for the PageUpdated event: - ResourceLoader: WikiModule::invalidateModuleCache to ResourceLoaderEventIngress. - TalkPageNotifications: TalkPageNotificationManager::setUserHasNewMessages to UserNotificationEventIngress. Bug: T378936 Change-Id: I5f2083b09d90cbd20abe2e8143a000dfc4d02aae
* | ResourceLoader: Debug mode now defaults to debug mode v2Hannah Okwelum2025-02-061-3/+2
|/ | | | | Bug: T367441 Change-Id: I926a490e81875b48753c71265e03f4d9f94e7a10
* Merge "Use $string === '' instead of strlen( $string ) === 0"jenkins-bot2025-02-051-1/+1
|\
| * Use $string === '' instead of strlen( $string ) === 0Fomafix2025-01-301-1/+1
| | | | | | | | | | | | | | | | | | Add $string === false or $string === null where $string can have other types than a string. Also document null as possible return value in FileRepo. Change-Id: Iaa29ba01c3fd6bea506debdc6f929edfe881c808
* | build: Updating mediawiki/mediawiki-codesniffer to 46.0.0libraryupgrader2025-01-311-1/+1
| | | | | | | | Change-Id: I0f8a8cac36015bba52aea3ee2affd92f83d3574a
* | Merge "ResourceLoader: Replace ::encodeJsonForScript() with json_encode"jenkins-bot2025-01-301-1/+1
|\ \ | |/ |/|
| * ResourceLoader: Replace ::encodeJsonForScript() with json_encodeHannah Okwelum2025-01-301-1/+1
| | | | | | | | | | Bug: T36738 Change-Id: I4c95950c244961f4100413eed0ebb4fa38438301
* | resourceloader: Fix hash computation for virtual files with versionFilePathRoan Kattouw2025-01-291-3/+2
|/ | | | | | | | | | A regression in 69ad795df7719a7854672140afa3a07269639978 caused virtual files with a versionFilePath to be silently dropped from the version hash computation. This caused changes in these files to not be reflected in the version hash of the file. Bug: T385055 Change-Id: Ibde41f07bb6fa7610660cb5b7a3f7aafbe9d6bd3
* resourceloader: Use hashtable to check recursion in StartUpModuleUmherirrender2025-01-251-5/+6
| | | | | | | | | | Change in_array with list to isset() with hashtable, a hashtable has better performance to check the existence of entries. Make the array pass-by-ref to avoid that a copy of the array is created on each recursion call (Technically the copy is done on the first write to that array, but most recursion calls writes to the array) Change-Id: I6ef3d4c10a6ce8d70c746d6e4e67c84be170f88b
* Merge "resourceloader: Minor documentation corrections"jenkins-bot2025-01-221-1/+5
|\
| * resourceloader: Minor documentation correctionsBartosz Dziewoński2025-01-201-1/+5
| | | | | | | | | | | | | | | | Issues spotted while working on I03a9a6945ab27e9888ea21b03985ed713f0a9b50. Some code style improvements too. Change-Id: I409d0a1805aa7430cc86e53633f4f85ef8a76dcf
* | Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-179-46/+0
|/ | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-163-10/+0
| | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* maintenance: Back out DI in purgeMessageBlobStore.php maint scriptAmmarpad2025-01-121-12/+2
| | | | | | | | | | Use MessageBlobStore::clearGlobalCacheEntry static method directly Delete the script test. Cache clearing is already tested in MessageBlobStoreTest and seems sufficient here Bug: T379722 Change-Id: I7155089081f5bd518b06b0890a3d5d5b7d0d0314
* ResourceLoader: Deprecate ResourceLoader::makeConfigSetScriptHannah Okwelum2024-12-241-0/+4
| | | | | Bug: T36738 Change-Id: Ide9e51d46377c95904694c4791f85831f4c46d36
* RevisionRecord: add convenience methods for main slotdaniel2024-11-281-4/+3
| | | | | | | | | | | | | When accessing slot content and meta-data, most code wants to only access the main slot. Add convenience methods for making this less awkward. Originally, the intent was for all code to support arbitrary slots. This hasn't happened, instead we spread SlotREcord::MAIN all over the code base. It seems better to adjust the interface of RevisionRecord to reality. Change-Id: I8603f95c8e39d6fc3522a47f74657798e7f7c061
* ResourceLoader: Avoid CACHE_DB fallback for minify and less.php cacheTimo Tijhof2024-11-272-3/+3
| | | | | | | | | | | | | * For minify cache, we removed the CACHE_DB fallback in I086e275148 (7c2c016e46), but I forgot to do the same for the (now, mostly unused) static method. * For less.php cache, likewise don't bother storing these in the database if the install has no php-apcu, although keep a fallback to an in-process cache for now. Bug: T186673 Change-Id: Ic93e37c974c07aa74acdaaf5f990f5270f255546
* ResourceLoader: Run addOneModuleResponse() once instead of twiceBartosz Dziewoński2024-11-212-5/+73
| | | | | | | | | | | | | | | | | | | | | In the usual request, we need to generate two outputs for the same module response: first minified, and second unminified (for source maps). We did that by calling addOneModuleResponse() twice with two different minifiers. This ran the code generating the response twice. Most of it was already cached internally, but some parts weren't, causing log warnings like this (which led me to find this problem): SQLBagOStuff.WARNING: Duplicate get(): "global:resourceloader-filter:minify-js:9:<md5>" fetched 2 times Instead, call addOneModuleResponse() once, remember what it does, and replay those calls on the two minifiers. We have to remember and replay the calls, instead of doing them immediately, because sometimes the result of the first minifier is needed to decide whether we even construct the second minifier. Change-Id: I2a4516ebb95973f5bb1a863f4b6eecf04edd2a92
* Add type hints to detect bool/null message paramsBartosz Dziewoński2024-11-141-1/+4
| | | | | | | | | | | | Add more precise type hints to every method I could find that takes message params as arguments, so that Phan will warn if bool or null is passed, which is deprecated (T378876). Errors found in this repository thanks to these checks are fixed in I286a4a51e879bdf61f65c87dc078621c51045bee. Bug: T378876 Change-Id: I3e0df790ff9db2fa630f82408a7254a359fe61ca
* Merge "ResourceLoader: Restore `@nomin` for JavaScript files"jenkins-bot2024-10-281-1/+12
|\
| * ResourceLoader: Restore `@nomin` for JavaScript filesTimo Tijhof2024-10-281-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follows-up I086e275148 (7c2c016e46). Test Plan: Add the following to LocalSettings, then load Main Page with and without this patch. ``` $myScript = " /*@nomin*/ function example() { // Comment: Am I minified? if (example.toString().match(/\/\/ Comment/)) { console.log( 'Example was %coriginal', 'background: lightGreen', ); } else { console.log( 'Example was %cminified', 'background: pink', ); } } example(); "; $wgResourceModules['example'] = [ 'scripts' => [ [ 'name' => 'example.js', 'content' => $myScript ] ], ]; $wgHooks['BeforePageDisplay'][] = function ( $out ) { $out->addModules('example'); }; ``` Bug: T373990 Change-Id: Ic4b8b3053a9fe458356765a24b67688602212ad8
* | ResourceLoader: Simplify injection of DependencyStore to Module objectHannah Okwelum2024-10-263-184/+104
| | | | | | | | | | Bug: T371152 Change-Id: I789c125a37f0d3549922060894f863bab146d948
* | ResourceLoader: Simplify DependencyStoreHannah Okwelum2024-10-243-112/+73
| | | | | | | | | | Bug: T343492 Change-Id: Ia581ac107cb139afb0740a36f4f22f047d0de1ad
* | ResourceLoader: Remove SqlModuleDependencyStoreHannah Okwelum2024-10-241-207/+0
| | | | | | | | | | Bug: T343492 Change-Id: I17b53030969956bef861ce7dd98e08839cdba98a
* | ResourceLoader: Remove ResourceLoaderUseObjectCacheForDepsHannah Okwelum2024-10-241-2/+1
| | | | | | | | | | Bug: T343492 Change-Id: I89a32eea3280f5c5ca809efa3fa661b2bf998e08
* | Use explicit nullable type on parameter argumentsUmherirrender2024-10-168-15/+15
|/ | | | | | | | | | | 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
* Merge "WebRequest: Add PHP return type hint for getRawVal"jenkins-bot2024-10-101-5/+5
|\
| * WebRequest: Add PHP return type hint for getRawValFomafix2024-10-101-5/+5
| | | | | | | | | | | | Improve the code to avoid phan errors detected by this type hint. Change-Id: I134d962e1cf95f6b135f3e8959669dc41ccec877
* | Merge "WebRequest: Deprecate parameter $default in getRawVal"jenkins-bot2024-10-102-5/+3
|\|
| * WebRequest: Deprecate parameter $default in getRawValFomafix2024-10-032-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use $request->getRawVal( 'key' ) ?? 'default' instead of $request->getRawVal( 'key', 'default' ) The ?? is more flexible, avoids a wrong type detection by phan and avoids the evaluation of the default value if not needed. Bug: T376245 Depends-On: I3ed6b85c0d117ed7cb3a8b79f73a3eb42977891e Change-Id: I8b02f9297b76d04e21f8cb9194f3b85631956eca
* | Remove meaningless @var documentation from constantsthiemowmde2024-10-093-7/+1
|/ | | | | | | | | A constant is not a variable. The type is hard-coded via the value and can never change. While the extra @var probably doesn't hurt much, it's redundant and error-prone and can't provide any additional information. Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
* Merge "Add namespace to remaining parts of Wikimedia\ObjectCache"jenkins-bot2024-10-031-1/+1
|\
| * Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-271-1/+1
| | | | | | | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* | Merge "resourceloader: Add/change ResourceLoaderModifyEmbeddedSourceUrls hook"jenkins-bot2024-10-025-42/+48
|\ \
| * | resourceloader: Add/change ResourceLoaderModifyEmbeddedSourceUrls hookBartosz Dziewoński2024-09-275-42/+48
| |/ | | | | | | | | | | | | | | | | | | We've discovered some new requirements. Follow-up to 31f614f7322c1e050eba0a91aa339e3cc495b8a1. The hook was not in a release yet, so we can rename it. Bug: T371530 Change-Id: I82d8ae69c27a38c45eab5d19c063f0b9515b8ec8
* | Merge "Add @phan-mandatory-param for function name arguments"jenkins-bot2024-09-301-1/+1
|\ \ | |/ |/|
| * Add @phan-mandatory-param for function name argumentsUmherirrender2024-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | Providing the function name is often optional from the php code, but it is needed for better logging, so make it mandatory and let phan report issues about this. Bug: T374546 Depends-On: Iaed5489a85a5a6e685829e151436afc94310fbd0 Depends-On: Ie2a1e5052e5b61bbb5b89905de942f47d3f1413d Change-Id: I5227f2fa65850ac8c6f620900f22d1f4e7bfd470
* | Merge "resourceloader: Serve images with "Access-Control-Allow-Origin: *""jenkins-bot2024-09-261-0/+1
|\ \
| * | resourceloader: Serve images with "Access-Control-Allow-Origin: *"Bartosz Dziewoński2024-09-241-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | This allows them to be used in 'mask-image' rules in CSS (introduced in e977eea1533c) even if the image is loaded from a different domain. It also allows JavaScript code to e.g. draw the images on <canvas> and read back the pixel data. This should be fine, the images don't contain any private data. Bug: T371530 Change-Id: Iec3bdd91ca094e2da5030ac5f16ae96be49bf78e
* | Merge "ResourceLoader: Fix `content-links` compat"jenkins-bot2024-09-241-2/+2
|\ \ | |/ |/|
| * ResourceLoader: Fix `content-links` compatTimo Tijhof2024-09-171-2/+2
| | | | | | | | | | | | | | | | | | This never worked because it looked for `element` instead of `elements`. The test repeated the same mistake. Bug: T278576 Bug: T255717 Change-Id: I9bfceb6b8bd761244af6eda0e2ae08e98238aa76
* | Support legacy message boxes in user generated contentJon Robson2024-09-181-0/+9
|/ | | | | | | | | * Deprecate SkinModule feature 'interface-message-box" * Include styles using dedicated module where needed for content. Bug: T375127 Depends-On: I58d9e41f0c98adbd816240b161b5145a667436cd Change-Id: I59ab5f222dc9d01de04077d3e2cef5b42a8ffe08
* ResourceLoader: Fix SkinModule aliases to not override existing keysTimo Tijhof2024-09-171-1/+5
| | | | | | | | | | | | | While not documented or tested, aliases previously not only adding but also replaced values. Instead, emit a warning to inform skin developers of this conflict. Note that the `content-links => elements` alias already behaves this way (only if not already set), which the other aliases would now be consistent with. Change-Id: I66ae66b37bba14b2f65710f3d32f17d4e9a5a7a3
* ResourceLoader: Minor doc blocks and coding style cleanupTimo Tijhof2024-09-171-7/+12
| | | | | | | | | | | | | | | | | | | * Function alls are either complete on one line or one arg per line. Avoid confusing calls where the args are on their own line as this creates visual ambiguity over how many args are passed, and what each piece belongs to. For example, is `true` or `false` passed as 2nd arg to applyFeaturesCompatibility? * Replace comment about list-form behaviour with something that provides intention and insight instead of merely repeating what can already be seen from the code. * Fix malformed `@param` docs that used variable as part of sentence. * Use named data providers to ease PHPUnit debugging, and to make code coverage reports on doc.wikimedia.org more useful. Change-Id: I2efd6cc7ac59c80684c9411025c4226473a36d43
* ResourceLoader: Reduce deprecation clutter in SkinModuleTimo Tijhof2024-09-161-46/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Move docs for deprecated aliases from top-level mentions into footnotes under primary docs. Still easy to search for, but no longer advertised as important for skin devs to know about or scan past when reading. * Fix bug in 'legacy' logic where the key was not unset, thus mandating a needless entry in FEATURES constant. With the bug fixed, this internal entry is no longer needed. * Fix bug in 'interface' logic where the key was not unset when the value is false. This would break the "skins.vector.styles" module otherwise, and had a similar workaround in place that is now no longer needed. * Remove other unneeded entries in FEATURES for keys that were already being unset by applyFeaturesCompatibility(). * Remove deprecation warnings in favour of letting ResourceModules give a stable interface from ResourceLoader to skin.json. * Add missing test to confirm no-op behaviour. Bug: T374262 Change-Id: I9f4b1d48127d0afe67bada44d8dc4472507f9506
* ResourceLoader: Revive i18n-all-lists-margins feature of SkinModuleEbrahim Byagowi2024-09-161-3/+6
| | | | | | | | | * Corrects the previous deprecation to restore backwards compatible functionality to i18n-all-lists-margins for skin developers without any change on their part. * Updates deprecation message to give clearer next steps. Bug: T369475 Change-Id: I98696b4a52838a4836320a491430e669e3a5d1e1