Repository navigation
Conversation
Without an Accept-Language header WebClient::detectLanguage() passed null to explode(), which raises a deprecation since PHP 8.1. Both detection routines also kept parameters such as quality values, so "gzip;q=1.0" never matched in compress(), and values refused with q=0 were treated as accepted. Both headers are now parsed by one helper that strips parameters, skips empty values and values with q=0, and accepts a missing header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Without an
Accept-Languageheader,WebClient::detectLanguage()callsexplode(',', null), which triggersDeprecated: explode(): Passing null to parameter #2on PHP 8.1+ (and becomes aTypeErrorshould PHP turn these into errors).detectEncoding()casts to string, but both keep header parameters:Accept-Encoding: gzip;q=1.0yieldsgzip;q=1.0, soAbstractWebApplication::compress()never matches such clients, and values the client refuses withq=0are listed as accepted.Both routines now use a private
parseAcceptHeader()helper thatde;q=0.9→de),Behaviour change in 4.x: a missing or empty header now gives an empty list instead of
[''], andq=0entries are no longer listed.Testing Instructions
vendor/bin/phpunit --filter WebClientTest: new data sets for q-values andq=0ingetEncodingData()/getLanguageData(), an emptyAccept-Encoding, andtestDetectLanguageWithoutHeader, which turns deprecations into exceptions and fails without the change insrc/.Documentation Changes Required
docs/web-application.md("Client detection") listed the properties aslanguage/encoding; they arelanguages/encodings. The section now uses the right names and describes the parsing.🤖 Generated with Claude Code