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.3] Touch owners on save only if model is dirty #14214

Merged
merged 1 commit into from
Jul 12, 2016

Conversation

dan-har
Copy link
Contributor

@dan-har dan-har commented Jul 4, 2016

It seems that the model save() method not behave correctly when saving model that is NOT dirty and the model set to touch its owners.

So lets say we have posts and comments

$comment = Comment::find(1);

// do something ...

// $comment->isDirty() == false

$comment->save();

/** owner post timestamp is updating **/

It results with the saved model updated_at attribute not changing but the owner model updated_at is changed.

This is a suggestion for fixing this issue. In this change the save method will return false if the model is not dirty.

@GrahamCampbell GrahamCampbell changed the title Touch owners on save only if model is dirty [5.3] Touch owners on save only if model is dirty Jul 5, 2016
@kasparsklavins
Copy link

This would be a breaking change as I rely on this behaviour when changing user associated data in the filesystem.

@dan-har
Copy link
Contributor Author

dan-har commented Jul 11, 2016

For updating timestamps, a more explicit way may be $model->touch().

The problem with this behavior is that leads to non consistent data being saved in the database whether someone aware to it or not.

@GrahamCampbell
Copy link
Member

This would be a breaking change

That's fine. Laravel 5.3 is allowed breaking changes wrt 5.2.

@taylorotwell taylorotwell merged commit 7af9cd1 into laravel:5.3 Jul 12, 2016
@dan-har dan-har deleted the 5.3 branch August 30, 2016 16:15
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.

4 participants