From aeb9562255ef758fd28b37be9196f02e39703ea8 Mon Sep 17 00:00:00 2001 From: Nikolay Lobachev Date: Tue, 9 Oct 2018 22:39:03 +0200 Subject: [PATCH] Replace username with message for deleted users --- src/Command/Database/DatabaseLogBase.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Command/Database/DatabaseLogBase.php b/src/Command/Database/DatabaseLogBase.php index 7004ed0aa..075ca661e 100644 --- a/src/Command/Database/DatabaseLogBase.php +++ b/src/Command/Database/DatabaseLogBase.php @@ -197,12 +197,12 @@ protected function makeQuery($offset = null, $range = 1000) protected function createTableHeader() { return [ - $this->trans('commands.database.log.common.messages.event-id'), - $this->trans('commands.database.log.common.messages.type'), - $this->trans('commands.database.log.common.messages.date'), - $this->trans('commands.database.log.common.messages.message'), - $this->trans('commands.database.log.common.messages.user'), - $this->trans('commands.database.log.common.messages.severity'), + $this->trans('commands.database.log.common.messages.event-id'), + $this->trans('commands.database.log.common.messages.type'), + $this->trans('commands.database.log.common.messages.date'), + $this->trans('commands.database.log.common.messages.message'), + $this->trans('commands.database.log.common.messages.user'), + $this->trans('commands.database.log.common.messages.severity'), ]; } @@ -216,7 +216,13 @@ protected function createTableRow(\stdClass $dblog) /** * @var User $user */ - $user = $this->userStorage->load($dblog->uid); + if ($user = $this->userStorage->load($dblog->uid)) { + $user_id = $user->id(); + $user_name = $user->getUsername(); + } else { + $user_id = $dblog->uid; + $user_name = $this->trans('commands.database.log.common.messages.user-deleted'); + } return [ $dblog->wid, @@ -228,7 +234,7 @@ protected function createTableRow(\stdClass $dblog) true, true ), - $user->getUsername() . ' (' . $user->id() . ')', + $user_name . ' (' . $user_id . ')', $this->severityList[$dblog->severity]->render(), ]; }