Skip to content

fixForeignRecord crash on deleted Records #5

Description

@sunkan

This code will crash with TokenRow::$account_id is immutable after Row is deleted

$account = $mapper->fetchRecord(1, ['tokens']);

$token = $account->tokens->getOneBy(['type' => 'test']);

if (isValid($token)) {
    $atlas->delete($token);
}

$account->modified = date('c');
$atlas->update($account);

Is this the intended behavior?

Ps.
I found out will writing this issue that I can use detachOneBy instead of getOneBy but that's not always what you want.

Ps 2.
Also found the detachDeleted method.

We should probably update the documentation with a not about this behavior

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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