Wrong component status in status update email
Before submitting your issue, please make sure that you've checked the checkboxes below.
- [x ] I am running the 2.4 version of Cachet.
- [x ] I am running at least PHP 5.5.9. You can check this by running
php -v. - [x ] I have ran
rm -rf bootstrap/cache/*.
Expected behaviour
- When a component gets updated to major outage, subscribers receive an email with content "The component XXX has seen a status change. The component is now at Major Outage."
Actual behaviour
- When a component gets updated to major outage, subscribers receive an email with content "The component XXX has seen a status change. The component is now at Operational." -> Operational is the old status.
Steps to reproduce
- Create a component, add a subscriber, update the status, check the received email.
I'd like to help with that one as it's pretty significant issue for me, but somehow I can't pinpoint what is going wrong there. The changes introduced by @jbrooksuk regarding the old_status and new_status seem to be additions to the previous code, and the component still updated with the new $command status. Any ideas so that I could try to move forward with this?
Seems like the perfect excuse to get #2060 put into action.
@ConnorVG Thanks for the work! Regarding the bug, have you had the chance to take a look?
@fdhex it's something that will surely be looked into and easier to avoid once we have proper mail testing in place. After my initial testing I wasn't actually able to replicate this bug myself, though.
Which may correlate with me not finding what's the problem in the code - I'll check my installation, maybe some local issues.
Could this be an instance of an email sending job is created - before - the update to the database is done?
@fdhex that could very much be it, actually

I don't know much Laravel but I've tried to use this Debugbar I found, and here are the requests when updating the component from 1 to 2. I'm not sure if they are ordered in the order they are done, but if yes that's indeed the issue. Not sure how to fix it yet though...
We should instead be using the variables on the event (https://github.com/CachetHQ/Cachet/blob/2.4/app/Bus/Events/Component/ComponentStatusWasUpdatedEvent.php#L42) rather than the property on the component (https://github.com/CachetHQ/Cachet/blob/2.4/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php#L100)
Note: I haven't tested this, it may not be the issue.
But it's two different Events no? Can you send a variable from one to the other?
@ConnorVG I'm going to assign this one to you, since you're already kinda on it.
Just wanted to let the group know that i was able to replicate the issue running php 5.6.24. I have tried both database and sync queues, haven't had a chance to try the other.
Above fix is working for me!
Closed by https://github.com/CachetHQ/Cachet/commit/b40066b20e0d5b3262d81c69d4edeeb60f7d8a00