Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Make sure locale doesn't change after flush is called #159

Merged
merged 3 commits into from
Oct 10, 2015

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Aug 23, 2015

Fixes #145

I could not find an easy way to test this...

// reset locale to the original locale
if (null !== $locale) {
$meta = $dm->getMetadataFactory()->getMetadataFor(get_class($document));
$dm->findTranslation($meta->getName(), $meta->getIdentifierValue($document), $locale);
Copy link
Member

Choose a reason for hiding this comment

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

you should use $uow->getDocumentId($document) instead. reading the $meta->getIdentifierValue code, it seems that the id could be not mapped on the document.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, didn't know such a method existed on the uow.

Copy link
Member

@dbu dbu Aug 25, 2015 via email

Choose a reason for hiding this comment

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

@dantleech
Copy link
Member

+1 nice work @wouterj -- whats the problem with testing? too much to setup?

@wouterj
Copy link
Member Author

wouterj commented Aug 24, 2015

Added a test & fixed the comments.

@dantleech couldn't think of a way to bind different locales and then make sure the locale is not the last bound locale before calling flush. Now I realized it's just as simple as calling findTranslation before flushing...

if (null !== $locale) {
$dm->findTranslation(get_class($document), $uow->getDocumentId($document), $locale);

$locale = null;
Copy link
Member

Choose a reason for hiding this comment

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

this does nothing, its overwritten in the next iteration.

@dbu
Copy link
Member

dbu commented Aug 25, 2015

not sure what exactly causes the test failure - looks unrelated to this PR. the php class is Nodename not NodeName - is that case sensitive?

@wouterj
Copy link
Member Author

wouterj commented Aug 25, 2015

Updated

@dantleech
Copy link
Member

Tests failing, unidentified index path

@wouterj
Copy link
Member Author

wouterj commented Aug 27, 2015

@dantleech this seems to be a bug in Doctrine PHPCR, when calling findTranslation before flush (it works before 1.2.0-RC4 btw).

This PR works perfectly, but the test doesn't. Should be skip it until the bug has been fixed, so we can merge this?

@dantleech
Copy link
Member

It depends if we are going to release CMF before PHPCR-ODM 1.3. If we have found a regression it must be fixed before the 1.3 release. If we plan to release 1.3 before or at the same time as the next CMF round of releases, I would prefer to wait.

Could you create an issue on phpcr-odm? If nobody else looks I will try and tackle it on Saturday

@dbu
Copy link
Member

dbu commented Aug 28, 2015 via email

@wouterj
Copy link
Member Author

wouterj commented Oct 10, 2015

Build passes now, thanks @dantleech

@dbu
Copy link
Member

dbu commented Oct 10, 2015

so, should we merge this? or is doctrine/phpcr-odm#665 still a problem?

@wouterj
Copy link
Member Author

wouterj commented Oct 10, 2015

No, @dantleech worked around that bug in the tests.

dantleech added a commit that referenced this pull request Oct 10, 2015
Make sure locale doesn't change after flush is called
@dantleech dantleech merged commit 404874b into symfony-cmf:master Oct 10, 2015
@dantleech dantleech removed the review label Oct 10, 2015
@dantleech
Copy link
Member

Cheers @wouterj

@wouterj wouterj deleted the issue_145 branch October 10, 2015 17:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants