Projection FieldIndexPartHandler welding FieldIndexPart to all new content items.

Topics: Troubleshooting
Nov 5, 2012 at 3:04 PM

Not sure if this is a bug or not. Just noticed when creating any new content item via code when projections module is enabled that the new content item always gets the FieldIndexPart welded to it. Shouldn't this part only be welded if the content type has any parts that have fields added?

I think the problem may be in the Projections/Handlers/FieldIndexPartHandler.cs class

 protected override void Activating(ActivatingContentContext context) {
            base.Activating(context);

            context.Builder.Weld<FieldIndexPart>();

            // weld the FieldIndexPart dynamically, if a field has been assigned to one of its parts
            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentType);
            if (contentTypeDefinition == null)
                return;
            if (contentTypeDefinition.Parts.Any(p => p.PartDefinition.Fields.Any())) {
                context.Builder.Weld<FieldIndexPart>();
            }
        }

In that code it looks to me like the first call to context.Builder.Weld<FieldIndexPart>() really should be there. Any reason why it is?

Coordinator
Nov 6, 2012 at 12:32 AM

I agree, shouldn't be there. Some debugging code that maybe I forgot to remove ...

Nov 8, 2012 at 1:07 PM

I've created an issue for this, resolved it and generated a pull request.

http://orchard.codeplex.com/workitem/19231