From 86320317f493d0bf26fac7860d2e0c388633ab0c Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Fri, 10 Jan 2020 22:27:05 +0100 Subject: [PATCH] Fix missing storage class --- src/Model/Attach.php | 8 ++++---- src/Model/Photo.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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); }