diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs b/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs
index 1c0d39a8b8..d3a87ef3e0 100644
--- a/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs
+++ b/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs
@@ -60,11 +60,6 @@ namespace Umbraco.Core.Models.PublishedContent
///
int CreatorId { get; }
- ///
- /// Gets the name of the user who created the content item.
- ///
- string CreatorName { get; }
-
///
/// Gets the date the content item was created.
///
@@ -75,11 +70,6 @@ namespace Umbraco.Core.Models.PublishedContent
///
int WriterId { get; }
- ///
- /// Gets the name of the user who last updated the content item.
- ///
- string WriterName { get; }
-
///
/// Gets the date the content item was last updated.
///
diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs
index 6c6c9c4cc7..2aaffbe798 100644
--- a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs
+++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs
@@ -60,18 +60,12 @@ namespace Umbraco.Web.Models
///
public abstract int CreatorId { get; }
- ///
- public abstract string CreatorName { get; }
-
///
public abstract DateTime CreateDate { get; }
///
public abstract int WriterId { get; }
- ///
- public abstract string WriterName { get; }
-
///
public abstract DateTime UpdateDate { get; }
diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs
index fb41c95419..7e6c730a02 100644
--- a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs
+++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs
@@ -78,18 +78,12 @@ namespace Umbraco.Core.Models.PublishedContent
///
public virtual int CreatorId => _content.CreatorId;
- ///
- public virtual string CreatorName => _content.CreatorName;
-
///
public virtual DateTime CreateDate => _content.CreateDate;
///
public virtual int WriterId => _content.WriterId;
- ///
- public virtual string WriterName => _content.WriterName;
-
///
public virtual DateTime UpdateDate => _content.UpdateDate;
diff --git a/src/Umbraco.Abstractions/PublishedContentExtensions.cs b/src/Umbraco.Abstractions/PublishedContentExtensions.cs
index 5242fdfd67..11444a274b 100644
--- a/src/Umbraco.Abstractions/PublishedContentExtensions.cs
+++ b/src/Umbraco.Abstractions/PublishedContentExtensions.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.Models.PublishedContent;
+using Umbraco.Core.Services;
namespace Umbraco.Core
{
@@ -135,5 +136,17 @@ namespace Umbraco.Core
? children
: children.Where(x => x.IsInvariantOrHasCulture(culture));
}
+
+ public static string GetCreatorName(this IPublishedContent content, IUserService userService)
+ {
+ var user = userService.GetProfileById(content.CreatorId);
+ return user?.Name;
+ }
+
+ public static string GetWriterName(this IPublishedContent content, IUserService userService)
+ {
+ var user = userService.GetProfileById(content.WriterId);
+ return user?.Name;
+ }
}
}
diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs
index f9c6678343..f60e2e1e99 100644
--- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs
+++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs
@@ -147,18 +147,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
///
public override int CreatorId => _contentNode.CreatorId;
- ///
- public override string CreatorName => string.Empty; // TODO: remove (as want to avoid injecting user service to get these names)
-
///
public override DateTime CreateDate => _contentNode.CreateDate;
///
public override int WriterId => ContentData.WriterId;
- ///
- public override string WriterName => string.Empty; // TODO: remove (as want to avoid injecting user service to get these names)
-
///
public override DateTime UpdateDate => ContentData.VersionDate;
diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs
index f4293b3dfb..bd84e4a9d2 100644
--- a/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs
+++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs
@@ -141,10 +141,6 @@ namespace Umbraco.Web.PublishedCache
public override string UrlSegment => throw new NotSupportedException();
- public override string WriterName => _member.GetCreatorProfile(_userService).Name;
-
- public override string CreatorName => _member.GetCreatorProfile(_userService).Name;
-
public override int WriterId => _member.CreatorId;
public override int CreatorId => _member.CreatorId;
diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
index 36ac57728e..6be417e484 100644
--- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
+++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs
@@ -25,6 +25,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
public class PublishMediaCacheTests : BaseWebTest
{
private Dictionary _mediaTypes;
+ private int _testWriterAndCreatorId;
private IUmbracoContextAccessor _umbracoContextAccessor;
protected override void Compose()
@@ -51,6 +52,8 @@ namespace Umbraco.Tests.Cache.PublishedCache
{ testMediaType.Alias, testMediaType }
};
ContentTypesCache.GetPublishedContentTypeByAlias = alias => _mediaTypes[alias];
+
+ _testWriterAndCreatorId = ServiceContext.UserService.CreateUserWithIdentity("Shannon", "test").Id;
}
private IMediaType MakeNewMediaType(IUser user, string text, int parentId = -1)
@@ -201,7 +204,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
{"path", "-1,1234"},
{"updateDate", DateTime.Parse("2012-07-16T10:34:09").Ticks.ToString()},
{"createDate", DateTime.Parse("2012-07-17T10:34:09").Ticks.ToString()},
- {"creatorID", "0"},
+ {"creatorID", _testWriterAndCreatorId.ToString()},
{"creatorName", "Shannon"}
};
@@ -210,7 +213,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var store = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor);
var doc = store.CreateFromCacheValues(store.ConvertFromSearchResult(result));
- DoAssert(doc, 1234, key, null, 0, "/media/test.jpg", "Image", 23, "Shannon", "Shannon", 0, 0, "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2);
+ DoAssert(doc, 1234, key, null, 0, "/media/test.jpg", "Image", 23, "Shannon", "Shannon", "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2);
Assert.AreEqual(null, doc.Parent);
}
@@ -226,7 +229,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(),VariationContextAccessor);
var doc = cache.CreateFromCacheValues(cache.ConvertFromXPathNavigator(navigator, true));
- DoAssert(doc, 2000, key, null, 2, "image1", "Image", 23, "Shannon", "Shannon", 33, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1);
+ DoAssert(doc, 2000, key, null, 2, "image1", "Image", 23, "Shannon", "Shannon", "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1);
Assert.AreEqual(null, doc.Parent);
Assert.AreEqual(2, doc.Children.Count());
Assert.AreEqual(2001, doc.Children.ElementAt(0).Id);
@@ -243,16 +246,18 @@ namespace Umbraco.Tests.Cache.PublishedCache
]>
-
+
-
+
-
+
";
+ xml = xml.Replace("[WriterId]", _testWriterAndCreatorId.ToString());
+ xml = xml.Replace("[CreatorId]", _testWriterAndCreatorId.ToString());
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
@@ -279,10 +284,8 @@ namespace Umbraco.Tests.Cache.PublishedCache
{"urlName", "testing"},
{nodeTypeAliasKey, "myType"},
{"nodeType", "22"},
- {"writerName", "Shannon"},
- {"creatorName", "Shannon"},
- {"writerID", "33"},
- {"creatorID", "33"},
+ {"writerID", _testWriterAndCreatorId.ToString()},
+ {"creatorID", _testWriterAndCreatorId.ToString()},
{pathKey, "1,2,3,4,5"},
{"createDate", "2012-01-02"},
{"updateDate", "2012-01-02"},
@@ -349,8 +352,6 @@ namespace Umbraco.Tests.Cache.PublishedCache
int nodeTypeIdVal = 22,
string writerNameVal = "Shannon",
string creatorNameVal = "Shannon",
- int writerIdVal = 33,
- int creatorIdVal = 33,
string pathVal = "1,2,3,4,5",
DateTime? createDateVal = null,
DateTime? updateDateVal = null,
@@ -363,7 +364,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
updateDateVal = DateTime.Parse("2012-01-02");
DoAssert((IPublishedContent)dicDoc, idVal, keyVal, templateIdVal, sortOrderVal, urlNameVal, nodeTypeAliasVal, nodeTypeIdVal, writerNameVal,
- creatorNameVal, writerIdVal, creatorIdVal, pathVal, createDateVal, updateDateVal, levelVal);
+ creatorNameVal, pathVal, createDateVal, updateDateVal, levelVal);
//now validate the parentId that has been parsed, this doesn't exist on the IPublishedContent
Assert.AreEqual(parentIdVal, dicDoc.ParentId);
@@ -380,8 +381,6 @@ namespace Umbraco.Tests.Cache.PublishedCache
int nodeTypeIdVal = 22,
string writerNameVal = "Shannon",
string creatorNameVal = "Shannon",
- int writerIdVal = 33,
- int creatorIdVal = 33,
string pathVal = "1,2,3,4,5",
DateTime? createDateVal = null,
DateTime? updateDateVal = null,
@@ -399,10 +398,10 @@ namespace Umbraco.Tests.Cache.PublishedCache
Assert.AreEqual(urlNameVal, doc.UrlSegment);
Assert.AreEqual(nodeTypeAliasVal, doc.ContentType.Alias);
Assert.AreEqual(nodeTypeIdVal, doc.ContentType.Id);
- Assert.AreEqual(writerNameVal, doc.WriterName);
- Assert.AreEqual(creatorNameVal, doc.CreatorName);
- Assert.AreEqual(writerIdVal, doc.WriterId);
- Assert.AreEqual(creatorIdVal, doc.CreatorId);
+ Assert.AreEqual(writerNameVal, doc.GetWriterName(ServiceContext.UserService));
+ Assert.AreEqual(creatorNameVal, doc.GetCreatorName(ServiceContext.UserService));
+ Assert.AreEqual(_testWriterAndCreatorId, doc.WriterId);
+ Assert.AreEqual(_testWriterAndCreatorId, doc.CreatorId);
Assert.AreEqual(pathVal, doc.Path);
Assert.AreEqual(createDateVal.Value, doc.CreateDate);
Assert.AreEqual(updateDateVal.Value, doc.UpdateDate);
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
index 31fbb8d6b9..11b1f1c049 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs
@@ -61,8 +61,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
ValidateAndSetProperty(valueDictionary, val => _urlName = val, "urlName");
ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", LuceneIndex.ItemTypeFieldName);
ValidateAndSetProperty(valueDictionary, val => _documentTypeId = Int32.Parse(val), "nodeType");
- //ValidateAndSetProperty(valueDictionary, val => _writerName = val, "writerName");
- ValidateAndSetProperty(valueDictionary, val => _creatorName = val, "creatorName", "writerName"); //this is a bit of a hack fix for: U4-1132
//ValidateAndSetProperty(valueDictionary, val => _writerId = int.Parse(val), "writerID");
ValidateAndSetProperty(valueDictionary, val => _creatorId = Int32.Parse(val), "creatorID", "writerID"); //this is a bit of a hack fix for: U4-1132
ValidateAndSetProperty(valueDictionary, val => _path = val, "path", "__Path");
@@ -161,10 +159,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
public override string UrlSegment => _urlName;
- public override string WriterName => _creatorName;
-
- public override string CreatorName => _creatorName;
-
public override int WriterId => _creatorId;
public override int CreatorId => _creatorId;
@@ -203,8 +197,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private string _urlName;
private string _documentTypeAlias;
private int _documentTypeId;
- //private string _writerName;
- private string _creatorName;
//private int _writerId;
private int _creatorId;
private string _path;
diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
index 03f897b0cc..4d6f57f490 100644
--- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
+++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs
@@ -61,8 +61,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private string _name;
private string _docTypeAlias;
private int _docTypeId;
- private string _writerName;
- private string _creatorName;
private int _writerId;
private int _creatorId;
private string _urlName;
@@ -158,24 +156,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
public override IReadOnlyDictionary Cultures => _cultures ?? (_cultures = GetCultures());
- public override string WriterName
- {
- get
- {
- EnsureNodeInitialized();
- return _writerName;
- }
- }
-
- public override string CreatorName
- {
- get
- {
- EnsureNodeInitialized();
- return _creatorName;
- }
- }
-
public override int WriterId
{
get
@@ -301,8 +281,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
private void InitializeNode()
{
InitializeNode(this, _xmlNode, _isPreviewing,
- out _id, out _key, out _template, out _sortOrder, out _name, out _writerName,
- out _urlName, out _creatorName, out _creatorId, out _writerId, out _docTypeAlias, out _docTypeId, out _path,
+ out _id, out _key, out _template, out _sortOrder, out _name,
+ out _urlName, out _creatorId, out _writerId, out _docTypeAlias, out _docTypeId, out _path,
out _createDate, out _updateDate, out _level, out _isDraft, out _contentType, out _properties,
_contentTypeCache.Get);
@@ -311,18 +291,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
// internal for some benchmarks
internal static void InitializeNode(XmlPublishedContent node, XmlNode xmlNode, bool isPreviewing,
- out int id, out Guid key, out int template, out int sortOrder, out string name, out string writerName, out string urlName,
- out string creatorName, out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path,
+ out int id, out Guid key, out int template, out int sortOrder, out string name, out string urlName,
+ out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path,
out DateTime createDate, out DateTime updateDate, out int level, out bool isDraft,
out IPublishedContentType contentType, out Dictionary properties,
Func getPublishedContentType)
{
//initialize the out params with defaults:
- writerName = null;
docTypeAlias = null;
id = template = sortOrder = template = creatorId = writerId = docTypeId = level = default(int);
key = default(Guid);
- name = writerName = urlName = creatorName = docTypeAlias = path = null;
+ name = docTypeAlias = urlName = path = null;
createDate = updateDate = default(DateTime);
isDraft = false;
contentType = null;
@@ -341,12 +320,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache
sortOrder = int.Parse(xmlNode.Attributes.GetNamedItem("sortOrder").Value);
if (xmlNode.Attributes.GetNamedItem("nodeName") != null)
name = xmlNode.Attributes.GetNamedItem("nodeName").Value;
- if (xmlNode.Attributes.GetNamedItem("writerName") != null)
- writerName = xmlNode.Attributes.GetNamedItem("writerName").Value;
if (xmlNode.Attributes.GetNamedItem("urlName") != null)
urlName = xmlNode.Attributes.GetNamedItem("urlName").Value;
- if (xmlNode.Attributes.GetNamedItem("creatorName") != null)
- creatorName = xmlNode.Attributes.GetNamedItem("creatorName").Value;
//Added the actual userID, as a user cannot be looked up via full name only...
if (xmlNode.Attributes.GetNamedItem("creatorID") != null)
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs
index 0685e2c679..d35cc941da 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs
@@ -52,8 +52,8 @@ namespace Umbraco.Tests.PublishedContent
{"NodeTypeAlias", "NodeTypeAlias"},
{"CreateDate", "CreateDate"},
{"UpdateDate", "UpdateDate"},
- {"CreatorName", "CreatorName"},
- {"WriterName", "WriterName"},
+ {"CreatorId", "CreatorId"},
+ {"WriterId", "WriterId"},
{"Url", "Url"}
};
foreach (var f in userFields.Where(f => !allFields.ContainsKey(f.Key)))
@@ -135,7 +135,6 @@ namespace Umbraco.Tests.PublishedContent
{
CreateDate = DateTime.Now,
CreatorId = 1,
- CreatorName = "Shannon",
Id = 3,
SortOrder = 4,
TemplateId = 5,
@@ -145,7 +144,6 @@ namespace Umbraco.Tests.PublishedContent
Name = "Page" + Guid.NewGuid(),
Version = Guid.NewGuid(),
WriterId = 1,
- WriterName = "Shannon",
Parent = null,
Level = 1,
Children = new List()
diff --git a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs
index d8dbabb569..f8f7ddae75 100644
--- a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs
+++ b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs
@@ -59,8 +59,6 @@ namespace Umbraco.Tests.PublishedContent
var pc = new Mock();
pc.Setup(content => content.Id).Returns(1);
pc.Setup(content => content.Name).Returns("test");
- pc.Setup(content => content.WriterName).Returns("admin");
- pc.Setup(content => content.CreatorName).Returns("admin");
pc.Setup(content => content.CreateDate).Returns(DateTime.Now);
pc.Setup(content => content.UpdateDate).Returns(DateTime.Now);
pc.Setup(content => content.Path).Returns("-1,1");
diff --git a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs
index 713acaa5dc..ac550ed75a 100644
--- a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs
+++ b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs
@@ -167,7 +167,6 @@ namespace Umbraco.Tests.PublishedContent
{
// initialize boring stuff
TemplateId = 0;
- WriterName = CreatorName = string.Empty;
WriterId = CreatorId = 0;
CreateDate = UpdateDate = DateTime.Now;
Version = Guid.Empty;
@@ -193,8 +192,6 @@ namespace Umbraco.Tests.PublishedContent
public string Name { get; set; }
public IReadOnlyDictionary Cultures => _cultures ?? (_cultures = GetCultures());
public string UrlSegment { get; set; }
- public string WriterName { get; set; }
- public string CreatorName { get; set; }
public int WriterId { get; set; }
public int CreatorId { get; set; }
public string Path { get; set; }
diff --git a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
index 077ed80efa..176664b467 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs
@@ -101,7 +101,8 @@ namespace Umbraco.Tests.TestHelpers
new TestVariationContextAccessor(),
container?.TryGetInstance() ?? ServiceContext.CreatePartial(),
new ProfilingLogger(Mock.Of(), Mock.Of()),
- container?.TryGetInstance() ?? Current.Factory.GetInstance());
+ container?.TryGetInstance() ?? Current.Factory.GetInstance(),
+ Mock.Of());
}
}
}
diff --git a/src/Umbraco.Web/Macros/MacroRenderer.cs b/src/Umbraco.Web/Macros/MacroRenderer.cs
index 1b5f907205..d331dfc65f 100755
--- a/src/Umbraco.Web/Macros/MacroRenderer.cs
+++ b/src/Umbraco.Web/Macros/MacroRenderer.cs
@@ -26,8 +26,9 @@ namespace Umbraco.Web.Macros
private readonly ILocalizedTextService _textService;
private readonly AppCaches _appCaches;
private readonly IMacroService _macroService;
+ private readonly IUserService _userService;
- public MacroRenderer(IProfilingLogger plogger, IUmbracoContextAccessor umbracoContextAccessor, IContentSection contentSection, ILocalizedTextService textService, AppCaches appCaches, IMacroService macroService)
+ public MacroRenderer(IProfilingLogger plogger, IUmbracoContextAccessor umbracoContextAccessor, IContentSection contentSection, ILocalizedTextService textService, AppCaches appCaches, IMacroService macroService, IUserService userService)
{
_plogger = plogger ?? throw new ArgumentNullException(nameof(plogger));
_umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
@@ -35,6 +36,7 @@ namespace Umbraco.Web.Macros
_textService = textService;
_appCaches = appCaches ?? throw new ArgumentNullException(nameof(appCaches));
_macroService = macroService ?? throw new ArgumentNullException(nameof(macroService));
+ _userService = userService ?? throw new ArgumentNullException(nameof(userService));
}
#region MacroContent cache
@@ -201,7 +203,7 @@ namespace Umbraco.Web.Macros
if (m == null)
throw new InvalidOperationException("No macro found by alias " + macroAlias);
- var page = new PublishedContentHashtableConverter(content);
+ var page = new PublishedContentHashtableConverter(content, _userService);
var macro = new MacroModel(m);
diff --git a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs
index be284c1bb3..5e921eb7c2 100644
--- a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs
+++ b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs
@@ -25,19 +25,20 @@ namespace Umbraco.Web.Macros
/// Initializes a new instance of the class for a published document request.
///
/// The pointing to the document.
+ /// The .
///
/// The difference between creating the page with PublishedRequest vs an IPublishedContent item is
/// that the PublishedRequest takes into account how a template is assigned during the routing process whereas
/// with an IPublishedContent item, the template id is assigned purely based on the default.
///
- internal PublishedContentHashtableConverter(PublishedRequest frequest)
+ internal PublishedContentHashtableConverter(PublishedRequest frequest, IUserService userService)
{
if (!frequest.HasPublishedContent)
throw new ArgumentException("Document request has no node.", nameof(frequest));
PopulatePageData(frequest.PublishedContent.Id,
frequest.PublishedContent.Name, frequest.PublishedContent.ContentType.Id, frequest.PublishedContent.ContentType.Alias,
- frequest.PublishedContent.WriterName, frequest.PublishedContent.CreatorName, frequest.PublishedContent.CreateDate, frequest.PublishedContent.UpdateDate,
+ frequest.PublishedContent.GetWriterName(userService), frequest.PublishedContent.GetCreatorName(userService), frequest.PublishedContent.CreateDate, frequest.PublishedContent.UpdateDate,
frequest.PublishedContent.Path, frequest.PublishedContent.Parent?.Id ?? -1);
if (frequest.HasTemplate)
@@ -53,13 +54,13 @@ namespace Umbraco.Web.Macros
/// Initializes a new instance of the page for a published document
///
///
- internal PublishedContentHashtableConverter(IPublishedContent doc)
+ internal PublishedContentHashtableConverter(IPublishedContent doc, IUserService userService)
{
if (doc == null) throw new ArgumentNullException(nameof(doc));
PopulatePageData(doc.Id,
doc.Name, doc.ContentType.Id, doc.ContentType.Alias,
- doc.WriterName, doc.CreatorName, doc.CreateDate, doc.UpdateDate,
+ doc.GetWriterName(userService), doc.GetCreatorName(userService), doc.CreateDate, doc.UpdateDate,
doc.Path, doc.Parent?.Id ?? -1);
if (doc.TemplateId.HasValue)
@@ -78,7 +79,7 @@ namespace Umbraco.Web.Macros
///
/// This is for usage only.
internal PublishedContentHashtableConverter(IContent content, IVariationContextAccessor variationContextAccessor, IUserService userService, IShortStringHelper shortStringHelper, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IPublishedContentTypeFactory publishedContentTypeFactory, UrlSegmentProviderCollection urlSegmentProviders)
- : this(new PagePublishedContent(content, variationContextAccessor, userService, shortStringHelper, contentTypeBaseServiceProvider, publishedContentTypeFactory, urlSegmentProviders))
+ : this(new PagePublishedContent(content, variationContextAccessor, userService, shortStringHelper, contentTypeBaseServiceProvider, publishedContentTypeFactory, urlSegmentProviders), userService)
{ }
#endregion
diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs
index d02e5a3197..0eaabe0ff6 100644
--- a/src/Umbraco.Web/PublishedContentExtensions.cs
+++ b/src/Umbraco.Web/PublishedContentExtensions.cs
@@ -1000,15 +1000,15 @@ namespace Umbraco.Web
var standardVals = new Dictionary
{
- { "Id", n.Id },
- { "NodeName", n.Name(VariationContextAccessor) },
- { "NodeTypeAlias", n.ContentType.Alias },
- { "CreateDate", n.CreateDate },
- { "UpdateDate", n.UpdateDate },
- { "CreatorName", n.CreatorName },
- { "WriterName", n.WriterName },
- { "Url", n.Url() }
- };
+ { "Id", n.Id },
+ { "NodeName", n.Name(VariationContextAccessor) },
+ { "NodeTypeAlias", n.ContentType.Alias },
+ { "CreateDate", n.CreateDate },
+ { "UpdateDate", n.UpdateDate },
+ { "CreatorId", n.CreatorId},
+ { "WriterId", n.WriterId },
+ { "Url", n.Url() }
+ };
var userVals = new Dictionary();
foreach (var p in from IPublishedProperty p in n.Properties where p.GetSourceValue() != null select p)
diff --git a/src/Umbraco.Web/Routing/PublishedRouter.cs b/src/Umbraco.Web/Routing/PublishedRouter.cs
index 6f146b35dd..9148ce2e31 100644
--- a/src/Umbraco.Web/Routing/PublishedRouter.cs
+++ b/src/Umbraco.Web/Routing/PublishedRouter.cs
@@ -28,6 +28,7 @@ namespace Umbraco.Web.Routing
private readonly IVariationContextAccessor _variationContextAccessor;
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _umbracoSettingsSection;
+ private readonly IUserService _userService;
///
/// Initializes a new instance of the class.
@@ -39,7 +40,8 @@ namespace Umbraco.Web.Routing
IVariationContextAccessor variationContextAccessor,
ServiceContext services,
IProfilingLogger proflog,
- IUmbracoSettingsSection umbracoSettingsSection)
+ IUmbracoSettingsSection umbracoSettingsSection,
+ IUserService userService)
{
_webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection));
_contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders));
@@ -49,6 +51,7 @@ namespace Umbraco.Web.Routing
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
_logger = proflog;
_umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection));
+ _userService = userService ?? throw new ArgumentNullException(nameof(userService));
}
///
@@ -194,7 +197,7 @@ namespace Umbraco.Web.Routing
// assign the legacy page back to the request
// handlers like default.aspx will want it and most macros currently need it
- frequest.LegacyContentHashTable = new PublishedContentHashtableConverter(frequest);
+ frequest.LegacyContentHashTable = new PublishedContentHashtableConverter(frequest, _userService);
return true;
}
@@ -234,8 +237,7 @@ namespace Umbraco.Web.Routing
// assign the legacy page back to the docrequest
// handlers like default.aspx will want it and most macros currently need it
- request.LegacyContentHashTable = new PublishedContentHashtableConverter(request);
-
+ request.LegacyContentHashTable = new PublishedContentHashtableConverter(request, _userService);
}
#endregion