Skip to content

Commit 09ca50a

Browse files
authored
[5.2] Catch exception to get the user in the action log model (#44358)
1 parent 4afcf74 commit 09ca50a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

administrator/components/com_actionlogs/src/Model/ActionlogModel.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ public function addLog($messages, $messageLanguageKey, $context, $userId = 0)
5555
@trigger_error(\sprintf('User ID must be an integer in %s.', __METHOD__), E_USER_DEPRECATED);
5656
}
5757

58-
$user = $userId ? $this->getUserFactory()->loadUserById($userId) : $this->getCurrentUser();
58+
try {
59+
$user = $userId ? $this->getUserFactory()->loadUserById($userId) : $this->getCurrentUser();
60+
} catch (\UnexpectedValueException $e) {
61+
@trigger_error(\sprintf('UserFactory must be set, this will not be caught anymore in 7.0.'), E_USER_DEPRECATED);
62+
$user = Factory::getUser($userId);
63+
}
64+
5965
$db = $this->getDatabase();
6066
$date = Factory::getDate();
6167
$params = ComponentHelper::getComponent('com_actionlogs')->getParams();

0 commit comments

Comments
 (0)