Sitecore Partial Language Fallback Cache Clearing Issue

I have been using the Sitecore Partial Language Fallback module and have faced an issue which causes a null exception during publish and the cache doesn’t clear properly on CD servers.

Today someone else faced the same issue on the sdn forums and hence decided to write a quick fix for the same

http://sdn.sitecore.net/Forum/ShowPost.aspx?PostID=60769

File to be Modified : Sitecore.SharedSource.PartialLanguageFallback/Providers/FallbackLanguageProvider.cs

Method to be modified :  ClearFallbackCaches

    private void ClearFallbackCaches(ItemUri itemUri, Database database)
      {
         var cache = _fallbackValuesCaches[database.Name];
         var ignore_cache = _fallbackIgnoreCaches[database.Name];

         if (cache != null)
         {
             // Added a null check on itemUri
			 if (itemUri == null)
                 cache.Clear();
             else
                 cache.RemoveKeysContaining(itemUri.ItemID.ToString());
         }
         if (ignore_cache != null)
         {
             // Added a null check on itemUri
			 if (itemUri == null)
                 ignore_cache.Clear();
             else
				 ignore_cache.RemoveKeysContaining(itemUri.ItemID.ToString());
         }
	  }

In the FallbackLanguageProvider class, The InitializeEventHandlers method binds the PublishEndRemoteEvent to ClearFallbackCaches with null as ItemUri.This causes the null reference exception and the caching issue.

Once we add the null reference checks before clearing the cache, Things seems to be back to normal

Should you have any questions, Please feel free to drop me a line @ sjain@horizontalintegration.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: