Skip to content

Commit

Permalink
Multiple referenced pages fix. This is feels like a hack though. Save…
Browse files Browse the repository at this point in the history
…Action.ForceCurrentVersion creates and endless loop when updating content in the PublishingContent event, which it probably shouldn't
  • Loading branch information
jstemerdink committed Sep 8, 2017
1 parent 0fe0668 commit 25c614e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions SearchInitialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class SearchInitialization : IInitializableModule
/// <summary>
/// The parent update triggered
/// </summary>
private bool parentUpdateTriggered;
private int parentId;

/// <summary>
/// Gets or sets the logger
Expand Down Expand Up @@ -123,6 +123,9 @@ public void OnPublishedContent(object sender, ContentEventArgs contentEventArgs)
return;
}

// Reset the pageId currently updating.
this.parentId = 0;

// Check if the content that is published is indeed a block.
BlockData blockData = contentEventArgs.Content as BlockData;

Expand Down Expand Up @@ -156,8 +159,8 @@ public void OnPublishingContent(object sender, ContentEventArgs contentEventArgs
return;
}

// If a SaveAction.ForceCurrentVersion is triggered on the page itself, publishing content is triggered only once. When initiated from somewhere else, it goed into an endless loop.
if (this.parentUpdateTriggered)
// If a SaveAction.ForceCurrentVersion is triggered it goes into an endless loop.
if (this.parentId != 0 && this.parentId == contentEventArgs.ContentLink.ID)
{
return;
}
Expand Down Expand Up @@ -299,7 +302,8 @@ where typeof(PropertyContentArea).IsAssignableFrom(c: d.Type.DefinitionType)
PageData editablePage = parent.CreateWritableClone();
editablePage[index: addtionalSearchContentProperty.Name] = additionalSearchContent;

this.parentUpdateTriggered = true;
// Set the pageId currently updating
this.parentId = parent.ContentLink.ID;

this.ContentRepository.Save(
content: editablePage,
Expand Down

0 comments on commit 25c614e

Please sign in to comment.