From 48383f2e7a154efd6b72c620a62b2421511e31dc Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 18 Nov 2015 16:04:01 +0100 Subject: [PATCH] updaes null check and ensures the path isn't pre-set in the withidentity overload --- src/Umbraco.Core/Services/ContentService.cs | 3 ++- src/Umbraco.Core/Services/MediaService.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 8427a46d75..7599001618 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -282,9 +282,10 @@ namespace Umbraco.Core.Services /// public IContent CreateContentWithIdentity(string name, IContent parent, string contentTypeAlias, int userId = 0) { + if (parent == null) throw new ArgumentNullException("parent"); + var contentType = FindContentTypeByAlias(contentTypeAlias); var content = new Content(name, parent, contentType); - content.Path = string.Concat(parent.Path, ",", content.Id); //NOTE: I really hate the notion of these Creating/Created events - they are so inconsistent, I've only just found // out that in these 'WithIdentity' methods, the Saving/Saved events were not fired, wtf. Anyways, they're added now. diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs index f4755f281d..0788044734 100644 --- a/src/Umbraco.Core/Services/MediaService.cs +++ b/src/Umbraco.Core/Services/MediaService.cs @@ -190,9 +190,10 @@ namespace Umbraco.Core.Services /// public IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = 0) { + if (parent == null) throw new ArgumentNullException("parent"); + var mediaType = FindMediaTypeByAlias(mediaTypeAlias); var media = new Models.Media(name, parent, mediaType); - media.Path = string.Concat(parent.Path, ",", media.Id); //NOTE: I really hate the notion of these Creating/Created events - they are so inconsistent, I've only just found // out that in these 'WithIdentity' methods, the Saving/Saved events were not fired, wtf. Anyways, they're added now.