3
Vote

Taxonomy 1.8.1 Release has Small Bug (Fix Included)

description

With the recent taxonomy changes for 1.8.1 there is a small bug in Orchard.Taxonomies.Handlers.TermsPartHandler --> InitializerTermsLoader method. In the part._termParts.Loader expression it puts the results in a dictionary. However, the Id's are not always distinct (or I have some corrupt data). Either way, here is the fix:

Original:
var ids = part.Terms.Select(t => t.TermRecord.Id);
var terms = _contentManager.GetMany<TermPart>(ids, VersionOptions.Published, queryHint)
    .ToDictionary(t => t.Id, t => t);
Fixed:
var ids = part.Terms.Select(t => t.TermRecord.Id).Distinct(); // EMS CHANGE - added .Distinct()
var terms = _contentManager.GetMany<TermPart>(ids, VersionOptions.Published, queryHint)
    .ToDictionary(t => t.Id, t => t);
This ensures that the ids used to get TermPart are unique (and thus the .ToDictionary expression will have unique Id's also).

comments

StanleyGoldman wrote Jul 8 at 5:04 PM

Glad to know I wasn't the only one...

https://orchard.codeplex.com/discussions/549275