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

ORM second level cache and version (locking) #7067

Closed
wtorsi opened this issue Feb 15, 2018 · 7 comments
Closed

ORM second level cache and version (locking) #7067

wtorsi opened this issue Feb 15, 2018 · 7 comments
Assignees
Milestone

Comments

@wtorsi
Copy link

wtorsi commented Feb 15, 2018

Hi,
I have found strange behaviour when using Second Level Cache and Version.
When new version is set second level cache does not include it into update.

After some investigation:
The problem occurs here DefaultEntityHydrator::buildCacheEntry, UnitOfWork does not include version field in actualData.

Any ideas how to fix it?

@Ocramius
Copy link
Member

This is way too little information to work on anything. Please try re-creating a failure with an isolated test. See examples at https://github.com/doctrine/doctrine2/tree/master/tests/Doctrine/Tests/ORM/Functional/Ticket

@wtorsi
Copy link
Author

wtorsi commented Feb 15, 2018

I have never done it before.
Also, i'm using Symfony Bridge, I have never configured Doctrine from the box :)
Ok, i'll try.

Here is the fast fix:

// Doctrine\ORM\Cache\DefaultEntityHydrator::buildCacheEntry

$data = $this->uow->getOriginalEntityData($entity);
$data = array_merge($data, $metadata->getIdentifierValues($entity)); // why update has no identifier values ?

//here it is
if ($metadata->isVersioned) {
    $data[$metadata->versionField] = $metadata->getFieldValue($entity, $metadata->versionField);
}

This can fix the problem.

@wtorsi
Copy link
Author

wtorsi commented Feb 16, 2018

@Ocramius hi again, I need some help.
How I can push a commit with test to repo? It's my first time, sorry.

@Ocramius
Copy link
Member

@wtorsi you first need to fork this repository (top right on this page), then follow https://yangsu.github.io/pull-request-tutorial/ 👍

@wtorsi
Copy link
Author

wtorsi commented Feb 16, 2018

Thank's

wtorsi pushed a commit to wtorsi/doctrine2 that referenced this issue Feb 16, 2018
wtorsi pushed a commit to wtorsi/doctrine2 that referenced this issue Feb 16, 2018
for doctrine version 3
@wtorsi
Copy link
Author

wtorsi commented Feb 16, 2018

Got it, here is the test.
Here is the test and fix for doctrine 3

lcobucci pushed a commit to wtorsi/doctrine2 that referenced this issue Feb 17, 2018
As explained in doctrine#7067, fields with `@ORM\Version` annotation were not
being added to L2C cached data.
lcobucci pushed a commit to wtorsi/doctrine2 that referenced this issue Feb 17, 2018
As explained in doctrine#7067, fields with `@ORM\Version` annotation were not
being added to L2C cached data.
lcobucci pushed a commit to wtorsi/doctrine2 that referenced this issue Feb 17, 2018
As explained in doctrine#7067, fields with `@ORM\Version` annotation were not
being added to L2C cached data.
lcobucci added a commit that referenced this issue Feb 17, 2018
Test for Second level cache with Version, DDC #7067
lcobucci pushed a commit that referenced this issue Feb 17, 2018
As explained in #7067, fields with `@ORM\Version` annotation were not
being added to L2C cached data.
@lcobucci
Copy link
Member

Fixed by #7069

@Ocramius Ocramius added this to the 2.6.1 milestone Feb 17, 2018
maglnet pushed a commit to maglnet/doctrine2 that referenced this issue Oct 10, 2018
As explained in doctrine#7067, fields with `@ORM\Version` annotation were not
being added to L2C cached data.
guilhermeblanco pushed a commit that referenced this issue May 30, 2019
As explained in #7067, fields with `@ORM\Version` annotation were not
being added to L2C cached data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants