Skip to content

fixForeignRecord crash on deleted Records #5

@sunkan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions