diff options
author | Timo Tijhof <krinkle@fastmail.com> | 2023-03-09 16:49:12 +0000 |
---|---|---|
committer | Aaron Schulz <aschulz@wikimedia.org> | 2023-03-10 19:00:05 +0000 |
commit | 02b4671dbfa3016dd545d07e4f013681afe06903 (patch) | |
tree | e1665dd51fd428babdd0e59c2e4a28f3b41e94a0 /includes/ResourceLoader | |
parent | d47a60b4d26ea674368eef9113ae1ad20fcad89d (diff) | |
download | mediawikicore-02b4671dbfa3016dd545d07e4f013681afe06903.tar.gz mediawikicore-02b4671dbfa3016dd545d07e4f013681afe06903.zip |
ResourceLoader: Silence new encodeJson warning for $states array
Follows-up I89832142b55ec0f for T329330. encodeJson() is almost always
called with data that a core component or extension was responsible
for processing or generating. There is one exception that I know of,
namely within ResourceLoader itself, where we report back the name of
a load.php?modules parameter value if it doesn't exist or is invalid.
In that case, silence the newly added warning from encodeJson() since
the audience for that error is not the developers working on the code,
but the user making a badly formed URL. And the warning was coming
from the exact code formulating that same error message.
Bug: T331641
Change-Id: Idcccb979c89ef837546892ab786d803d429ecda5
Diffstat (limited to 'includes/ResourceLoader')
-rw-r--r-- | includes/ResourceLoader/ResourceLoader.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/includes/ResourceLoader/ResourceLoader.php b/includes/ResourceLoader/ResourceLoader.php index 9ae1756ca9ee..ad46ddd35c86 100644 --- a/includes/ResourceLoader/ResourceLoader.php +++ b/includes/ResourceLoader/ResourceLoader.php @@ -1216,7 +1216,11 @@ MESSAGE; } } elseif ( $states ) { $this->errors[] = 'Problematic modules: ' - . $context->encodeJson( $states ); + // Don't issue a server-side warning for client errors. (T331641) + // Modules with invalid encoded names can't be registered, but can be requested + // by forming a bad URL. + // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged + . @$context->encodeJson( $states ); } return $out; |