phpcr-odm
phpcr-odm copied to clipboard
Cannot change nodename and add new reference to collection. Fails with 409, PathNotFoundException.
You cannot update the nodename
of a document and add a new reference in the same transaction. To illustrate the issue better, I have the following code example:
$page = $dm->find(null, $object->getId());
$page->setName('helloo');
$translation = new PageTranslation();
$translation->setLocale('nl_NL');
$translation->setTitle('Over ons');
$translation->setBody('Content voor over ons');
$page->addTranslation($translation);
$dm->persist($page);
$dm->flush();
When running the above code, it will throw the following exception:
PHPCR\PathNotFoundException: HTTP 409: /workspaces/525/channels/658/pages/helloo/nl_NL
I am not sure if this is a problem in the phpcr-odm
project or an issue with the jackalope-jackrabbit
transport layer.
i think this is a problem of how references and renamings are handled inside the unit of work. it might also depend on order of execution. if you have time to look into this, i would be glad - i can't promise to find time to dig through that one.
btw, for your example, did you consider using the translation functionality of phpcr-odm itself? then you would not need PageTranslation objects and localization would happen completely transparent: http://doctrine-orm.readthedocs.org/projects/doctrine-phpcr-odm/en/latest/reference/multilang.html
When I find some more debug time I will try and find the issue, I was already looking in how the Jackalope client builds the request to the JCR repository, but I lack the understanding, so I need to know first how everything works. I will give it a try 👍
Well, I need to be able to load the translations of all locales in the same runtime, calls like $page->getTranslations()
should work properly. Also I wanted a nice way to add new translations. This is the RFC/Proposal I am currently issuing for Sylius: https://github.com/Sylius/Sylius/issues/4808
To achieve that with the translations system provided by doctrine phpcr-odm, it would require a lot of hacking to make a good public API to work with translations. The only downside with my approach, is that when you require one translation, all of them will be loaded in memory for that document. Or do you know a way to achieve some kind of extra lazy loading with phpcr?
lets continue the discussion about what sylius needs in #704