]> git.mxchange.org Git - friendica.git/commitdiff
Fix missing storage class
authornupplaPhil <admin@philipp.info>
Fri, 10 Jan 2020 21:27:05 +0000 (22:27 +0100)
committernupplaPhil <admin@philipp.info>
Fri, 10 Jan 2020 21:27:05 +0000 (22:27 +0100)
src/Model/Attach.php
src/Model/Photo.php

index e98f80a91d1f8914a67141ef00b5d76b0e4a92b1..fc0ebb8e2c869398c915fadd3c6075477d1716c6 100644 (file)
@@ -144,7 +144,8 @@ class Attach
         */
        public static function getData($item)
        {
-               if ($item['backend-class'] == '') {
+               $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
+               if ($backendClass === null) {
                        // legacy data storage in 'data' column
                        $i = self::selectFirst(['data'], ['id' => $item['id']]);
                        if ($i === false) {
@@ -152,9 +153,8 @@ class Attach
                        }
                        return $i['data'];
                } else {
-                       $backendClass = $item['backend-class'];
                        $backendRef = $item['backend-ref'];
-                       return $backendClass::get($backendRef);
+                       return $backendClass->get($backendRef);
                }
        }
 
@@ -260,7 +260,7 @@ class Attach
 
                        foreach($items as $item) {
                                $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
-                               if ($backend_class !== '') {
+                               if ($backend_class !== null) {
                                        $fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? '');
                                } else {
                                        $fields['data'] = $img->asString();
index 4f6b1640d019676eddd6e1eed36379312873df20..5c83bc99c73e8a77ab5ce10f8199c3419f5f25e3 100644 (file)
@@ -171,7 +171,8 @@ class Photo
         */
        public static function getImageForPhoto(array $photo)
        {
-               if (empty($photo['backend-class'])) {
+               $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
+               if ($backendClass === null) {
                        // legacy data storage in "data" column
                        $i = self::selectFirst(['data'], ['id' => $photo['id']]);
                        if ($i === false) {
@@ -179,7 +180,6 @@ class Photo
                        }
                        $data = $i['data'];
                } else {
-                       $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
                        $backendRef = $photo['backend-ref'] ?? '';
                        $data = $backendClass->get($backendRef);
                }