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

[5.6] Fix: revert model syncing after soft-delete #25392

Merged
merged 1 commit into from
Aug 31, 2018
Merged

[5.6] Fix: revert model syncing after soft-delete #25392

merged 1 commit into from
Aug 31, 2018

Conversation

edbentinck
Copy link
Contributor

This reverts the changes made in PR #24400

Why?
By immediately syncing the original model array, you could no longer retrieve changed values from the 'deleted' model event. This differs from the behavior of other model events such as 'created' and 'updated'.

Since you can manually call syncOriginal anyway, it seems it would be more desirable to leave the behavior of deleted in line with the other model events than to break this behavior for everyone without offering an opt-out:

$userModel->delete();
$userModel->syncOriginal();
$userModel->restore();

Tests
I have left in the tests from the previous PR and just added the manual syncing to show that those cases are still supported. By all means I can remove them.

If required I can also add some tests to ensure that changes on the model can be accessed after deleting.

Let me know.

@taylorotwell taylorotwell merged commit 90a844d into laravel:5.6 Aug 31, 2018
@edbentinck edbentinck deleted the hotfix/softdelete branch August 31, 2018 19:18
TBlindaruk added a commit to TBlindaruk/laravel-framework that referenced this pull request Sep 1, 2018
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

Successfully merging this pull request may close these issues.

None yet

2 participants