Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Merge entity associated to versioned entity#1573

Merged
Ocramius merged 4 commits into
doctrine:masterfrom
AdactiveSAS:MergeVersioned
Dec 11, 2015
Merged

Merge entity associated to versioned entity#1573
Ocramius merged 4 commits into
doctrine:masterfrom
AdactiveSAS:MergeVersioned

Conversation

@moroine
Copy link
Copy Markdown

@moroine moroine commented Nov 27, 2015

I wrote a unit test that reveal the bug and a fix.

If I merge an entity which is associated to a versioned entity this fire a OptimisticLockException as the managedCopy is a Proxy so the version attribute is always null.

I think when we compare version attribute, we should skip it when one of the entity or the managed copy is a Proxy not initialized.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this try-catch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove this empty line

Comment thread lib/Doctrine/ORM/UnitOfWork.php Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be clearer to flip this function and rewrite it as a positive-question, where you're asking if the entity has any data to work with.

private function isLoaded($entity){
    return !($entity instanceof Proxy) || $entity->__isInitialized();
}

Other possible names that come to mind are hasData() or isInitialized(). (Assuming that non-proxies are considered initialized too.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a public $tags earlier on?

Ocramius added a commit that referenced this pull request Dec 11, 2015
Ocramius added a commit that referenced this pull request Dec 11, 2015
Ocramius added a commit that referenced this pull request Dec 11, 2015
Ocramius added a commit that referenced this pull request Dec 11, 2015
@Ocramius Ocramius merged commit fb4d02c into doctrine:master Dec 11, 2015
Ocramius added a commit that referenced this pull request Dec 11, 2015
Ocramius added a commit that referenced this pull request Dec 11, 2015
Ocramius added a commit that referenced this pull request Dec 11, 2015
@Ocramius
Copy link
Copy Markdown
Member

Merged, thanks!

Backported also in 2.5.x via 62719f2

@Ocramius Ocramius self-assigned this Dec 11, 2015
@Ocramius Ocramius added this to the 2.5.3 milestone Dec 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants