Skip to content

SoftDeletes should call syncOriginal() after UPDATE query execution #31527

@mpyw

Description

@mpyw
  • Laravel Version: 6.16.0
  • PHP Version: 7.4

Description:

Currently models get dirty (isDirty() == true) after both force-deletion and soft-deletion.

Force-deletion

Correct behavior. After deletion, the model doesn't exist anymore: $exists = false. We cannot sync the latest attributes from database.

Soft-deletion

Wrong behavior. After deletion, the model still exists: $exists = true. We should be able to retrieve the latest attributes or immediately restore the data. Currently, immediate restore() call just after delete() has a broken behavior. SoftDeletes should call syncOriginal() after UPDATE query execution.

Steps To Reproduce:

$softDeletable->delete();
$softDeletable->restore(); // It does't execute any queries
$softDeletable->delete();
$softDeletable->refresh();
$softDeletable->restore(); // It works

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions