Im writing code to unidex pages from an external search when a page is moving. I have noticed that contentservice.Moving only has the page that we are moving in the MoveInfoCollection and NOT its child pages.
Yet, ContentService.Moved has all the child pages.
I need to unindex all pages when moving and reindex when Moved (new location).
Is the issue with a single page in the mioveinfocollection during Moving a bug or is there a different way to get all the pages underneath this page?
It looks like the calculation of the descendants of the moved page is made during the actual move of the content item... eg after the 'Moving' event has been fired:
and each one is adding to a 'moves' list, which is then set as the MoveInfoCollected in the Moved event.
So it would need to make the descendants call earlier to include them in the Moving event.
One possible workaround would be in your external indexing service, are you indexing the 'Path' property for each node (the comma separated list of integer values starting at -1, and including each parent id, down the content tree to the actual content item id) - or could you add it? - if so then during the 'Moving' event you could unindex any content items that included the id of the page being moved in their existing 'Path'...
Umbraco Events - Moving - MoveInfoCollection doesnt contain child pages
Hi,
Im writing code to unidex pages from an external search when a page is moving. I have noticed that contentservice.Moving only has the page that we are moving in the MoveInfoCollection and NOT its child pages.
Yet, ContentService.Moved has all the child pages.
I need to unindex all pages when moving and reindex when Moved (new location).
Is the issue with a single page in the mioveinfocollection during Moving a bug or is there a different way to get all the pages underneath this page?
Jon
Hi Jon
It looks like the calculation of the descendants of the moved page is made during the actual move of the content item... eg after the 'Moving' event has been fired:
https://github.com/umbraco/Umbraco-CMS/blob/b21f5f59b09c43fd015681a073a5c00da486bba0/src/Umbraco.Core/Services/Implement/ContentService.cs#L1965
You can see inside 'PerformMoveLocked' where the descendants are calculated and then subsequently moved;
https://github.com/umbraco/Umbraco-CMS/blob/b21f5f59b09c43fd015681a073a5c00da486bba0/src/Umbraco.Core/Services/Implement/ContentService.cs#L2023
and each one is adding to a 'moves' list, which is then set as the MoveInfoCollected in the Moved event.
So it would need to make the descendants call earlier to include them in the Moving event.
One possible workaround would be in your external indexing service, are you indexing the 'Path' property for each node (the comma separated list of integer values starting at -1, and including each parent id, down the content tree to the actual content item id) - or could you add it? - if so then during the 'Moving' event you could unindex any content items that included the id of the page being moved in their existing 'Path'...
regards
Marc
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.