]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Storage/Database.php
Merge pull request #10860 from nupplaphil/feat/depository_profilefield
[friendica.git] / src / Model / Storage / Database.php
index 5e83ca85680aac43086ca9921ad3b04f0c13ea19..7b90d878909221d8f2ac59d48e990c8cd0f51f08 100644 (file)
@@ -29,7 +29,7 @@ use Friendica\Database\Database as DBA;
  *
  * This class manage data stored in database table.
  */
-class Database implements ISelectableStorage
+class Database implements IWritableStorage
 {
        const NAME = 'Database';
 
@@ -57,7 +57,11 @@ class Database implements ISelectableStorage
 
                        return $result['data'];
                } catch (Exception $exception) {
-                       throw new StorageException(sprintf('Database storage failed to get %s', $reference), $exception->getCode(), $exception);
+                       if ($exception instanceof ReferenceStorageException) {
+                               throw $exception;
+                       } else {
+                               throw new StorageException(sprintf('Database storage failed to get %s', $reference), $exception->getCode(), $exception);
+                       }
                }
        }
 
@@ -97,30 +101,18 @@ class Database implements ISelectableStorage
        public function delete(string $reference)
        {
                try {
-                       if (!$this->dba->delete('storage', ['id' => $reference])) {
+                       if (!$this->dba->delete('storage', ['id' => $reference]) || $this->dba->affectedRows() === 0) {
                                throw new ReferenceStorageException(sprintf('Database storage failed to delete %s', $reference));
                        }
                } catch (Exception $exception) {
-                       throw new StorageException(sprintf('Database storage failed to delete %s', $reference), $exception->getCode(), $exception);
+                       if ($exception instanceof ReferenceStorageException) {
+                               throw $exception;
+                       } else {
+                               throw new StorageException(sprintf('Database storage failed to delete %s', $reference), $exception->getCode(), $exception);
+                       }
                }
        }
 
-       /**
-        * @inheritDoc
-        */
-       public function getOptions(): array
-       {
-               return [];
-       }
-
-       /**
-        * @inheritDoc
-        */
-       public function saveOptions(array $data): array
-       {
-               return [];
-       }
-
        /**
         * @inheritDoc
         */