xwp / stream

🗄️ Stream plugin for WordPress
https://wordpress.org/plugins/stream/
GNU General Public License v2.0
406 stars 116 forks source link

Invalid access of `$user->user_login` in email alert if stream fired without user #1492

Closed i-am-chitti closed 1 month ago

i-am-chitti commented 1 month ago

Bug Report

I've a cron job. On it's completion, a stream log is fired via a custom connector. Since, this is a cron job, there is no user provided - https://github.com/xwp/stream/blob/develop/classes/class-connector.php#L158.

Now, I've attached an email alert. When, stream is fired and email is sent, a PHP warning comes up -

PHP Warning:  Attempt to read property "user_login" on bool in /var/www/html/wp-content/plugins/stream/alerts/class-alert-type-email.php on line 87

For reference - https://github.com/xwp/stream/blob/develop/alerts/class-alert-type-email.php#L87

Expected Behavior

No warning. Should have a check if user actually exists.

Actual Behavior

A warning appears

Steps to Reproduce the Problem

  1. Create a custom connector
  2. Add an email alert via Stream dashboard
  3. Add a cron job and do action of the connector
  4. Run cron job via CLI - wp cron event run
  5. Look into the debug log. Above warning should be there

Screenshots

Drag and drop screenshots in this area that help illustrate the problem.

System Information