From 5442d09cc130206171f734e84afbed1c01c195ce Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 3 Jun 2022 05:28:10 +0000 Subject: [PATCH] Ensure that the avatar base path exists --- src/Contact/Avatar.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index bca8d20048..d63ebe5b6d 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -147,6 +147,13 @@ class Avatar DI::profiler()->startRecording('file'); + if (!file_exists($dirpath)) { + if (!mkdir($dirpath, 0775)) { + Logger::warning('Base directory could not be created', ['directory' => $dirpath]); + return ''; + } + } + // Fetch the permission and group ownership of the "avatar" path and apply to all files $dir_perm = fileperms($dirpath) & 0777; $file_perm = fileperms($dirpath) & 0666;