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
Add lead to the log only after persisted to avoid cascade persist error #5804
Conversation
@@ -1920,6 +1919,10 @@ public function import($fields, $data, $owner = null, $list = null, $tags = null | |||
if ($company !== null) { | |||
$this->companyModel->addLeadToCompany($company, $lead); | |||
} | |||
|
|||
if ($eventLog) { | |||
$lead->addEventLog($eventLog); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this change will be saved to database? No flush
is called here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Because of https://github.com/mautic/mautic/pull/5804/files#diff-9784b7fe0e4e02b9768b1efa4c50fe25R393 and https://github.com/mautic/mautic/pull/5804/files#diff-9784b7fe0e4e02b9768b1efa4c50fe25R396.
I also tested it and it stores all rows to the log table. Before the last commit it stored only errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me
tests pass |
Description:
I'm trying to fix this error:
The problem is that I don't quite know how to replicate it. But from the code I think it happens like this:
So my solution is to associate Lead with LeadEventLog only if the Lead save ends with a success.
Steps to reproduce the bug:
Steps to test this PR:
$ bin/phpunit -d memory_limit=2048M --bootstrap vendor/autoload.php --configuration app/phpunit.xml.dist --filter LeadModelTest