From afa57edf8ebc73a438aaf0a3084663a3a7860ae1 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 11 May 2022 17:28:28 +0000 Subject: [PATCH] Avoid warning "fileperms(): stat failed for ..." --- src/Contact/Avatar.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index e3caebb373..38208a043e 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -124,18 +124,15 @@ class Avatar foreach (explode('/', dirname($filename)) as $part) { $dirpath .= $part . '/'; - $old_perm = fileperms($dirpath) & 0777; - $old_group = filegroup($dirpath); - if (!file_exists($dirpath)) { if (!mkdir($dirpath, $dir_perm)) { Logger::warning('Directory could not be created', ['directory' => $dirpath]); } - } elseif (($old_perm != $dir_perm) && !chmod($dirpath, $dir_perm)) { + } elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) { Logger::notice('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]); } - if (($old_group != $group) && !chgrp($dirpath, $group)) { + if ((($old_group = filegroup($dirpath)) != $group) && !chgrp($dirpath, $group)) { Logger::notice('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]); } } -- 2.39.5