Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jon 92 posts 166 karma points
    Aug 04, 2020 @ 16:09
    Jon
    0

    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

  • Marc Goodson 2136 posts 14298 karma points MVP 8x c-trib
    Aug 05, 2020 @ 08:43
    Marc Goodson
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft