Removing items in Orchard

Some of you reported an issue with deleting menus in Advanced Menu module. It was widely discussed in initial post comments and on StackOverflow. I’ve investigated that issue and was pretty surprised with findings. It looks like it was related to how Orchard handles content item removal, what is a pretty interesting thing because it works differently as one may think.

Content items never get completely deleted.

Remember that when designing your content parts. They have only certain flags removed which makes them invisible to further queries.  It’s a desirable behavior in many cases, as it allows items to be undeleted, browse history etc. But it raises a couple of issues though, e.g.. with unique columns on content part records – you cannot recreate the removed item with the same value, as it’s there all the time.

If you want to completely erase an item – you can do that via IRepository<ContentItem> when needed (e.g.. in ContentHandler’s OnRemoved event). Related content part records will be automatically deleted. I hope that future Orchard releases will have the feature to delete content items via ContentManager built-in.

Thanks to Louis De Jardin, who described it in details here.

Cheers!

blog comments powered by Disqus