-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overrides the standard SitecoreItemCrawler to resolve issues with upd…
…ating index when additional system languages are used and the published item has a Shared field
- Loading branch information
1 parent
83ffa69
commit 24aa939
Showing
6 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25123.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{DF0AE779-F7B6-49C6-80D7-7EB3660C60D4}") = "Sitecore.Support.107730.107856", "Sitecore.Support.107730.107856\Sitecore.Support.107730.107856.csproj", "{1E8BAC09-FDB2-4A9F-95B1-6F94124E5E13}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1E8BAC09-FDB2-4A9F-95B1-6F94124E5E13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1E8BAC09-FDB2-4A9F-95B1-6F94124E5E13}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1E8BAC09-FDB2-4A9F-95B1-6F94124E5E13}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1E8BAC09-FDB2-4A9F-95B1-6F94124E5E13}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
6 changes: 6 additions & 0 deletions
6
src/Sitecore.Support.107730.107856/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("Sitecore.Support.107730.107856")] | ||
[assembly: AssemblyProduct("Sitecore.Support.107730.107856")] | ||
[assembly: ComVisible(false)] |
94 changes: 94 additions & 0 deletions
94
src/Sitecore.Support.107730.107856/Sitecore.Support.107730.107856.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion> | ||
</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{1E8BAC09-FDB2-4A9F-95B1-6F94124E5E13}</ProjectGuid> | ||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Sitecore.Support</RootNamespace> | ||
<AssemblyName>Sitecore.Support.107730.107856</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<UseIISExpress>true</UseIISExpress> | ||
<IISExpressSSLPort /> | ||
<IISExpressAnonymousAuthentication /> | ||
<IISExpressWindowsAuthentication /> | ||
<IISExpressUseClassicPipelineMode /> | ||
<UseGlobalApplicationHostFile /> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Sitecore.ContentSearch, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\SC.Sitecore.ContentSearch.8.1.1\lib\Sitecore.ContentSearch.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Sitecore.ContentSearch.Linq, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\SC.Sitecore.ContentSearch.Linq.8.1.1\lib\Sitecore.ContentSearch.Linq.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Sitecore.Kernel"> | ||
<HintPath>..\packages\SC.Sitecore.Kernel.8.1.1\lib\Sitecore.Kernel.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Configuration" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="SitecoreItemCrawler.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
<None Include="web.config" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" /> | ||
<ProjectExtensions> | ||
<VisualStudio> | ||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> | ||
<WebProjectProperties> | ||
<UseIIS>True</UseIIS> | ||
<AutoAssignPort>True</AutoAssignPort> | ||
<DevelopmentServerPort>0</DevelopmentServerPort> | ||
<DevelopmentServerVPath>/</DevelopmentServerVPath> | ||
<IISUrl>http://localhost:59678/</IISUrl> | ||
<NTLMAuthentication>False</NTLMAuthentication> | ||
<UseCustomServer>False</UseCustomServer> | ||
<CustomServerUrl> | ||
</CustomServerUrl> | ||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> | ||
</WebProjectProperties> | ||
</FlavorProperties> | ||
</VisualStudio> | ||
</ProjectExtensions> | ||
</Project> |
107 changes: 107 additions & 0 deletions
107
src/Sitecore.Support.107730.107856/SitecoreItemCrawler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using Sitecore.Collections; | ||
using Sitecore.Common; | ||
using Sitecore.Configuration; | ||
using Sitecore.ContentSearch; | ||
using Sitecore.ContentSearch.Diagnostics; | ||
using Sitecore.ContentSearch.Pipelines.GetContextIndex; | ||
using Sitecore.Data; | ||
using Sitecore.Data.Items; | ||
using Sitecore.Data.LanguageFallback; | ||
using Sitecore.Data.Managers; | ||
using Sitecore.Diagnostics; | ||
using Sitecore.Globalization; | ||
using Sitecore.SecurityModel; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Threading; | ||
|
||
namespace Sitecore.Support.ContentSearch | ||
{ | ||
public class SitecoreItemCrawler : Sitecore.ContentSearch.SitecoreItemCrawler | ||
{ | ||
public override void Update(IProviderUpdateContext context, IIndexableUniqueId indexableUniqueId, IndexEntryOperationContext operationContext, IndexingOptions indexingOptions = IndexingOptions.Default) | ||
{ | ||
Assert.ArgumentNotNull(indexableUniqueId, "indexableUniqueId"); | ||
if (!base.ShouldStartIndexing(indexingOptions)) | ||
{ | ||
return; | ||
} | ||
IDocumentBuilderOptions documentOptions = base.DocumentOptions; | ||
Assert.IsNotNull(documentOptions, "DocumentOptions"); | ||
if (this.IsExcludedFromIndex(indexableUniqueId, true)) | ||
{ | ||
return; | ||
} | ||
if (operationContext != null) | ||
{ | ||
if (operationContext.NeedUpdateChildren) | ||
{ | ||
Item item = Sitecore.Data.Database.GetItem(indexableUniqueId as SitecoreItemUniqueId); | ||
if (item != null) | ||
{ | ||
this.UpdateHierarchicalRecursive(context, item, CancellationToken.None); | ||
return; | ||
} | ||
} | ||
if (operationContext.NeedUpdatePreviousVersion) | ||
{ | ||
Item item2 = Sitecore.Data.Database.GetItem(indexableUniqueId as SitecoreItemUniqueId); | ||
if (item2 != null) | ||
{ | ||
this.UpdatePreviousVersion(item2, context); | ||
} | ||
} | ||
// Sitecore.Support.107730.107856 | ||
if (operationContext.NeedUpdateAllVersions) | ||
{ | ||
var item = Sitecore.Data.Database.GetItem(indexableUniqueId as SitecoreItemUniqueId); | ||
if (item != null) | ||
{ | ||
this.DoUpdate(context, item, operationContext); | ||
return; | ||
} | ||
} | ||
} | ||
SitecoreIndexableItem indexableAndCheckDeletes = this.GetIndexableAndCheckDeletes(indexableUniqueId); | ||
if (indexableAndCheckDeletes != null) | ||
{ | ||
this.DoUpdate(context, indexableAndCheckDeletes, operationContext); | ||
return; | ||
} | ||
if (this.GroupShouldBeDeleted(indexableUniqueId.GroupId)) | ||
{ | ||
this.Delete(context, indexableUniqueId.GroupId, IndexingOptions.Default); | ||
return; | ||
} | ||
this.Delete(context, indexableUniqueId, IndexingOptions.Default); | ||
} | ||
|
||
private void UpdatePreviousVersion(Item item, IProviderUpdateContext context) | ||
{ | ||
Sitecore.Data.Version[] array; | ||
using (new WriteCachesDisabler()) | ||
{ | ||
array = (item.Versions.GetVersionNumbers() ?? new Sitecore.Data.Version[0]); | ||
} | ||
int num = array.ToList<Sitecore.Data.Version>().FindIndex((Sitecore.Data.Version version) => version.Number == item.Version.Number); | ||
if (num < 1) | ||
{ | ||
return; | ||
} | ||
Sitecore.Data.Version previousVersion = array[num - 1]; | ||
Sitecore.Data.Version version2 = array.FirstOrDefault((Sitecore.Data.Version version) => version == previousVersion); | ||
ItemUri uri = new ItemUri(item.ID, item.Language, version2, item.Database.Name); | ||
Item item2 = Sitecore.Data.Database.GetItem(uri); | ||
SitecoreIndexableItem sitecoreIndexableItem = item2; | ||
if (sitecoreIndexableItem != null) | ||
{ | ||
IIndexableBuiltinFields indexableBuiltinFields = sitecoreIndexableItem; | ||
indexableBuiltinFields.IsLatestVersion = false; | ||
sitecoreIndexableItem.IndexFieldStorageValueFormatter = context.Index.Configuration.IndexFieldStorageValueFormatter; | ||
base.Operations.Update(sitecoreIndexableItem, context, this.index.Configuration); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="SC.Sitecore.ContentSearch" version="8.1.1" targetFramework="net45" /> | ||
<package id="SC.Sitecore.ContentSearch.Linq" version="8.1.1" targetFramework="net45" /> | ||
<package id="SC.Sitecore.Kernel" version="8.1.1" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<!-- Do not change this file - it must be empty, see https://github.com/SitecoreSupport/PatchCreator/issues/13 --> | ||
</configuration> |