]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Photo.php
Merge pull request #12251 from annando/remote-self
[friendica.git] / src / Model / Photo.php
index 287fc65ad1d228783071c36b2fd13ad272dc9525..7c620b0ad45bb6afc9e95119bf518c788c0353a5 100644 (file)
@@ -25,7 +25,6 @@ use Friendica\Core\Cache\Enum\Duration;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
-use Friendica\Database\DBStructure;
 use Friendica\DI;
 use Friendica\Core\Storage\Type\ExternalResource;
 use Friendica\Core\Storage\Exception\InvalidClassStorageException;
@@ -639,10 +638,10 @@ class Photo
        {
                $sql_extra = Security::getPermissionsSQLByUserId($uid);
 
-               $avatar_type = (local_user() && (local_user() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
-               $banner_type = (local_user() && (local_user() == $uid)) ? self::USER_BANNER : self::DEFAULT;
+               $avatar_type = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
+               $banner_type = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $uid)) ? self::USER_BANNER : self::DEFAULT;
 
-               $key = 'photo_albums:' . $uid . ':' . local_user() . ':' . remote_user();
+               $key = 'photo_albums:' . $uid . ':' . DI::userSession()->getLocalUserId() . ':' . DI::userSession()->getRemoteUserId();
                $albums = DI::cache()->get($key);
 
                if (is_null($albums) || $update) {
@@ -681,7 +680,7 @@ class Photo
         */
        public static function clearAlbumCache(int $uid)
        {
-               $key = 'photo_albums:' . $uid . ':' . local_user() . ':' . remote_user();
+               $key = 'photo_albums:' . $uid . ':' . DI::userSession()->getLocalUserId() . ':' . DI::userSession()->getRemoteUserId();
                DI::cache()->set($key, null, Duration::DAY);
        }
 
@@ -1095,7 +1094,7 @@ class Photo
 
                $r = self::store($image, $user['uid'], 0, $resource_id, $filename, $album, 0, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
                if (!$r) {
-                       Logger::warning('Photo could not be stored');
+                       Logger::warning('Photo could not be stored', ['uid' => $user['uid'], 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
                        return [];
                }
 
@@ -1131,8 +1130,8 @@ class Photo
                $picture['height']      = $photo['height'];
                $picture['type']        = $photo['type'];
                $picture['albumpage']   = DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $resource_id;
-               $picture['picture']     = DI::baseUrl() . '/photo/{$resource_id}-0.' . $image->getExt();
-               $picture['preview']     = DI::baseUrl() . '/photo/{$resource_id}-{$smallest}.' . $image->getExt();
+               $picture['picture']     = DI::baseUrl() . '/photo/' . $resource_id . '-0.' . $image->getExt();
+               $picture['preview']     = DI::baseUrl() . '/photo/' . $resource_id . '-' . $smallest . '.' . $image->getExt();
 
                Logger::info('upload done', ['picture' => $picture]);
                return $picture;
@@ -1182,7 +1181,7 @@ class Photo
 
                $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 4, self::USER_AVATAR);
                if (!$r) {
-                       logger::warning('profile image upload with scale 4 (300) failed');
+                       logger::warning('profile image upload with scale 4 (300) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
                }
 
                if ($width > 80 || $height > 80) {
@@ -1191,7 +1190,7 @@ class Photo
 
                $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 5, self::USER_AVATAR);
                if (!$r) {
-                       logger::warning('profile image upload with scale 5 (80) failed');
+                       logger::warning('profile image upload with scale 5 (80) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
                }
 
                if ($width > 48 || $height > 48) {
@@ -1200,7 +1199,7 @@ class Photo
 
                $r = self::store($image, $uid, 0, $resource_id, $filename, $album, 6, self::USER_AVATAR);
                if (!$r) {
-                       logger::warning('profile image upload with scale 6 (48) failed');
+                       logger::warning('profile image upload with scale 6 (48) failed', ['uid' => $uid, 'resource_id' => $resource_id, 'filename' => $filename, 'album' => $album]);
                }
 
                logger::info('new profile image upload ended');
@@ -1273,4 +1272,3 @@ class Photo
                return $resource_id;
        }
 }
-