Commit graph

378 commits

Author SHA1 Message Date
James D. Forrester
65c90be7ea Drop a few phan PhanImpossibleTypeComparison suppressions now we've dropped PHP 7.4
Change-Id: I3426e8d65c38f4e4c6e6d2ab8ff380b9d12a47fd
2025-06-18 10:54:01 +01:00
James D. Forrester
ac8a5b0b59 Drop PHP 7.4/8.0 support from master (forward-port from MW 1.42)
This patch was applied to release branches for MW 1.42 in April 2024, and
since ported to MW 1.43 and then MW 1.44 as well. This one-of-a-kind hot
patch will finally discontinue once this lands in the master branch as
part of MW 1.45+ releases.

A small handful of phan fixes make this pass so it can land; the rest
(including fixes rather than suppressions of events here) will happen in
later patches.

Bug: T328921
Bug: T359868
Change-Id: Ica2c11a6243795437ec652923e42ef3bd74a5fd8
2025-06-18 10:53:22 +01:00
Roan Kattouw
e402fc7d91 resourceloader: Fix hash computation for virtual files with versionFilePath
A regression in 69ad795df7 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
(cherry picked from commit bce48b6358cd2176d9fbc9a7c22f008bfbcf73d2)
2025-01-29 21:26:20 +00:00
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
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
2024-10-16 20:58:33 +02:00
jenkins-bot
3bf2b6a23f Merge "WebRequest: Add PHP return type hint for getRawVal" 2024-10-10 15:05:43 +00:00
jenkins-bot
dbe8c4b9aa Merge "WebRequest: Deprecate parameter $default in getRawVal" 2024-10-10 15:05:35 +00:00
Fomafix
7be5a303d1 WebRequest: Add PHP return type hint for getRawVal
Improve the code to avoid phan errors detected by this type hint.

Change-Id: I134d962e1cf95f6b135f3e8959669dc41ccec877
2024-10-10 14:01:26 +00:00
thiemowmde
b1c9ec74fa Remove meaningless @var documentation from constants
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
2024-10-09 09:33:12 +02:00
Fomafix
9208216d6b WebRequest: Deprecate parameter $default in getRawVal
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
2024-10-03 15:49:33 +00:00
jenkins-bot
db7ee3db99 Merge "Add namespace to remaining parts of Wikimedia\ObjectCache" 2024-10-03 14:02:47 +00:00
jenkins-bot
a80da8eacf Merge "resourceloader: Add/change ResourceLoaderModifyEmbeddedSourceUrls hook" 2024-10-02 16:12:30 +00:00
jenkins-bot
0921ef1b49 Merge "Add @phan-mandatory-param for function name arguments" 2024-09-30 16:51:33 +00:00
James D. Forrester
53b67ae0a6 Add namespace to remaining parts of Wikimedia\ObjectCache
Bug: T353458
Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
2024-09-27 16:19:10 -04:00
Bartosz Dziewoński
531ba3aad0 resourceloader: Add/change ResourceLoaderModifyEmbeddedSourceUrls hook
We've discovered some new requirements.

Follow-up to 31f614f732.
The hook was not in a release yet, so we can rename it.

Bug: T371530
Change-Id: I82d8ae69c27a38c45eab5d19c063f0b9515b8ec8
2024-09-27 20:28:30 +02:00
jenkins-bot
c1c5eff194 Merge "resourceloader: Serve images with "Access-Control-Allow-Origin: *"" 2024-09-26 01:09:40 +00:00
jenkins-bot
6aff64e157 Merge "ResourceLoader: Fix content-links compat" 2024-09-24 22:17:54 +00:00
Bartosz Dziewoński
c42e103152 resourceloader: Serve images with "Access-Control-Allow-Origin: *"
This allows them to be used in 'mask-image' rules in CSS (introduced
in e977eea153) 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
2024-09-24 16:00:37 +02:00
Umherirrender
f910edce6d Add @phan-mandatory-param for function name arguments
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
2024-09-20 16:23:17 +00:00
Jon Robson
a09791e942 Support legacy message boxes in user generated content
* Deprecate SkinModule feature 'interface-message-box"
* Include styles using dedicated module where needed for content.

Bug: T375127
Depends-On: I58d9e41f0c98adbd816240b161b5145a667436cd
Change-Id: I59ab5f222dc9d01de04077d3e2cef5b42a8ffe08
2024-09-18 21:02:59 +00:00
Timo Tijhof
e03380c714 ResourceLoader: Fix content-links compat
This never worked because it looked for `element` instead of `elements`.
The test repeated the same mistake.

