X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FStorageManager.php;h=cfefa5f35a7dcc91738a2d63d9bc500221d6aa4b;hb=f68b3c7c4ec9c7c98054035957db178d5071542c;hp=a71e2473cda5efa61baa4a4562ae2c4f69ee4fa2;hpb=8addcf98442d8651c969cbcf5383c6ea71c921ad;p=friendica.git diff --git a/src/Core/StorageManager.php b/src/Core/StorageManager.php index a71e2473cd..cfefa5f35a 100644 --- a/src/Core/StorageManager.php +++ b/src/Core/StorageManager.php @@ -3,9 +3,7 @@ namespace Friendica\Core; use Friendica\Database\DBA; -use Friendica\Core\Config; -use Friendica\Core\Logger; - +use Friendica\Model\Storage\IStorage; /** @@ -33,6 +31,7 @@ class StorageManager /** * @brief Return current storage backend class * @return string + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function getBackend() { @@ -54,7 +53,8 @@ class StorageManager /** * @brief Set current storage backend class * - * @param string $class Backend class name + * @param string $class Backend class name + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function setBackend($class) { @@ -74,12 +74,12 @@ class StorageManager } - /** * @brief Register a storage backend class * - * @param string $name User readable backend name - * @param string $class Backend class name + * @param string $name User readable backend name + * @param string $class Backend class name + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function register($name, $class) { @@ -93,7 +93,8 @@ class StorageManager /** * @brief Unregister a storage backend class * - * @param string $name User readable backend name + * @param string $name User readable backend name + * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function unregister($name) { @@ -110,18 +111,19 @@ class StorageManager * This method cannot move to legacy in-table `data` field. * * @param string $dest Destination storage class name - * @param array $tables Tables to look in for resources. Optional, defaults to ['photo'] + * @param array $tables Tables to look in for resources. Optional, defaults to ['photo', 'attach'] * - * @retur int Number of moved resources + * @throws \Exception + * @return int Number of moved resources */ public static function move($dest, $tables = null) { if (is_null($dest) || empty($dest)) { - throw Exception('Can\'t move to NULL storage backend'); + throw new \Exception('Can\'t move to NULL storage backend'); } if (is_null($tables)) { - $tables = ['photo']; + $tables = ['photo', 'attach']; } $moved = 0; @@ -134,9 +136,10 @@ class StorageManager ); if (DBA::isResult($rr)) { - while($r = $rr->fetch()) { + while($r = DBA::fetch($rr)) { $id = $r['id']; $data = $r['data']; + /** @var IStorage $backendClass */ $backendClass = $r['backend-class']; $backendRef = $r['backend-ref']; if (!is_null($backendClass) && $backendClass !== '') { @@ -145,6 +148,7 @@ class StorageManager } Logger::log("save data to new backend " . $dest); + /** @var IStorage $dest */ $ref = $dest::put($data); Logger::log("saved data as " . $ref);