From 0d68a3fb4f5043dbcf8cb709220ec8e973cb3336 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 31 May 2018 15:54:23 +1000 Subject: [PATCH] avoids a ysod if the wrong user id sneaks in to the log --- src/Umbraco.Web/Editors/LogController.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/Editors/LogController.cs b/src/Umbraco.Web/Editors/LogController.cs index 30c2a33ff1..08a21a9364 100644 --- a/src/Umbraco.Web/Editors/LogController.cs +++ b/src/Umbraco.Web/Editors/LogController.cs @@ -83,13 +83,21 @@ namespace Umbraco.Web.Editors private IEnumerable MapAvatarsAndNames(IEnumerable items) { var userIds = items.Select(x => x.UserId).ToArray(); - var users = Services.UserService.GetUsersById(userIds) + var userAvatars = Services.UserService.GetUsersById(userIds) .ToDictionary(x => x.Id, x => x.GetUserAvatarUrls(ApplicationCache.RuntimeCache)); var userNames = Services.UserService.GetUsersById(userIds).ToDictionary(x => x.Id, x => x.Name); foreach (var item in items) - { - item.UserAvatars = users[item.UserId]; - item.UserName = userNames[item.UserId]; + { + if (userAvatars.TryGetValue(item.UserId, out var avatars)) + { + item.UserAvatars = avatars; + } + if (userNames.TryGetValue(item.UserId, out var name)) + { + item.UserName = name; + } + + } return items; }