Skip to content

Commit

Permalink
Bug 79099: The Search Index disappear when a new version of the root …
Browse files Browse the repository at this point in the history
…page is published. (#839)
  • Loading branch information
neexite authored Jul 26, 2024
1 parent 0711192 commit 67a38c4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
25 changes: 22 additions & 3 deletions Composite/Data/Types/PageServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,15 @@ public static void AddPageTypeRelatedData(IPage page)
/// <summary>
/// Deletes the versions of the given page in its current localization scope.
/// </summary>
public static void DeletePage(IPage page, bool deleteChildPages = true)
public static void DeletePage(IPage page)
{
DeletePage(page, true);
}

/// <summary>
/// Deletes the versions of the given page in its current localization scope.
/// </summary>
public static void DeletePage(IPage page, bool deleteChildPages)
{
using (var transactionScope = TransactionsFacade.CreateNewScope())
{
Expand Down Expand Up @@ -644,8 +652,19 @@ private static void RemoveAllFolderAndMetaDataDefinitions(IPage page)
/// <param name="pageId"></param>
/// <param name="versionId"></param>
/// <param name="locale"></param>
/// <param name="deleteChildPages">default is true</param>
public static void DeletePage(Guid pageId, Guid versionId, CultureInfo locale, bool deleteChildPages = true)
public static void DeletePage(Guid pageId, Guid versionId, CultureInfo locale)
{
DeletePage(pageId, versionId, locale, true);
}

/// <summary>
/// Delete the specific version of the page in the current localization scope.
/// </summary>
/// <param name="pageId"></param>
/// <param name="versionId"></param>
/// <param name="locale"></param>
/// <param name="deleteChildPages"></param>
public static void DeletePage(Guid pageId, Guid versionId, CultureInfo locale, bool deleteChildPages)
{
Verify.ArgumentNotNull(locale, nameof(locale));

Expand Down
19 changes: 17 additions & 2 deletions Composite/Search/Crawling/SearchDocumentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,23 @@ private void AddAccessField(EntityToken entityToken)

internal static string GetEntityTokenHash(EntityToken entityToken)
{
var entityTokenString = EntityTokenSerializer.Serialize(entityToken);
var md5Hash = HashingHelper.ComputeMD5Hash(entityTokenString, Encoding.UTF8);
var token = new StringBuilder();
if (entityToken is DataEntityToken dataEntityToken && typeof(IVersioned).IsAssignableFrom(dataEntityToken.InterfaceType))
{
var dataSourceId = dataEntityToken.DataSourceId;
// Serialize without versionId
token.Append(dataEntityToken.Id);
token.Append(':');
token.Append(dataSourceId.LocaleScope);
token.Append(":");
token.Append(dataSourceId.DataScopeIdentifier);
}
else
{
token.Append(EntityTokenSerializer.Serialize(entityToken));
}

var md5Hash = HashingHelper.ComputeMD5Hash(token.ToString(), Encoding.UTF8);

return UrlUtils.CompressGuid(md5Hash);
}
Expand Down

0 comments on commit 67a38c4

Please sign in to comment.