]> git.mxchange.org Git - friendica.git/blobdiff - src/Contact/Avatar.php
Merge pull request #12397 from HankG/fix-photo-get-without-scale-arg
[friendica.git] / src / Contact / Avatar.php
index 60981485e81f2fb3dacbd46a3938bd7753106ac8..0cfc8df3458275478b84340d9245440c595af10c 100644 (file)
@@ -123,7 +123,7 @@ class Avatar
                return $fields;
        }
 
-       private static function getFilename(string $url)
+       private static function getFilename(string $url): string
        {
                $guid = Item::guidFromUri($url, parse_url($url, PHP_URL_HOST));
 
@@ -161,15 +161,15 @@ class Avatar
                        $dirpath .= $part . '/';
 
                        if (!file_exists($dirpath)) {
-                               if (!mkdir($dirpath, $dir_perm)) {
+                               if (!@mkdir($dirpath, $dir_perm) && !file_exists($dirpath)) {
                                        Logger::warning('Directory could not be created', ['directory' => $dirpath]);
                                }
                        } 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]);
+                               Logger::warning('Directory permissions could not be changed', ['directory' => $dirpath, 'old' => $old_perm, 'new' => $dir_perm]);
                        }
 
                        if ((($old_group = filegroup($dirpath)) != $group) && !chgrp($dirpath, $group)) {
-                               Logger::notice('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]);
+                               Logger::warning('Directory group could not be changed', ['directory' => $dirpath, 'old' => $old_group, 'new' => $group]);
                        }
                }
 
@@ -181,11 +181,11 @@ class Avatar
                $old_group = filegroup($filepath);
 
                if (($old_perm != $file_perm) && !chmod($filepath, $file_perm)) {
-                       Logger::notice('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]);
+                       Logger::warning('File permissions could not be changed', ['file' => $filepath, 'old' => $old_perm, 'new' => $file_perm]);
                }
 
                if (($old_group != $group) && !chgrp($filepath, $group)) {
-                       Logger::notice('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]);
+                       Logger::warning('File group could not be changed', ['file' => $filepath, 'old' => $old_group, 'new' => $group]);
                }
 
                DI::profiler()->stopRecording();
@@ -263,7 +263,7 @@ class Avatar
        {
                $localFile = self::getCacheFile($avatar);
                if (!empty($localFile)) {
-                       unlink($localFile);
+                       @unlink($localFile);
                        Logger::debug('Unlink avatar', ['avatar' => $avatar]);
                }
        }