Ensures the right type is tracked for links ensures relations are removed.
This commit is contained in:
@@ -358,6 +358,15 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
public const string RelateParentMediaFolderOnDeleteAlias = "relateParentMediaFolderOnDelete";
|
||||
|
||||
/// <summary>
|
||||
/// Returns the types of relations that are automatically tracked
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Developers should not manually use these relation types since they will all be cleared whenever an entity
|
||||
/// (content, media or member) is saved since they are auto-populated based on property values.
|
||||
/// </remarks>
|
||||
public static string[] AutomaticRelationTypes = new[] { RelatedMediaAlias, RelatedDocumentAlias };
|
||||
|
||||
//TODO: return a list of built in types so we can use that to prevent deletion in the uI
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,11 +837,10 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
trackedRelations.AddRange(refs);
|
||||
}
|
||||
|
||||
if (trackedRelations.Count == 0) return;
|
||||
//First delete all auto-relations for this entity
|
||||
RelationRepository.DeleteByParent(entity.Id, Constants.Conventions.RelationTypes.AutomaticRelationTypes);
|
||||
|
||||
//First delete all relations for this entity
|
||||
var relationTypes = trackedRelations.Select(x => x.RelationTypeAlias).ToArray();
|
||||
RelationRepository.DeleteByParent(entity.Id, relationTypes);
|
||||
if (trackedRelations.Count == 0) return;
|
||||
|
||||
var udiToGuids = trackedRelations.Select(x => x.Udi as GuidUdi)
|
||||
.ToDictionary(x => (Udi)x, x => x.Guid);
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
yield return new UmbracoEntityReference(udi, Constants.Conventions.RelationTypes.RelatedMediaAlias);
|
||||
|
||||
foreach (var udi in _localLinkParser.FindUdisFromLocalLinks(asString))
|
||||
yield return new UmbracoEntityReference(udi, Constants.Conventions.RelationTypes.RelatedMediaAlias);
|
||||
yield return new UmbracoEntityReference(udi, Constants.Conventions.RelationTypes.RelatedDocumentAlias);
|
||||
|
||||
//TODO: Detect Macros too ... but we can save that for a later date, right now need to do media refs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user