Commit a24fd185 authored by TravisCarden's avatar TravisCarden

Issue #3074254 by maticb: Error when last property changed by is null

parent bbcf4348
......@@ -172,17 +172,16 @@ class ChecklistapiChecklist {
* Gets the name of the last user to update the checklist.
*
* @return string
* The themed name of the last user to update the checklist, or 'n/a' if
* there is no record of such a user.
* The themed name of the last user to update the checklist, 'n/a' if there
* is no saved progress, or '[missing user] if the user no longer exists.
*/
public function getLastUpdatedUser() {
if (isset($this->savedProgress['#changed_by'])) {
return User::load($this->savedProgress['#changed_by'])
->getAccountName();
}
else {
if (!isset($this->savedProgress['#changed_by'])) {
return t('n/a');
}
$user = User::load($this->savedProgress['#changed_by']);
return ($user) ? $user->getAccountName() : t('[missing user]');
}
/**
......
......@@ -126,9 +126,10 @@ class ChecklistapiChecklistForm implements FormInterface, ContainerInjectionInte
$title = Xss::filter($item['#title']);
if ($saved_item) {
// Append completion details.
$user = User::load($saved_item['#uid']);
$title .= '<span class="completion-details"> - ' . t('Completed @time by @user', [
'@time' => $this->dateFormatter->format($saved_item['#completed'], 'short'),
'@user' => User::load($saved_item['#uid'])->getAccountName(),
'@user' => ($user) ? $user->getAccountName() : t('[missing user]'),
]) . '</span>';
}
// Set default value.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment