- $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
- if (empty($backendClass)) {
- // legacy data storage in "data" column
- $i = self::selectFirst(['data'], ['id' => $photo['id']]);
- if ($i === false) {
- return null;
+ try {
+ $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
+ /// @todo refactoring this returning, because the storage returns a "string" which is casted in different ways - a check "instanceof Image" will fail!
+ return $backendClass->get($photo['backend-ref'] ?? '');
+ } catch (InvalidClassStorageException $storageException) {
+ try {
+ // legacy data storage in "data" column
+ $i = self::selectFirst(['data'], ['id' => $photo['id']]);
+ if ($i !== false) {
+ return $i['data'];
+ } else {
+ DI::logger()->info('Stored legacy data is empty', ['photo' => $photo]);
+ }
+ } catch (\Exception $exception) {
+ DI::logger()->info('Unexpected database exception', ['photo' => $photo, 'exception' => $exception]);