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

Changing the name of a node results in deletion not move #659

Open
uwej711 opened this issue Sep 14, 2015 · 7 comments
Open

Changing the name of a node results in deletion not move #659

uwej711 opened this issue Sep 14, 2015 · 7 comments

Comments

@uwej711
Copy link
Contributor

uwej711 commented Sep 14, 2015

I found this while trying to rename a route (from the RoutingBundle) with setName, the cause is a bit difficult to describe ...

First you need a parent with mapped children, say /cms/routes/zn, the child /cms/routes/zn/page-1 will be renamed to page-2 with setName.

The UnitOfWork correctly detects the move of /cms/routes/zn/page-1 to /cms/routes/zn/page-2. But it also creates a change for /cms/routes/zn because it adds an empty reordering in https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/UnitOfWork.php#L1422 or https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/UnitOfWork.php#L1424. the resulting executeUpdates for /cms/routes/zn triggers another computeChangeset for that node in https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/UnitOfWork.php#L2482, which then results in a deletion of /cms/routes/zn/page-1.

Only adding the reodering if the array in https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/UnitOfWork.php#L1420 has count > 0 solves that very special case for me but if your parent node has other changes it will break anyway.

Hope this is somehow clear ...

Cheers
Uwe

@dbu
Copy link
Member

dbu commented Sep 18, 2015

i guess we should not add the empty reordering, it makes no sense. but for when other changes do exist, we have to sort out the ordering issue then.

@uwej711
Copy link
Contributor Author

uwej711 commented Sep 18, 2015

The setup to demonstrate this seems a bit more complicated than I thought ...

uwej711 added a commit to uwej711/phpcr-odm that referenced this issue Sep 21, 2015
@dantleech
Copy link
Contributor

So this UOW is moving the node, then recalculating the changeset, and then registering a delete for the "missing" node and then deleting it because executeRemoves is after executeUpdates ?

  • Could we calculate the delete based on UUID instead of node names? (only if we were to force UUIDs in a next major version).

@uwej711
Copy link
Contributor Author

uwej711 commented Oct 9, 2015

This is a bit more complicated, see the test in #661.
Because there is an event listener computeChangeset is called twice but the second computation messes up the child renaming. In #661 I restricted this changeset computation to fields only bit that leaves us with a failing test that want's to revert a child reorder in the preUpdate event.

uwej711 added a commit to valiton-forks/phpcr-odm that referenced this issue Nov 2, 2015
possible fix for issue doctrine#659

fix cs
@uwej711
Copy link
Contributor Author

uwej711 commented Apr 3, 2017

Just bumped into that again. I think I will test my change in #661 in production now ...

uwej711 added a commit to valiton-forks/phpcr-odm that referenced this issue Apr 3, 2017
@dbu
Copy link
Member

dbu commented Apr 5, 2017 via email

@uwej711
Copy link
Contributor Author

uwej711 commented Apr 5, 2017

As already mentioned in #661 there remains an issue with undoing an reordering of children in preUpdate which keeps the tests failing. If I find the time I will investigate that again.

Dens49 pushed a commit to Dens49/phpcr-odm that referenced this issue Dec 13, 2017
(cherry picked from commit a338384)
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