stream
stream copied to clipboard
Warning: Trying to access array offset on value of type bool in /code/wp-content/plugins/stream/alerts/class-alert-type-slack.php on line 148
Bug Report
I am getting this warning message
Warning: Trying to access array offset on value of type bool in /code/wp-content/plugins/stream/alerts/class-alert-type-slack.php on line 148
And it's because we don't have a default fallback value for the array here. https://github.com/xwp/stream/blob/305583d70e8a7667d1f99df85196024a7334ed50/alerts/class-alert-type-slack.php#L148
Changing it to
'footer_icon' => get_site_icon_url( 16, $logo[0] ?? '', $recordarr['blog_id'] ),
will work.
System Information
- Stream plugin version: 3.9.1
- WordPress version: 6
- PHP version: 8
- Browser: Chrome
- Computer operating system: Mac/Linux
Looking at the code I think there's other places where it is assumed as well data returned will always exist, for example here:
https://github.com/xwp/stream/blob/develop/alerts/class-alert-type-slack.php#L142
If an avatar URL is not found it will return false.
I think if the API doesn't complain if we send an empty string for the things we can't find, the solution @benerd proposed would work.