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

Outer transaction prevents Model.afterSaveCommit from firing #9

Open
jeremyharris opened this issue Sep 9, 2021 · 0 comments
Open

Comments

@jeremyharris
Copy link

The outer transaction created by DbTest prevents the event from firing because Model.afterSaveCommit only fires if it is not currently in a transaction.

A possible solution to this would be to not use Connection::begin & friends to handle the transaction in the FixtureInjector. Those methods track the transaction state internally. Instead it might work if you start the transaction outside of those methods:

ConnectionManager::get('test')->begin();
// becomes
ConnectionManager::get('test')->getDriver()->beginTransaction();

This way the internal state of Connection isn't aware of the outer transaction. This should cause Model.afterSaveCommit to fire again.

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

1 participant