Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling the order of SDL Tridion 2011 Custom Resolvers

Tags:

tridion

I have a Custom Resolver configured for SDL Tridion 2011 which is designed to prevent Pages and Components which use a Multimedia Component from being published when a user publishes the linked Multimedia Component. This Custom Resolver is replacing an old event handler which looked like this:

private void MMCmpPublishHandler(Component source, PublishEventArgs args, 
                                 EventPhases phase)
{
    if (source.ComponentType == ComponentType.Multimedia)
    {
        args.PublishInstruction.ResolveInstruction.IncludeComponentLinks = false;
    }
}

The old event handler used to be called before the resolvers were invoked. I have configured my new resolver to fire after the default the resolver by configuring my Tridion.ContentManager.config file with the following extract:

<add itemType="Tridion.ContentManager.ContentManagement.Component">
    <resolvers>
        <add type="Tridion.ContentManager.Publishing.Resolving.ComponentResolver" assembly="Tridion.ContentManager.Publishing, Version=6.1.0.996, Culture=neutral, PublicKeyToken=360aac4d3354074b"/>
        <add type="UrbanCherry.Net.SDLTridion.CustomResolvers.DynamicBinaryLinkResolver" assembly="UrbanCherry.Net.SDLTridion.CustomResolvers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e7729a00ff9574fb"/>
    </resolvers>
</add>

The code works fine, although it seems counter intuitive (from a performance perspective) to place the new resolver after the default resolver as the default resolver takes time to find all the resolved items only to have them all removed again.

I tried changing the order of the resolvers so that the new resolver is called first, but the new resolver is never called, and the following error appears in the event log:

Object reference not set to an instance of an object.


Component: Tridion.ContentManager.Publishing
Errorcode: 0
User: NT AUTHORITY\SYSTEM

StackTrace Information Details:
   at Tridion.ContentManager.Publishing.Resolving.ResolveEngine.ResolveItems(IEnumerable`1 items, ResolveInstruction instruction, IEnumerable`1 contexts)
   at Tridion.ContentManager.Publishing.Resolving.ResolveEngine.ResolveItem(IdentifiableObject item, ResolveInstruction instruction, PublishContext context)
   at Tridion.ContentManager.Publishing.Handling.DefaultPublishTransactionHandler.HandlePublishRequest(PublishTransaction publishTransaction)
   at Tridion.ContentManager.Publishing.Handling.DefaultPublishTransactionHandler.ProcessPublishTransaction(PublishTransaction publishTransaction)
   at Tridion.ContentManager.Publishing.Publisher.QueueMessageHandler.HandleMessage()

Does anyone know if it is possible to call a Custom Resolver before a Default Resolver, and if not can you suggest an efficient way to achieve the same behavior as the old event handler?

like image 964
Chris Summers Avatar asked Feb 22 '23 00:02

Chris Summers


2 Answers

We have opened an incident request to Tridion SDL support. Please find below their answer:

R&D department have confirmed that the issue you have found is a defect staring with the migration to SP1. It is now no longer possible to place a custom resolver before the default resolver.The issue is expected to be handled in a future release.

like image 90
Sébastien PRAT Avatar answered Apr 27 '23 13:04

Sébastien PRAT


It is certainly possible to call your resolver first, however you will need it to create the initial list of resolved items. Since that is basically what the default resolver already does, it doesn't make much sense trying to add yours in front of it in my mind.

So yes performance wise it would make more sense to only have your resolver and have it replace the default one. But then you should really decompile the default one and rewrite it with your logic in there. Which is counter productive certainly considering hotfixes and upgrades would mean your resolver code might need to change in the future.

I found that the resolvers actually are so fast that I ignored the performance impact of removing the few items I needed removed in mine. It realistically is only adding items to a list and then you are removing a few of those items from the list again.

like image 22
Bart Koopman Avatar answered Apr 27 '23 13:04

Bart Koopman