memberful / memberful-wp

Better membership software for WordPress.
https://memberful.com
41 stars 15 forks source link

Check for `member` when processing order webhooks #325

Closed julianfssen closed 2 years ago

julianfssen commented 2 years ago

To-do: https://3.basecamp.com/3293071/buckets/5610905/todos/4945211415

Error message: https://sentry.io/share/issue/c1d9770e3aeb42069fa21c89ac1a2fb3/


When processing webhooks for the order event:

https://github.com/memberful/memberful-wp/blob/main/wordpress/wp-content/plugins/memberful-wp/src/endpoints/webhook.php#L16

it is possible to receive a payload that does not contain the member attribute, due to the way we define it here in our builder template.

This does not throw an error but raises a warning in the logs.

This PR fixes the warning by checking for the existence of member before assigning. I used isset here for compatibility as null safe operators do not work for PHP 7 and below.