Bug: T278576
Bug: T255717
Change-Id: I9bfceb6b8bd761244af6eda0e2ae08e98238aa76
2024-09-17 03:22:14 +00:00
Timo Tijhof
123da635a1 ResourceLoader: Fix SkinModule aliases to not override existing keys
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
2024-09-17 03:22:04 +00:00
Timo Tijhof
3d924e4ed1 ResourceLoader: Minor doc blocks and coding style cleanup
* 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
2024-09-17 03:20:15 +00:00
Timo Tijhof
3ee96d47b6 ResourceLoader: Reduce deprecation clutter in SkinModule
* 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
2024-09-16 20:17:34 -07:00
Ebrahim Byagowi
80a2a97e79 ResourceLoader: Revive i18n-all-lists-margins feature of SkinModule
* 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
2024-09-16 23:18:51 +00:00
Umherirrender
441017cb54 ResourceLoader: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I90ecf85cb6f639af4be1947ccfbfb16d5b84cab3
2024-09-07 21:25:51 +02:00
jenkins-bot
06b1522184 Merge "OOUI: Provide the 'editing-functions' icon pack module" 2024-09-06 16:21:43 +00:00
jenkins-bot
3909efa52e Merge "Fix typo in browser vendor prefix" 2024-09-06 12:45:58 +00:00
Jon Robson
6bd260d7b2 Fix typo in browser vendor prefix
This is preventing icons from displaying in older Chrome browsers

Change-Id: I017da77ccda5763dc0312859127c453ba69e4029
2024-09-05 22:19:48 -07:00
Ebrahim Byagowi
68aee7d37b Hard deprecating wfUrlProtocols
wfUrlProtocols is deprecated since 1.39, let's remove the uses and turn it
into a hard deprecation.

Change-Id: Ic5f827f6e4563bab1b28f090da8f8613b124fcc5
2024-09-05 19:16:19 +03:30
Umherirrender
7ef1eb39e5 ResourceLoader: Avoid assignment in condition in ForeignResoureManager
Change-Id: I3414f7e17f4bcb801857bc986bae8eb97aa2bfb8
2024-08-31 22:04:01 +00:00
Roan Kattouw
c13dbc8a93 CodexModule: Fix double-flipping in RTL
CodexModule::processStyle() looks at the path of the style file to
detect whether it's an already-flipped Codex file. In
I11c6a81a1ba34fe10f4b1c98bf76f0db40c1ce98 we broke this logic so that it
was comparing a full path (prefixed with MW_INSTALL_PATH) to a relative
path (not prefixed), so the detection always failed and we'd flip every
file. For Codex files, this meant we double-flipped the RTL files back
to LTR.

Follow-Up: I11c6a81a1ba34fe10f4b1c98bf76f0db40c1ce98
Bug: T373676
Change-Id: I49f14dcc503a3279362559197f12b2852276fb5e
2024-08-30 13:13:00 -07:00
James D. Forrester
9698ed95a2 OOUI: Provide the 'editing-functions' icon pack module
This will be needed by the Wikifunctions VisualEditor integration.

Change-Id: I622d9a5ef61678bb4cc9b1d9309c6ee8540f97ce
2024-08-30 12:29:18 -04:00
jenkins-bot
81ebe177ca Merge "ResourceLoader: Switch CodexModule from BaseDirectory to MW_INSTALL_PATH" 2024-08-29 02:14:01 +00:00
jenkins-bot
7735987c26 Merge "ResourceLoader: Migrate from deprecated $IP global to MW_INSTALL_PATH" 2024-08-29 02:13:53 +00:00
Roan Kattouw
5b055f7ef0 ResourceLoader: Switch CodexModule from BaseDirectory to MW_INSTALL_PATH
Change-Id: I6d6e6dd79f4d6cf8601dcc3d02195bd87b216649
2024-08-29 01:44:12 +00:00
jenkins-bot
7415ff9e0b Merge "CodexModule: Also print dev mode warning when loading full library" 2024-08-27 16:23:08 +00:00
Roan Kattouw
1c950a1e83 ResourceLoader: Migrate from deprecated $IP global to MW_INSTALL_PATH
Change-Id: I37a65a54ec4422a96b141d29bb771378532de0fc
2024-08-27 08:21:04 -07:00
thiemowmde
dca4931b42 Make use of the ??= and ?? operators where it makes sense
This touches various production classes and maintenance scripts.
The code should do the exact same as before. The main benefit is that
the syntax avoids any repetition.

Change-Id: I5c552125469f4d7fb5b0fe494d198951b05eb35f
2024-08-26 09:26:36 +02:00
Ebrahim Byagowi
c9a1fc3f02 Minor comment tweak in SkinModule
Just make all the parts similar.

Change-Id: Iee79eef2d86dde7f75a4a2d090d976ad0a964826
2024-08-25 17:02:06 +03:30
Roan Kattouw
5842c2c487 CodexModule: Also print dev mode warning when loading full library
We were only showing the development mode warning when Codex was used in
code splitting mode, but not when the full library was being loaded.

