Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Getting the children of an article node during a comment nodes unpublished event still shows the unpublished comment node as a valid child. Why?
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 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.
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.
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...
I've now created a bug report for this issue: https://github.com/umbraco/Umbraco-CMS/issues/11164
Edit: a workaround was provided in the bug report, so I'll mark this thread as solved (but the ticket is still open as there could still be a bug to fix within Umbraco)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted