Commit graph

15 commits

Author SHA1 Message Date
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
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
Ebrahim Byagowi
d21cc67450 Add namespace and deprecation alias to FileBackend
This patch introduces a namespace declaration for the
Wikimedia\FileBackend to FileBackend and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Id897687b1d679fd7d179e3a32e617aae10ebff33
2024-05-19 22:35:58 +03:30
James D. Forrester
21d8d9863b Drop old ResourceLoader class aliases, deprecated since 1.39
Depends-On: Iff15a2e13a3507ef1ab5cfa504ca1a1c8d2b2a60
Depends-On: Icf8331e35acf6fe51a8303ee639921b9e4f3e6bb
Depends-On: I5a5af003026db69b279ddde0b0dedbfcfe7d70fd
Change-Id: I5929a2f760c8d21c1cb2542a19220a91ac7240e4
2024-01-31 18:24:37 -05:00
Bartosz Dziewoński
ef72497f57 resourceloader: Always include 'lang' in ImageModule image URLs
This mostly reverts 01a4a58982.

Bug: T321394
Change-Id: I67e399cd9de99e43876a0f57dd969993db902a70
2023-08-21 15:13:25 +02:00
Umherirrender
1086958611 Replace array_keys in foreach to use $_ as value instead
When the value of the associated array is not used, there is no need to
use array_keys and create internal a copy of the array, just omit the
value with $_ to tell static analyzer that the var is unused.

Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
2023-07-10 02:53:52 +00:00
Daimona Eaytoy
44e8c7885b media: Replace deprecated MWException
Introduce new classes for checked exceptions.

Bug: T328220
Change-Id: Idbcdc09647a857e359e41ecec98212a8937c5c2e
2023-06-09 18:51:07 +02:00
Tim Starling
7b3e7c017a Respond to some messages from Phan on PHP 8.1
* ForkController, OrderedStreamingForkController: indeed pcntl_fork()
  can't return false.
* RL\Image: Specify type instead of using suppression, since the issue
  name changes.
* VueComponentParser: Accept complaint about nullable nodeValue.
* Disable PHP 8.0 polyfill stubs when running on PHP 8.0+ to avoid
  duplicate interface errors.
* Add Socket stub and use it in LegacyHandler instead of multiple
  existing suppressions.
* MemcachedPeclBagOStuff: accept complaint recommending !$result over
  $result === false when the type is boolean.
* MemcachedPeclBagOStuff: fix probable bug, ignoring errors from
  Memcached::getMulti(). Phan noticed that $res=false was unreachable,
  but it should probably be reachable.
* DatabaseMysqli: accept complaint that $this->conn->errno is already
  known to be an int. It was probably a hack for some previous version
  of Phan.
* BcryptPassword, MWOldPassword, MWSaltedPassword: accept complaint that
  the !is_string() checks are unnecessary, after code review of PHP.
* Pbkdf2PasswordUsingHashExtension: note that contrary to Phan's
  suggestion, this check is necessary.
* DefaultPreferencesFactory: remove an existing hack for
  array_diff_key(), no longer necessary on 7.4 and causes an error on
  8.1. Use coalesce instead of cast for the remaining
  array_intersect_key() hack since it better shows that we are casting
  away null.
* FullSearchResultWidget: fix likely bug involving strict comparison
  between a float and an int.
* SpecialWatchlist: accept complaint that $selectedHours is
  unconditionally a float, being the return value of round(), and thus
  the cast is unnecessary.
* Add stub for AllowDynamicProperties, resolving an error in User.php.
* Xml: accept complaint that $encMonth is already known to be an int.

Six errors remain. These need suppressions or otherwise conflict with
PHP 7.4 support.

Bug: T322278
Change-Id: Ie375bbc8ccf22330b9a169e8da98f2bbe26ec8b9
2022-11-03 16:25:43 +11:00
Timo Tijhof
9a0cb0940b ResourceLoader: Switch Image.php to injected log channel
Avoid having to look at and query multiple channels for the same
core component. Use different log levels and messages instead.

E.g. avoid Foo and FooError or FooBar, use only "Foo".

This also switched to the injected Logger object at the same time.
This also avoids global wfDebugLog() at the same time.

Bug: T32956
Change-Id: I3e43b10d26858c5b3851476c8bbd27282316dd32
2022-07-08 03:57:16 +00:00
DannyS712
30483a3b29 ResourceLoader: Simplify Image::rasterize() and reduce indentation
Use guard clause to avoid needing to indent large blocks
of code, simplify return value checking.

Change-Id: I66d91ea7c1cf9586cd4d6a7f5092405e4d07f7c7
2022-06-28 04:50:41 +00:00
Timo Tijhof
af3481b3ba ResourceLoader: Let Image throw RuntimeException instead of MWException
Bug: T32956
Change-Id: Ib2b77c93d874d30847797a7b2a4ee324e0863042
2022-06-22 00:26:49 +01: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
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/ResourceLoaderImage.php (Browse further)