Copied to clipboard

Flag this post as spam?

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


  • George Kent-Nye 22 posts 125 karma points
    1 week ago
    George Kent-Nye
    0

    ContentService unpublished event not updating IPublishedContent parent's children

    TLDR Version

    Getting the children of an article node during a comment nodes unpublished event still shows the unpublished comment node as a valid child. Why?

    Longer version

    I have hooked a few custom methods into the ContentService events to update a custom sql table, but I'm having a bit of a problem with the unpublished event.

    What I'm trying to do

    After unpublishing a "comment" from an "article", I need the custom sql db to remove the comment, and then update the article's custom update date since the comment may have been the most recent update.

    How I'm doing it

    In the ContentService.Unpublished I'm first deleting the comment, then deleting its parent, the article, from the db and all its other child comments.

    After the db is cleared, I'm then rebuilding the article using its umbraco IPublishedContent data, and then all its surviving comments.

    The problem

    The issue is the IPublishedContent for the article still has the old comment I've just unpublished as one of its children!

    This means it initially gets deleted from my db, but then when the article is rebuilt it also gets recreated as well.

    I have no idea why article.Children still contains the unpublished comment - I'd understand if I was hooking into the ContentService.Unpublishing event, but I'm using the .Unpublished event - supposedly after the comment has been deleted from the umbraco db/nucache... So to me it doesn't make any sense that it's showing up...

    Is this expected behaviour? Am I missing something?

    I've event tried article.Children.where(x => x.isPublished()), but still have the same result.

    Any help/thoughts would be appreciated.

  • George Kent-Nye 22 posts 125 karma points
    1 week ago
    George Kent-Nye
    0

    I should also note I have no issue with the ContentService.Trashed event I also hook into - it actually uses the exact same method for deleting/rebuilding the db entries....

    So I can almost rule out the code as the source of the issue - it does seem specific to the .Unpublished event only.

  • George Kent-Nye 22 posts 125 karma points
    1 week ago
    George Kent-Nye
    0

    I still haven't been able to find a solution to this- I really don't understand how ContentService.Unpublished hasn't updated all the IPublishedContents, since the unpublishing process should be complete by the time the event is fired...

  • George Kent-Nye 22 posts 125 karma points
    6 days ago
    George Kent-Nye
    0

    I've now created a bug report for this issue: https://github.com/umbraco/Umbraco-CMS/issues/11164

Please Sign in or register to post replies

Write your reply to:

Draft