Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #1371

Open
benerd opened this issue Oct 10, 2022 · 1 comment

Comments

@benerd
Copy link

benerd commented Oct 10, 2022

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.

'footer_icon' => get_site_icon_url( 16, $logo[0], $recordarr['blog_id'] ),

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
@oscarssanchez
Copy link
Contributor

oscarssanchez commented Oct 22, 2022

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.

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

No branches or pull requests

2 participants