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

Regression when persisting object ID and changing the locale #657

Open
dantleech opened this issue Aug 29, 2015 · 5 comments
Open

Regression when persisting object ID and changing the locale #657

dantleech opened this issue Aug 29, 2015 · 5 comments

Comments

@dantleech
Copy link
Contributor

A test has been added in the RoutingAutoBundle which seems to reveal a regression introduced in 83863d7.

Failure is as follows

1) Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Functional\EventListener\AutoRouteListenerTest::testMultilangArticleRemainsSameLocale
Undefined index: path

/home/daniel/www/symfony-cmf/RoutingAutoBundle/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:40
/home/daniel/www/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:1604
/home/daniel/www/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:1123
/home/daniel/www/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:2157
/home/daniel/www/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/DocumentManager.php:949
/home/daniel/www/symfony-cmf/RoutingAutoBundle/Tests/Functional/EventListener/AutoRouteListenerTest.php:288

Where path is the name of the property mapped as the @Id.

/cc @lsmith77 @wouterj

@wouterj
Copy link
Contributor

wouterj commented Aug 29, 2015

I suspect it is caused by this PR: #555 (which was merged in 1.2.0-RC4, the first version failing). So this has to be fixed in both 1.2.x and master.

@wouterj
Copy link
Contributor

wouterj commented Aug 29, 2015

Btw, the problem probably is not in the fact that path is the Id, but that the Id is one of the types that is not translatable. Only the translatable fields seem to exists at the line of the error.

@dantleech
Copy link
Contributor Author

ok, I know what the problem is.

When the changeset if calculated the "isNew" flag is determined by the presence of the object ID in the $originalData array. If isNew is false then we expect all the fields to be present in the $originalData.

The problem is caused when we call findTranslation. This causes the UOW to set the originalData with only the translated fields. It seems it expects that the originalData already has been initialized (with all the fields).

I am not sure how to fix this but I think it is invalid to call findTranslation before a document is persisted. /cc @lsmith77 @dbu

@dbu
Copy link
Member

dbu commented Sep 25, 2015

oh my. well, you can bindTranslation before persisting, so findTranslation must work as well. i guess we should fix this edge case, maybe in bindTranslation to create all the expected data. or in findTranslation to not create any originalData when the document is new, because it actually makes no sense. could the later be the right solution?

@dantleech
Copy link
Contributor Author

Had another go at this, but failed. Maybe another day.

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

No branches or pull requests

3 participants