Delete ContentItem with associated Terms.

Jan 29, 2013 at 5:44 PM
Edited Jan 29, 2013 at 5:45 PM

I have Content with 3 Taxonomies Field associated. 

When I try to delete one of this ContentItems that have a Term selected, the contentitem is no deleted.

Looking the logs I found this error


NHibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)


The workaround that I found was to execute ContentManager.Clear() right before the ContentManager.Remove(ContentItem).

If someone could give me some guidance to fix this bug I would gladly submit a patch.

Looking at the code I think that this error is originated from the OnRemoved event in the Handler of the TermsPart. (TermsPartHandler.cs line 28)


OnRemoved<TermsPart>((context, part) => RecalculateCount(contentManager, taxonomyService, part));

This event calls a function in the service that makes a query useing a QueryHint to TitlePart and AutoRoute. (TaxonomyService.cs)


        public IEnumerable<TermPart> GetTerms(int taxonomyId) {

            return _contentManager.Query<TermPart, TermPartRecord>()
                .Where(x => x.TaxonomyId == taxonomyId)
                .WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord>())
                .OrderBy(t => t.FullPath);