88599: BUGFIX: Opposite side needs to be latest in order to set own side to non-latest

Otherwise an error occurs
This commit is contained in:
Bruno Roemers
2022-04-08 01:12:11 +02:00
parent b9c1f90ab8
commit ef87d0cbf5

View File

@@ -226,17 +226,23 @@ public class VersioningConsumer implements Consumer {
Relationship latestItemRelationship = Relationship latestItemRelationship =
getMatchingRelationship(latestItem, isLeft, previousItemRelationship, latestItemRelationships); getMatchingRelationship(latestItem, isLeft, previousItemRelationship, latestItemRelationships);
// the other side of the relationship should be "latest", otherwise the relationship could not have been
// copied to the new item in the first place (by DefaultVersionProvider#copyRelationships)
if (relationshipVersioningUtils.otherSideIsLatest(
isLeft, previousItemRelationship.getLatestVersionStatus())
) {
// Set the previous version of the item to non-latest. This implies that the previous version // Set the previous version of the item to non-latest. This implies that the previous version
// of the item will not be shown anymore on the page of the third-party item. That makes sense, // of the item will not be shown anymore on the page of the third-party item. That makes sense,
// because either the relationship has been deleted from the new version of the item (no match), // because either the relationship has been deleted from the new version of the item (no match),
// or the matching relationship (linked to new version) will receive "latest" status in the next step. // or the matching relationship (linked to new version) will receive "latest" status in the next step.
relationshipVersioningUtils.updateLatestVersionStatus(previousItemRelationship, isLeft, false); relationshipVersioningUtils.updateLatestVersionStatus(previousItemRelationship, isLeft, false);
}
if (latestItemRelationship != null) {
// Set the new version of the item to latest if the relevant relationship exists (match found). // Set the new version of the item to latest if the relevant relationship exists (match found).
// This implies that the new version of the item will appear on the page of the third-party item. // This implies that the new version of the item will appear on the page of the third-party item.
// The old version of the item will not appear anymore on the page of the third-party item, // The old version of the item will not appear anymore on the page of the third-party item,
// see previous step. // see previous step.
if (latestItemRelationship != null) {
relationshipVersioningUtils.updateLatestVersionStatus(latestItemRelationship, isLeft, true); relationshipVersioningUtils.updateLatestVersionStatus(latestItemRelationship, isLeft, true);
} }
} }