private void UpdateLanguageFallbackDependentItems(IProviderUpdateContext context, SitecoreIndexableItem versionIndexable, IndexEntryOperationContext operationContext) { if (operationContext == null || operationContext.NeedUpdateAllLanguages) { return; } var item = versionIndexable.Item; bool?currentValue1 = Switcher <bool?, LanguageFallbackFieldSwitcher> .CurrentValue; if ((!currentValue1.GetValueOrDefault() ? 1 : (!currentValue1.HasValue ? 1 : 0)) != 0) { bool?currentValue2 = Switcher <bool?, LanguageFallbackItemSwitcher> .CurrentValue; if ((!currentValue2.GetValueOrDefault() ? 1 : (!currentValue2.HasValue ? 1 : 0)) != 0 || StandardValuesManager.IsStandardValuesHolder(item) && item.Fields[FieldIDs.EnableItemFallback].GetValue(false) != "1") { return; } using (new LanguageFallbackItemSwitcher(new bool?(false))) { if (item.Fields[FieldIDs.EnableItemFallback].GetValue(true, true, false) != "1") { return; } } } if (!item.Versions.IsLatestVersion()) { return; } foreach (var indexable in Enumerable.Select(Enumerable.Where <Item>(Enumerable.SelectMany(LanguageFallbackManager.GetDependentLanguages(item.Language, item.Database, item.ID), language => { var item2 = item.Database.GetItem(item.ID, language); if (item2 == null) { return(new Item[0]); } return(item2.Versions.GetVersions()); }), item1 => !IsExcludedFromIndex(item1, false)), item1 => PrepareIndexableVersion(item1, context))) { Operations.Update(indexable, context, context.Index.Configuration); } }
protected virtual void UpdateItemVersion(IProviderUpdateContext context, Item version, IndexEntryOperationContext operationContext) { var versionIndexable = PrepareIndexableVersion(version, context); Operations.Update(versionIndexable, context, context.Index.Configuration); UpdateClones(context, versionIndexable); UpdateLanguageFallbackDependentItems(context, versionIndexable, operationContext); }
public override void Update(IProviderUpdateContext context, IIndexableUniqueId indexableUniqueId, IndexEntryOperationContext operationContext, IndexingOptions indexingOptions = IndexingOptions.Default) { Assert.ArgumentNotNull(indexableUniqueId, "indexableUniqueId"); if (!ShouldStartIndexing(indexingOptions)) { return; } if (IsExcludedFromIndex(indexableUniqueId, true)) { return; } if (operationContext != null) { if (operationContext.NeedUpdateChildren) { var obj = Sitecore.Data.Database.GetItem((indexableUniqueId as SitecoreItemUniqueId)); if (obj != null) { UpdateHierarchicalRecursive(context, obj, CancellationToken.None); return; } } if (operationContext.NeedUpdatePreviousVersion) { var obj = Sitecore.Data.Database.GetItem((indexableUniqueId as SitecoreItemUniqueId)); if (obj != null) { UpdatePreviousVersion(obj, context); } } } var indexableAndCheckDeletes = GetIndexableAndCheckDeletes(indexableUniqueId); if (indexableAndCheckDeletes == null) { if (GroupShouldBeDeleted(indexableUniqueId.GroupId)) { Delete(context, indexableUniqueId.GroupId, IndexingOptions.Default); } else { Delete(context, indexableUniqueId, IndexingOptions.Default); } } else { DoUpdate(context, indexableAndCheckDeletes, operationContext); } }
protected override void DoUpdate(IProviderUpdateContext context, SitecoreIndexableItem indexable, IndexEntryOperationContext operationContext) { Assert.ArgumentNotNull(context, "context"); Assert.ArgumentNotNull(indexable, "indexable"); using (new LanguageFallbackItemSwitcher(new bool?(Index.EnableItemLanguageFallback))) { if (IndexUpdateNeedDelete(indexable)) { Index.Locator.GetInstance <IEvent>().RaiseEvent("indexing:deleteitem", index.Name, indexable.UniqueId, indexable.AbsolutePath); Operations.Delete(indexable, context); } else { Index.Locator.GetInstance <IEvent>().RaiseEvent("indexing:updatingitem", index.Name, indexable.UniqueId, indexable.AbsolutePath); if (!IsExcludedFromIndex(indexable, true)) { if (operationContext != null && !operationContext.NeedUpdateAllVersions) { UpdateItemVersion(context, indexable, operationContext); } else { Language[] languageArray; if (operationContext == null || operationContext.NeedUpdateAllLanguages) { languageArray = indexable.Item.Languages; } else { languageArray = new Language[1] { indexable.Item.Language } }; foreach (var language in languageArray) { Item item; using (new WriteCachesDisabler()) item = indexable.Item.Database.GetItem(indexable.Item.ID, language, Sitecore.Data.Version.Latest); if (item == null) { CrawlingLog.Log.Warn(string.Format("SitecoreItemCrawler : Update : Latest version not found for item {0}. Skipping.", indexable.Item.Uri)); } else { Item[] versions; using (new SitecoreCachesDisabler()) versions = item.Versions.GetVersions(false); foreach (var version in versions) { UpdateItemVersion(context, version, operationContext); } } } } Index.Locator.GetInstance <IEvent>().RaiseEvent("indexing:updateditem", index.Name, indexable.UniqueId, indexable.AbsolutePath); } if (!DocumentOptions.ProcessDependencies) { return; } Index.Locator.GetInstance <IEvent>().RaiseEvent("indexing:updatedependents", index.Name, indexable.UniqueId, indexable.AbsolutePath); UpdateDependents(context, indexable); } } }
protected override void UpdateItemVersion(IProviderUpdateContext context, Item version, IndexEntryOperationContext operationContext) { IIndexable indexableItem = GetIndexable(version); this.Operations.Update((IIndexable)indexableItem, context, context.Index.Configuration); this.UpdateLanguageFallbackDependentItems(context, (SitecoreIndexableItem)indexableItem, operationContext); }