LibrarySites.Banner

Bug in Clearing Fallback Cache

I realized recently that there is a bug in the partial language fallback module in regards to clearing the fallback cache upon the publish end remote event. This basically throws an error on CD sites and does not properly clear the cache. Items that are falling back to others therefore may take a long time to update on the front-end (until the cache clears on its own). I want to recognize Horizon Integrations for also catching this and posting a fix: http://blog.horizontalintegration.com/2014/05/03/sitecore-partial-language-fallback-cache-clearing-issue/

Basically you need to fix the source code and recompile to fallback dll. It needs to take into account whether the itemUri is null or not (will be null in a remote publish event for CD sites). If so, it will just clear the whole fallback cache and not just an entry for that particular item (which it does on CM sites). The fix must be done in the /Providers/FallbackLanguageProvider.cs file, ClearFallbackBackCaches method:

private void ClearFallbackCaches(ItemUri itemUri, Database database)
{
var cache = _fallbackValuesCaches[database.Name];
var ignore_cache = _fallbackIgnoreCaches[database.Name];
 
//
// this is called by InitializeEventHandlers, EventManager.Subscribe, where it passes in a null ItemUri
// Therefore on CD servers, where PublishEndRemoteEvent would be called, there would have been null errors when trying to use itemUri
// must add null check and if null, whole fallback cache should be cleared
 
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());
}
}

You can get a copy of the updated file that needs to be updated if you are going to compile your project here:

https://github.com/Verndale-Corp/Sitecore-Fallback-FullDemo/tree/master/Sitecore.SharedSource.PartialLanguageFallback/Providers

The compiled dll that includes this update for sitecore 7.2 here: https://github.com/Verndale-Corp/Sitecore-7-Fallback-Lucene-Indexing

The compiled dll that includes this update for sitecore 6.6 here: https://github.com/Verndale-Corp/Sitecore-Fallback-Enforce-Version-Customizations/tree/master/bin