Bug in Taxonomy module...TermsPartHandler.RecalculateCount caught in endless loop?

Topics: Core, Customizing Orchard, General, Writing modules
Nov 4, 2014 at 8:22 PM
I am working through the Pluralsight Advanced Orchard course. I made some mods, including switching out the Movie DB provider. When I got it all set, on submitting a new Movie for import Orchard seems to hang... I think this is the problem. In the TermsPartHandler. My reading of the code would indicate that the while loop will never break because termPart is never given a change to be set to null if it doesn't have a parent term. That is definitely what is happening to in my case. termPart.Container == null.

I am doubting my analysis since Taxonomies have been out there forever. Am I missing something?


        // Retrieve the number of associated content items, for the whole hierarchy
        private static void RecalculateCount(ITaxonomyService taxonomyService, TermsPart part) {
            foreach (var term in part.Terms) {
                var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
                while (termPart != null) {
                    termPart.Count = (int)taxonomyService.GetContentItemsCount(termPart);

                    // compute count for the hierarchy too
                    if (termPart.Container != null) {
                        var parentTerm = termPart.Container.As<TermPart>();
                        termPart = parentTerm;
Nov 4, 2014 at 10:05 PM
Were you able to see this with a debugger attached? Can you write up some simple repro steps?
Nov 7, 2014 at 5:59 PM

Thanks for your reply.

This link has a module that repros the bug.


Enable it. Create a new Color Palette content item. In the ListOfColors type a separated list of colors as follows... "Purple, Sky Blue" (these are currently NOT in the taxonomy although any comma delimited list will do...)

Put a breakpoint in the post of the driver of the new module and in the TermsPartHandler.RecalculateCount method.

Save and you will be caught in the endless loop.

Nov 7, 2014 at 6:33 PM
Thanks for that, that is helpful. If you don't mind, please open a new work item so we can triage, assign, and fix.
Nov 7, 2014 at 6:36 PM
I don't know how to open a work item. Can you give me a bit of guidance?
Nov 7, 2014 at 6:46 PM
Sure, go to "Issues" (to the right of the "Discussions" tab, and click the "New Issue" link. The word "issue" here on CodePlex is synonymous to "work item".
Nov 7, 2014 at 7:05 PM
OK...thought that might be it.