]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Attach.php
Standards
[friendica.git] / src / Model / Attach.php
index b5dd64e0ca259c34c156d3c340412d48e672aef0..6182727c9762ad85d63c6365941bc8636129c5aa 100644 (file)
@@ -1,9 +1,24 @@
 <?php
-
 /**
- * @file src/Model/Attach.php
- * This file contains the Attach class for database interface
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
+
 namespace Friendica\Model;
 
 use Friendica\Core\System;
@@ -13,7 +28,7 @@ use Friendica\DI;
 use Friendica\Object\Image;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Mimetype;
-use Friendica\Util\Security;
+use Friendica\Security\Security;
 
 /**
  * Class to handle attach dabatase table
@@ -144,8 +159,12 @@ class Attach
         */
        public static function getData($item)
        {
-               $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
-               if ($backendClass === null) {
+               if (!empty($item['data'])) {
+                       return $item['data'];
+               }
+
+               $backendClass = DI::storageManager()->getByName($item['backend-class'] ?? '');
+               if (empty($backendClass)) {
                        // legacy data storage in 'data' column
                        $i = self::selectFirst(['data'], ['id' => $item['id']]);
                        if ($i === false) {
@@ -260,7 +279,7 @@ class Attach
 
                        foreach($items as $item) {
                                $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
-                               if ($backend_class !== null) {
+                               if (!empty($backend_class)) {
                                        $fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? '');
                                } else {
                                        $fields['data'] = $img->asString();
@@ -292,7 +311,7 @@ class Attach
 
                foreach($items as $item) {
                        $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
-                       if ($backend_class !== null) {
+                       if (!empty($backend_class)) {
                                $backend_class->delete($item['backend-ref'] ?? '');
                        }
                }