Moved log infos to context, fix #4

This commit is contained in:
Max Nuding 2025-05-24 18:41:32 +02:00
parent 769b9b4ccd
commit 70776ac21f
Signed by: phlaym
SSH Key Fingerprint: SHA256:mionmF+5trOUI1AxqzAU1ZK3tv6IiDcdKGXcMWwa1nQ
3 changed files with 106 additions and 79 deletions

20
phpcs.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>PHPCS configuration file.</description>
<!-- check all files in the src directory, feel free to add more files with:
-->
<file>.</file>
<file>src</file>
<!-- exclude our migrations directory from the violation check-->
<exclude-pattern>scripts/*</exclude-pattern>
<!-- Our base rule: set to PSR12-->
<rule ref="PSR12"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired">
<severity>1</severity>
</rule>
<rule ref="Zend.Files.ClosingTag"/>
</ruleset>

View File

@ -77,7 +77,7 @@ class Roastmonday extends APnutI
$this->logger->info("Downloading picture", ['url' => $link]); $this->logger->info("Downloading picture", ['url' => $link]);
$img_header = get_headers($link, 1); $img_header = get_headers($link, 1);
if (strpos($img_header[0], "200") === false && strpos($img_header[0], "OK")) { if (strpos($img_header[0], "200") === false && strpos($img_header[0], "OK")) {
$this->logger->error("Error fetching avatar header: " . json_encode($img_header)); $this->logger->error("Error fetching avatar header", ['header' => $img_header]);
return null; return null;
} }
$ext = $this->getExtension($img_header['Content-Type']); $ext = $this->getExtension($img_header['Content-Type']);
@ -131,7 +131,7 @@ class Roastmonday extends APnutI
try { try {
$past_themes_list = $past_themes_element->parentNode->nextSibling->nextSibling; $past_themes_list = $past_themes_element->parentNode->nextSibling->nextSibling;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('Error parsing wiki: ' . $e->getMessage()); $this->logger->error('Error parsing wiki', ['exception' => $e->getMessage()]);
return []; return [];
} }
foreach ($past_themes_list->childNodes as $child) { foreach ($past_themes_list->childNodes as $child) {
@ -151,15 +151,14 @@ class Roastmonday extends APnutI
} }
} }
if ($tag !== null && $date !== null) { if ($tag !== null && $date !== null) {
$tag = trim($tag);
$this->logger->info( $this->logger->info(
'Found ThemeMonday in wiki: ' 'Found ThemeMonday in wiki',
. trim($tag) ['tag' => $tag, 'date' => $date]
. ' on '
. $date->format('Y-m-d')
); );
$m[] = [ $m[] = [
'date' => new \DateTime($date->format('Y-m-d')), 'date' => new \DateTime($date->format('Y-m-d')),
'tag' => trim($tag) 'tag' => $tag
]; ];
} }
} }
@ -171,7 +170,6 @@ class Roastmonday extends APnutI
public function getThemeMonday($id) public function getThemeMonday($id)
{ {
$t = $this->db->getTheme($id); $t = $this->db->getTheme($id);
$this->logger->debug('Theme ' . $id . ': ' . json_encode($t));
return $t; return $t;
} }
@ -183,33 +181,32 @@ class Roastmonday extends APnutI
try { try {
$p = $this->getPollsFromUser(616); $p = $this->getPollsFromUser(616);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('Error reading @ThemeMonday polls: ' . $e->getMessage()); $this->logger->error('Error reading @ThemeMonday polls', ['exception' => $e->getMessage()]);
return []; return [];
} }
$p = array_filter($p, function ($e) { $p = array_filter($p, function ($e) {
return stripos($e->prompt, '#thememonday') !== false; return stripos($e->prompt, '#thememonday') !== false;
}); });
$this->logger->info('Found ' . count($p) . ' polls'); $this->logger->info('Found polls count', ['count' => count($p)]);
if (count($p) === 0) { if (count($p) === 0) {
return []; return [];
} }
foreach ($p as $poll) { foreach ($p as $poll) {
$tag = $poll->getMostVotedOption(); $tag = $poll->getMostVotedOption();
if (count($tag) !== 1) { if (count($tag) !== 1) {
$this->logger->info('Skipping ' . implode(', ', $tag) . ', because it was a tie'); $this->logger->info('Skipping tag, because it was a tie', ['tag' => $tag]);
continue; continue;
} }
$date = Roastmonday::getMondayAfterPoll($poll); $date = Roastmonday::getMondayAfterPoll($poll);
$tagtext = $tag[0]->text;
$this->logger->info( $this->logger->info(
'Found ThemeMonday: ' 'Found ThemeMonday',
. $tag[0]->text ['tag' => $tagtext, 'date' => $date]
. ' on '
. $date->format('Y-m-d')
); );
$m[] = [ $m[] = [
'date' => new \DateTime($date->format('Y-m-d')), 'date' => new \DateTime($date->format('Y-m-d')),
'tag' => $tag[0]->text 'tag' => $tagtext
]; ];
} }
return $m; return $m;
@ -224,13 +221,11 @@ class Roastmonday extends APnutI
protected function savePictureForPost($post, $theme_id) protected function savePictureForPost($post, $theme_id)
{ {
$this->logger->info('Checking post ' . $post->id . ' for theme ' . $theme_id); $this->logger->info('Checking post for theme', ['post' => $post->id, 'theme' => $theme_id]);
if (!empty($post->user) && !empty($post->user->avatar_image)) { if (!empty($post->user) && !empty($post->user->avatar_image)) {
$this->logger->info( $this->logger->info(
'Found new avatar on post ' 'Found new avatar on post',
. $post->id ['post' => $post->id, 'user' => $post->user->username]
. ' by @'
. $post->user->username
); );
$filename = $this->downloadPicture($post->user->avatar_image->link, $theme_id); $filename = $this->downloadPicture($post->user->avatar_image->link, $theme_id);
if ($filename !== null) { if ($filename !== null) {
@ -247,11 +242,8 @@ class Roastmonday extends APnutI
} }
} }
$this->logger->info( $this->logger->info(
'Saving avatar by ' 'Saving avatar to database',
. $post->user->username ['theme' => $theme_id, 'user' => $post->user->username]
. ' for '
. $theme_id
. ' to database'
); );
try { try {
$status = $this->db->saveAvatar( $status = $this->db->saveAvatar(
@ -274,16 +266,20 @@ class Roastmonday extends APnutI
$this->logger->info('Successfully inserted avatar'); $this->logger->info('Successfully inserted avatar');
break; break;
default: default:
$this->logger->info('Unknown return code ' . $status); $this->logger->info('Unknown return code', ['status' => $status]);
break; break;
} }
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('Error inserting avatar into database: ' . $e->getMessage()); $this->logger->error(
'Error inserting avatar into database',
['exception' => $e->getMessage()]
);
} }
return $filename; return $filename;
} }
$this->logger->warning( $this->logger->warning(
"Cannot save picture for post {$post->id}: Doesn't have a user or user doesn't have an avatar" "Cannot save picture for post. Doesn't have a user or user doesn't have an avatar",
['post' => $post->id]
); );
} }
} }
@ -293,7 +289,7 @@ class Roastmonday extends APnutI
$post = parent::getPost($post_id, $args); $post = parent::getPost($post_id, $args);
if (array_key_exists('avatarWidth', $args)) { if (array_key_exists('avatarWidth', $args)) {
$a = parent::getAvatar($post->user->id, ['w' => $args['avatarWidth']]); $a = parent::getAvatar($post->user->id, ['w' => $args['avatarWidth']]);
$this->logger->debug("Resized avatar: {$a}"); $this->logger->debug('Resized avatar', ['avatar' => $a]);
$post->user->avatar_image->link = $a; $post->user->avatar_image->link = $a;
} }
return $post; return $post;
@ -322,20 +318,19 @@ class Roastmonday extends APnutI
public function getThemeMondays() public function getThemeMondays()
{ {
$themes = $this->db->listThemes(); $themes = $this->db->listThemes();
$this->logger->debug('Themes: ' . json_encode($themes)); $this->logger->debug('Themes', ['themes' => $themes]);
return $themes; return $themes;
} }
public function getPicturesForTheme($id) public function getPicturesForTheme($id)
{ {
$this->logger->debug("Avatars for theme {$id}: "); $this->logger->debug('Avatars for theme', ['theme' => $id]);
$pics_folder = $this->pics_root . $id . '/'; $pics_folder = $this->pics_root . $id . '/';
$pics = []; $pics = [];
if (!is_dir($pics_folder)) { if (!is_dir($pics_folder)) {
$this->logger->warning($pics_folder . ' ist not a directory'); $this->logger->warning('Pics folder ist not a directory', ['path' => $pics_folder]);
return []; return [];
} }
$this->logger->debug("DB: " . json_encode($this->db));
$avatars = $this->db->getAvatarsForTheme($id); $avatars = $this->db->getAvatarsForTheme($id);
foreach ($avatars as $avatar) { foreach ($avatars as $avatar) {
$avatar['file'] = $pics_folder . $avatar['file']; $avatar['file'] = $pics_folder . $avatar['file'];
@ -360,7 +355,7 @@ class Roastmonday extends APnutI
} }
return $a['date'] > $b['date'] ? -1 : 1; return $a['date'] > $b['date'] ? -1 : 1;
}); });
$this->logger->info('Found theme mondays', $m); $this->logger->info('Found theme mondays', ['mondays' => $m]);
return $m; return $m;
} }
@ -369,7 +364,7 @@ class Roastmonday extends APnutI
$tag = preg_replace('/^#/', '', $theme['tag']); $tag = preg_replace('/^#/', '', $theme['tag']);
$tag = preg_replace('/ .*$/', '', $tag); $tag = preg_replace('/ .*$/', '', $tag);
$posts = []; $posts = [];
$this->logger->info('Searching pictures for: ' . $tag); $this->logger->info('Searching pictures for', ['tag' => $tag]);
foreach (Roastmonday::$new_avatar_keywords as $keyword) { foreach (Roastmonday::$new_avatar_keywords as $keyword) {
$query = [ $query = [
'tags' => $tag, 'tags' => $tag,
@ -380,7 +375,7 @@ class Roastmonday extends APnutI
'include_html' => false, 'include_html' => false,
]; ];
$p = $this->searchPosts($query); $p = $this->searchPosts($query);
$this->logger->info('Found ' . count($p) . ' posts'); $this->logger->info('Found posts', ['count' => count($p)]);
foreach ($p as $post) { foreach ($p as $post) {
$this->savePictureForPost($post, $theme['id']); $this->savePictureForPost($post, $theme['id']);
if (!in_array($post, $posts)) { if (!in_array($post, $posts)) {
@ -394,7 +389,7 @@ class Roastmonday extends APnutI
{ {
$tag = preg_replace('/^#/', '', $tag); $tag = preg_replace('/^#/', '', $tag);
$tag = preg_replace('/ .*$/', '', $tag); $tag = preg_replace('/ .*$/', '', $tag);
$this->logger->info('Adding: ' . $tag . ' to database'); $this->logger->info('Adding: tag to database', ['tag' => $tag]);
$id = $this->db->addTheme($tag, $date->format('Y-m-d')); $id = $this->db->addTheme($tag, $date->format('Y-m-d'));
if ($id !== -1) { if ($id !== -1) {
$pics_folder = $this->pics_root . $id . '/'; $pics_folder = $this->pics_root . $id . '/';
@ -413,7 +408,7 @@ class Roastmonday extends APnutI
$posttext = null, $posttext = null,
$overwrite_if_exist = false $overwrite_if_exist = false
) { ) {
$this->logger->info("Adding temporary avatar to theme {$theme} for {$avatar_duration} days"); $this->logger->info('Adding temporary avatar to theme', ['theme' => $theme, 'duration' => $avatar_duration]);
switch ($avatar['error']) { switch ($avatar['error']) {
case UPLOAD_ERR_OK: case UPLOAD_ERR_OK:
@ -429,9 +424,7 @@ class Roastmonday extends APnutI
#1. Save current user avatar #1. Save current user avatar
$a = self::getAvatar('me'); $a = self::getAvatar('me');
$this->logger->info("Current avatar: {$a}"); $this->logger->info('Current avatar', ['avatar' => $a]);
#$a = explode('/', $a);
#$filename = explode('?', end($a))[0];
$original_avatar = $this->downloadPicture($a, $this->temp_pics_root); $original_avatar = $this->downloadPicture($a, $this->temp_pics_root);
if (empty($original_avatar)) { if (empty($original_avatar)) {
return ['error' => ['message' => 'Could not download original avatar']]; return ['error' => ['message' => 'Could not download original avatar']];
@ -444,7 +437,7 @@ class Roastmonday extends APnutI
if (empty($current_user)) { if (empty($current_user)) {
return ['error' => ['message' => 'Could not fetch the authorized user']]; return ['error' => ['message' => 'Could not fetch the authorized user']];
} }
$this->logger->info("Current user: @{$current_user->username} ({$current_user->id})"); $this->logger->info('Current user', ['username' => $current_user->username, 'id' => $current_user->id]);
$avatar_duration = min($avatar_duration, 1); $avatar_duration = min($avatar_duration, 1);
$d = new \DateTime(); $d = new \DateTime();
$d->add(new \DateInterval("P{$avatar_duration}D")); $d->add(new \DateInterval("P{$avatar_duration}D"));
@ -510,8 +503,7 @@ class Roastmonday extends APnutI
try { try {
$post = $this->createPost($posttext, is_nsfw: false, auto_crop: true); $post = $this->createPost($posttext, is_nsfw: false, auto_crop: true);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error($e->getMessage()); $this->logger->error('Could not create post', ['exception' => $e]);
$this->logger->error($e->getTraceAsString());
return [ return [
'success' => true, 'success' => true,
'warn' => 'Your avatar has been updated, but an error occured creating the post:<br />' 'warn' => 'Your avatar has been updated, but an error occured creating the post:<br />'
@ -526,8 +518,7 @@ class Roastmonday extends APnutI
$response = $this->manuallyAddAvatar($theme, $post->id, null, overwrite_if_exist: $overwrite_if_exist); $response = $this->manuallyAddAvatar($theme, $post->id, null, overwrite_if_exist: $overwrite_if_exist);
$this->logger->info('Successfully added to gallery'); $this->logger->info('Successfully added to gallery');
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error($e->getMessage()); $this->logger->error('Could not authenticateServerToken', ['exception' => $e]);
$this->logger->error($e->getTraceAsString());
return [ return [
'success' => true, 'success' => true,
'postID' => $post->id, 'postID' => $post->id,
@ -554,7 +545,10 @@ class Roastmonday extends APnutI
$user = $post->user; $user = $post->user;
$date = $post->created_at; $date = $post->created_at;
if (empty($user)) { if (empty($user)) {
$this->logger->error("Error fetching avatar from post #{$post_id}. Post has no creator."); $this->logger->error(
'Error fetching avatar from post. Post has no creator.',
['post_id' => $post_id]
);
$resp['error'] = [ $resp['error'] = [
'code' => static::$ERROR_FETCHING_CREATOR_FIELD, 'code' => static::$ERROR_FETCHING_CREATOR_FIELD,
'message' => 'Error fetching avatar. Post has no creator.' 'message' => 'Error fetching avatar. Post has no creator.'
@ -563,7 +557,10 @@ class Roastmonday extends APnutI
} }
} }
if (empty($user->avatar_image) || empty($user->avatar_image->link)) { if (empty($user->avatar_image) || empty($user->avatar_image->link)) {
$this->logger->error("Error fetching avatar from post #{$post_id}. Post creator has no avatar."); $this->logger->error(
'Error fetching avatar from post. Post creator has no avatar.',
['post_id' => $post_id]
);
$resp['error'] = [ $resp['error'] = [
'code' => static::$ERROR_FETCHING_CREATOR_FIELD, 'code' => static::$ERROR_FETCHING_CREATOR_FIELD,
'message' => 'Error fetching avatar. Post creator has no avatar.' 'message' => 'Error fetching avatar. Post creator has no avatar.'
@ -571,9 +568,9 @@ class Roastmonday extends APnutI
return $resp; return $resp;
} }
$astr = print_r($avatar, true); $astr = print_r($avatar, true);
$this->logger->debug("Manually adding avatar: {$astr}"); $this->logger->debug('Manually adding avatar', ['avatar' => $astr]);
if (!empty($avatar) && (empty($avatar['error']) || $avatar['error'] === 0)) { if (!empty($avatar) && (empty($avatar['error']) || $avatar['error'] === 0)) {
$this->logger->info("Manually added post #{$post_id} has an avatar attached."); $this->logger->info('Manually added post has an avatar attached', ['post_id' => $post_id]);
$ext = $this->getExtension($avatar['type']); $ext = $this->getExtension($avatar['type']);
$target_file_name_without_theme = time() . '_' . $post_id . '.' . $ext; $target_file_name_without_theme = time() . '_' . $post_id . '.' . $ext;
$target_file_name = $theme . '/' . $target_file_name_without_theme; $target_file_name = $theme . '/' . $target_file_name_without_theme;
@ -581,14 +578,17 @@ class Roastmonday extends APnutI
if (move_uploaded_file($avatar["tmp_name"], $target_file)) { if (move_uploaded_file($avatar["tmp_name"], $target_file)) {
$resp['img'] = 'pics/' . $target_file_name; $resp['img'] = 'pics/' . $target_file_name;
} else { } else {
$this->logger->error("Error saving uploaded avatar from post #{$post_id}. Post has no creator."); $this->logger->error(
'Error saving uploaded avatar from post. Post has no creator',
['post_id' => $post_id]
);
$resp['error'] = [ $resp['error'] = [
'code' => static::$ERROR_UNKNOWN_SERVER_ERROR, 'code' => static::$ERROR_UNKNOWN_SERVER_ERROR,
'message' => 'Uploaded file could not be moved' 'message' => 'Uploaded file could not be moved'
]; ];
return $resp; return $resp;
} }
$this->logger->info("Saved manually uploaded file to " . $target_file . ". Adding to database"); $this->logger->info('Saved manually uploaded file. Adding to database', ['path' => $target_file]);
$realname = null; $realname = null;
$username = ''; $username = '';
if (isset($user)) { if (isset($user)) {
@ -615,7 +615,8 @@ class Roastmonday extends APnutI
); );
} else { } else {
$this->logger->info( $this->logger->info(
"Manually added post #{$post_id} doesn't have an avatar attached. fetching from user object." "Manually added post doesn't have an avatar attached. fetching from user object",
['post_id' => $post_id]
); );
$filename = $this->savePictureForPost($post, $theme); $filename = $this->savePictureForPost($post, $theme);
if (empty($filename)) { if (empty($filename)) {
@ -627,8 +628,6 @@ class Roastmonday extends APnutI
return $resp; return $resp;
} }
$resp['img'] = 'pics/' . $theme . '/' . $filename; $resp['img'] = 'pics/' . $theme . '/' . $filename;
//protected function savePicture($avatar, $theme_id, $filename) {
//$avatar = file_get_contents($this->pics_root.$theme.'/'.$filename);
$this->logger->info("Saved downloaded avatar to {$resp['img']}"); $this->logger->info("Saved downloaded avatar to {$resp['img']}");
} }
$resp['presence'] = -1; $resp['presence'] = -1;
@ -644,15 +643,6 @@ class Roastmonday extends APnutI
$resp['user'] = '@' . $username; $resp['user'] = '@' . $username;
$text = ""; $text = "";
/*
if (isset($post->content)) {
if (isset($post->content->html)) {
$text = $post->content->html;
} elseif (isset($post->content->text)) {
$text = $post->content->text;
}
}
*/
$text = empty($post) ? '' : $post->getText(); $text = empty($post) ? '' : $post->getText();
$resp['success'] = true; $resp['success'] = true;
$resp['realname'] = $realname; $resp['realname'] = $realname;
@ -660,19 +650,22 @@ class Roastmonday extends APnutI
$resp['postid'] = $post_id; $resp['postid'] = $post_id;
$resp['timestamp'] = $date->getTimestamp(); $resp['timestamp'] = $date->getTimestamp();
$this->logger->info( $this->logger->info(
"Successfully added manually uploaded avatar for user to theme", 'Successfully added manually uploaded avatar for user to theme',
['user' => $resp['user'], 'theme' => $theme] ['user' => $resp['user'], 'theme' => $theme]
); );
return $resp; return $resp;
} catch (NotFoundException $nfe) { } catch (NotFoundException $nfe) {
$this->logger->error( $this->logger->error(
"Error adding manually uploaded avatar for theme. Post could not be found", 'Error adding manually uploaded avatar for theme. Post could not be found',
['post_id' => $post_id, 'theme' => $theme, 'exception' => $nfe] ['post_id' => $post_id, 'theme' => $theme, 'exception' => $nfe]
); );
$resp['error'] = ['code' => static::$ERROR_NOT_FOUND, 'message' => 'Post could not be found']; $resp['error'] = ['code' => static::$ERROR_NOT_FOUND, 'message' => 'Post could not be found'];
return $resp; return $resp;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error("Error adding manually uploaded avatar for theme {$theme}: " . $e->getMessage()); $this->logger->error(
'Error adding manually uploaded avatar for theme',
['theme' => $theme, 'exception' => $e]
);
$resp['error'] = ['code' => static::$ERROR_UNKNOWN_SERVER_ERROR, 'message' => $e->getMessage()]; $resp['error'] = ['code' => static::$ERROR_UNKNOWN_SERVER_ERROR, 'message' => $e->getMessage()];
return $resp; return $resp;
} }
@ -682,38 +675,52 @@ class Roastmonday extends APnutI
{ {
$this->logger->info('Get outdated avatars'); $this->logger->info('Get outdated avatars');
$to_reset = $this->db->getOutdatedThemeAvatars(); $to_reset = $this->db->getOutdatedThemeAvatars();
$this->logger->info('Found ' . count($to_reset) . ' outdated avatars'); $this->logger->info('Found outdated avatars', ['count' => count($to_reset)]);
foreach ($to_reset as $value) { foreach ($to_reset as $value) {
$user_id = $value['user_id']; $user_id = $value['user_id'];
$p = $this->pics_root . $this->temp_pics_root . $value['original_avatar']; $p = $this->pics_root . $this->temp_pics_root . $value['original_avatar'];
$avatar_path = realpath($p); $avatar_path = realpath($p);
if ($avatar_path === false) { if ($avatar_path === false) {
$this->logger->error("Avatar path '{$p}' for user {$user_id} does not exist!"); $this->logger->error(
'Avatar path for user does not exist!',
['path' => $p, 'user_id' => $user_id]
);
} }
$this->logger->info('Resetting avatar for user ' . $user_id . ' to original at: ' . $avatar_path); $this->logger->info(
'Resetting avatar for user to original',
['path' => $avatar_path, 'user_id' => $user_id]
);
$this->access_token = $value['auth_token']; $this->access_token = $value['auth_token'];
try { try {
$this->updateAvatar($avatar_path); $this->updateAvatar($avatar_path);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('Error resetting user avatar: ' . $e->getMessage()); $this->logger->error('Error resetting user avatar', ['exception' => $e]);
$this->logger->error($e->getTraceAsString());
return; return;
} }
$this->logger->info('Resetted avatar for user ' . $user_id . ' to original at: ' . $avatar_path); $this->logger->info(
$this->logger->info('Deleting avatar for user ' . $user_id . ' at: ' . $avatar_path); 'Resetted avatar for user to original',
['path' => $avatar_path, 'user_id' => $user_id]
);
$this->logger->info(
'Deleting original avatar for user',
['path' => $avatar_path, 'user_id' => $user_id]
);
$res = unlink($avatar_path); $res = unlink($avatar_path);
if (!$res) { if (!$res) {
$this->logger->error('Failed to delete avatar at: ' . $avatar_path); $this->logger->error('Failed to delete avatar at', ['path' => $avatar_path]);
return; return;
} }
$this->logger->info('Deleted avatar for user ' . $user_id . ' at: ' . $avatar_path); $this->logger->info(
'Deleted original avatar for user',
['path' => $avatar_path, 'user_id' => $user_id]
);
try { try {
$this->db->removeOutdatedThemeAvatars($user_id); $this->db->removeOutdatedThemeAvatars($user_id);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('Error resetting user avatar', ['exception' => $e]); $this->logger->error('Error resetting user avatar', ['exception' => $e]);
return; return;
} }
$this->logger->info('Avatar for user ' . $user_id . ' is back to its original value!'); $this->logger->info('Avatar for user is back to its original value!', ['user_id' => $user_id]);
} }
} }
} }