Repository navigation
fix: honor explicit state/watch/presence options in queryChannels - #181
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
The defaults were applied with in_array(), which searches option values, not keys. An explicit state=false was overwritten with true, and watch/presence=true were reset to false.
pcbeingused333
requested review from
JimmyPettersson85 and
yaziine
as code owners
November 10, 2026 13:19
Author
|
Friendly ping: could someone take a look at this when there's time? I'm happy to adjust anything. Thanks! |
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.
Fixes
Client::queryChannelsignoring an explicitstate => falseand dropping thestate/watch/presencedefaults depending on the other options passed.Cause
The defaults were filled in with
in_array("state", $options), which searches the option values, not the keys, with PHP's loose comparison (a non-empty string such as"watch"equalstrue). As a result:["state" => false]did not count as "state set", so it was overwritten withtrueand the full channel state was returned, although docs/channels/query_channels.md recommendsstate=falseto reduce the response.["watch" => true]or["presence" => true]made thestatecheck succeed by accident, sostatewas never sent.statewas set totrueand that value then satisfied thewatch/presencechecks, so those defaults were never sent either.Fix
Use
array_key_exists()for the three checks, so only missing options get defaults.Test
New
tests/unit/QueryChannelsOptionsTest.phpinjects a mock Guzzle handler (no API or credentials) and asserts the request body: defaults when no options,state=falserespected,watch/presence=truerespected. All 3 tests fail without the change (state=falseoverwritten, missingwatch/statekeys) and pass with it; the full unit suite passes (51 tests).Disclosure: this change was prepared with the assistance of an AI coding tool (Claude Code); the tests above were run.