Skip to content

Conversation

@Koozza
Copy link
Contributor

@Koozza Koozza commented Feb 22, 2021

If no info key is present in the $params array Pusher will not return the channels property in the request. There is a if statement in place, but it doesn't check if the property actually exists.

So by just using the package and using the trigger method will provide you with a exception.

@benw-pusher
Copy link

I'm not able to replicate this, when using the following code no error is output:

$pusher->trigger(['my-channel', 'my-channel-2'], 'my-event', $data);.

Are you using the php library directly or is this error occurring as part of the Laravel Echo framework?

@Koozza
Copy link
Contributor Author

Koozza commented Feb 22, 2021

I'm using it directly within laravel, but not as part of Laravel Echo. Example call:

                $pusher = new Pusher\Pusher( 'xxx', 'xxx', 'xxx', array( 'cluster' => 'eu', 'useTLS' => true ) );
                $pusher->trigger( [ 'channel-1', 'channel-2' ], 'my_event', 'hello world' );

The $response contains the following:

array: 2 [
  " body " => " {} "
  " status " => 200
]

So accoring to the code: $result = json_decode($response['body']);
You'll get $result = {};

And thus making

if ($result->channels) {

Give a undefined property.

(Please note that this only occurs if no "info" is given).

Copy link
Contributor

@WillSewell WillSewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for investigating and fixing this.

Co-authored-by: Will Sewell <[email protected]>
@WillSewell WillSewell merged commit d078d06 into pusher:master Feb 22, 2021
@WillSewell WillSewell mentioned this pull request Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants