Skip to content

[5.6] syncOriginal on refresh - #21905

Merged
taylorotwell merged 1 commit into
laravel:masterfrom
maintainlyhq:sync_original_on_refresh
Nov 1, 2017
Merged

taylorotwell merged 1 commit into
laravel:masterfrom
maintainlyhq:sync_original_on_refresh

Conversation

@patrickomeara

@patrickomeara patrickomeara commented Nov 1, 2017 •

Copy link
Copy Markdown
Contributor

This is a new PR from #21889 with target version 5.6, instead of 5.5

Currently, after refreshing a model it can be dirty even when the attributes match those in the database.

$post = Post::create(['title' => 'pat']);

Post::find($post->id)->update(['title' => 'patrick']);

$post->refresh();

// current result
$post->getOriginal('title'); // pat
$post->getDirty(); // ['title' => 'patrick']

// with proposed fix 
$post->getOriginal('title'); // patrick
$post->getDirty(); // []

Syncing with the original after refresh prevents this.

@taylorotwell
taylorotwell merged commit f1584bf into laravel:master Nov 1, 2017
salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
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.

2 participants