You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an event handler which hooks into User::EVENT_BEFORE_SAVE and is setting $event->isValid to false. I am getting an integrity constraint violation in MySQL because the user doesn't exist when attempting to create the user preferences entry.
This may be intentional behavior but I need to be able to stop the full creation of the user with that event handler. It does seem a bit like if Craft::$app->getElements()->saveElement($user, false) returns false, then an exception should be thrown and the transaction rolled back.
I'm attempting to halt execution and return custom JSON in the event handler, but this does not seem possible. Let me know if I am overlooking something.
Steps to reproduce
Create an event handler with User::EVENT_BEFORE_SAVE hook.
Attempt to stop execution with $event->isValid = false;
Additional info
Craft version: 3.0.19
PHP version: 7.1.19
Database driver & version: MySQL 5.7
Plugins & versions:
The text was updated successfully, but these errors were encountered:
Description
I have an event handler which hooks into
User::EVENT_BEFORE_SAVE
and is setting$event->isValid
tofalse
. I am getting an integrity constraint violation in MySQL because the user doesn't exist when attempting to create the user preferences entry.This may be intentional behavior but I need to be able to stop the full creation of the user with that event handler. It does seem a bit like if
Craft::$app->getElements()->saveElement($user, false)
returns false, then an exception should be thrown and the transaction rolled back.I'm attempting to halt execution and return custom JSON in the event handler, but this does not seem possible. Let me know if I am overlooking something.
Steps to reproduce
User::EVENT_BEFORE_SAVE
hook.$event->isValid = false;
Additional info
The text was updated successfully, but these errors were encountered: