From: nupplaPhil Date: Fri, 10 Jan 2020 21:27:05 +0000 (+0100) Subject: Fix missing storage class X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=86320317f493d0bf26fac7860d2e0c388633ab0c;p=friendica.git Fix missing storage class --- diff --git a/src/Model/Attach.php b/src/Model/Attach.php index e98f80a91d..fc0ebb8e2c 100644 --- a/src/Model/Attach.php +++ b/src/Model/Attach.php @@ -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(); diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 4f6b1640d0..5c83bc99c7 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -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); }