Bug: T314507
Change-Id: I22e9707b659b004ef1059f8b13feaf3f61b7ca28
2024-08-23 16:49:22 -07:00
Roan Kattouw
8a39d83175 Codex: Allow a local development version to be used
Developers can use this to test their local version of Codex with
MediaWiki by pointing $wgCodexDevelopmentDir to their local clone of the
Codex repo, e.g. $wgCodexDevelopmentDir = '/home/yourname/git/codex';

Setting $wgCodexDevelopmentDir affects where the following things come
from:
- Codex JS/CSS files for the full library
- Codex JS/CSS files for code-split chunks, and the manifest.json file
  that points to them
- Icons retrieved by CodexModule::getIcons()
- CSS-only icons imported in Less
- Design tokens imported in Less

Other changes in this patch:
- Add CodexModule::makeFilePath() to centralize the repeated path
  concatenation. This makes it easier to switch out the regular path for
  the dev mode path.
- Replace all uses of $IP (which is deprecated) and MW_INSTALL_PATH in
  CodexModule with the BaseDirectory config setting.
- Make CodexModule::getIcons() reset its static cache if the path to the
  icons file changes. Without this, it's impossible to make the unit
  tests pass.
- Move the i18n messages code from the CodexModule constructor to
  getMessages(). It can't be in the constructor because makeFilePath()
  doesn't work there (it fails because the Config object hasn't been set
  up yet).
- Add a 'mediawiki.skin.codex' import path so that we can stop
  hard-coding the path to the Codex mixins file. Without this, we can't
  make the Codex mixins come from the right place in development mode.
- Consider $wgCodexDevelopmentDir in setting the cache key for compiled
  Less code, since changing this setting can change the output of Less
  compilation (by changing design tokens, icons or mixins).
- Add unit tests for (the non-dev mode behavior of)
  CodexModule::getIcons() and the i18n message key handling.

Bug: T314507
Change-Id: I11c6a81a1ba34fe10f4b1c98bf76f0db40c1ce98
2024-08-22 17:20:24 -07:00
Eric Gardner
095a4ec6f4 CodexModule: use list of i18n message keys from Codex package
Previously, ResourceLoader's CodexModule class was using a hard-coded
list of message keys to add to the payload any time Codex components
get used. But now we can get the list of messages directly from
Codex. This change replaces the hardcoded list of strings with
a call to file_get_contents().

The list of messages is defined in a file called "messageKeys.json"
in the Codex package. In the next release of Codex, this file will
be pulled in via foreign-resources.yml; for now it has been added
manually to the Codex files in resources/lib.

Bug: T371330
Change-Id: Ib7ca66d67153dfba72d8d49b0181d49b007eedce
2024-08-12 15:30:11 -07:00
Ebrahim Byagowi
d78eaa228b RL: Consider RTL styles are also generated
ResourceLoader currently declares styles are generated only if
Less is involved but RTL CSS styles are also generated in the
same way so let's treat them the same.

This makes RL's debug mode matching better with non-debug mode
so if a user uses ?debug=1 in an RTL wiki, they get CSS Janus
transformed styles just as if Less was involved.

I was seeing the issue for years but had to get to the bottom
of it in I6c9544d7eee3b5885f4fd30265e906fe22a8c223 as this
bit was part of the confusion I had to debug the issue there.

Change-Id: Ib10bec85da969881be590e3d95d5f9474f2eb6e9
2024-08-12 20:36:01 +03:30
jenkins-bot
22163e47a7 Merge "Add MediaWiki\Registration namespace to registration classes" 2024-08-10 11:33:27 +00:00
Ebrahim Byagowi
697e19e461 Add MediaWiki\Registration namespace to registration classes
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
2024-08-10 10:08:22 +00:00
James D. Forrester
f7ce0a0976 Move remaining four classes in includes/content into Content namespace
Bug: T353458
Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
2024-08-10 10:40:53 +02:00
jenkins-bot
bbcd8a2ddc Merge "i18n: Add new messages needed by Codex 1.11.0" 2024-08-08 16:23:08 +00:00
Gergő Tisza
a6b07302ea ForeignResourceManager: Write CDX file to disk
* Make 'manageForeignResources.php make-cdx' write the CycloneDX
  file to resources/lib/foreign-resources.cdx.json.
* Commit resources/lib/foreign-resources.cdx.json
* Add a structure test to ensure it is up to date.

Bug: T363589
Change-Id: I1e9d53590d4e7f0577d21cd51d777daf62d1f589
2024-08-08 14:51:01 +02:00
jenkins-bot
cfc9cb4a9f Merge "ForeignResourceManager: Ignore network errors during tests" 2024-08-08 12:12:17 +00:00
Gergő Tisza
3b276808ed ForeignResourceManager: Ignore network errors during tests
Bug: T362425
Change-Id: Ie7e9e9bbd99c32d5b3153f1fd4a4042b437ce189
2024-08-08 12:51:37 +02:00