Skip to content

Outer transaction prevents Model.afterSaveCommit from firing #9

@jeremyharris

Description

@jeremyharris

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions