diff --git a/doc/AddonStorageBackend.md b/doc/AddonStorageBackend.md index ef1b4454b9..f69dfff45a 100644 --- a/doc/AddonStorageBackend.md +++ b/doc/AddonStorageBackend.md @@ -23,7 +23,7 @@ interface IStorage public function getOptions(); public function saveOptions(array $data); public function __toString(); - public static function getName(); + public static function getName(); } ``` @@ -250,13 +250,13 @@ function samplestorage_install() // on addon install, we register our class with name "Sample Storage". // note: we use `::class` property, which returns full class name as string // this save us the problem of correctly escape backslashes in class name - DI::facStorage()->register(SampleStorageBackend::class); + DI::storageManager()->register(SampleStorageBackend::class); } function samplestorage_unistall() { // when the plugin is uninstalled, we unregister the backend. - DI::facStorage()->unregister(SampleStorageBackend::class); + DI::storageManager()->unregister(SampleStorageBackend::class); } function samplestorage_storage_instance(\Friendica\App $a, array $data) diff --git a/src/DI.php b/src/DI.php index 152e705a7b..b7be36212b 100644 --- a/src/DI.php +++ b/src/DI.php @@ -27,7 +27,7 @@ use Psr\Log\LoggerInterface; * @method static Core\L10n\L10n l10n() * @method static Core\Process process() * @method static Core\Session\ISession session() - * @method static Core\StorageManager facStorage() + * @method static Core\StorageManager storageManager() * @method static Database\Database dba() * @method static Factory\Mastodon\Account mstdnAccount() * @method static Factory\Mastodon\FollowRequest mstdnFollowRequest() @@ -49,40 +49,40 @@ use Psr\Log\LoggerInterface; abstract class DI { const CLASS_MAPPING = [ - 'app' => App::class, - 'auth' => App\Authentication::class, - 'args' => App\Arguments::class, - 'baseUrl' => App\BaseURL::class, - 'mode' => App\Mode::class, - 'module' => App\Module::class, - 'page' => App\Page::class, - 'router' => App\Router::class, - 'contentItem' => Content\Item::class, - 'bbCodeVideo' => Content\Text\BBCode\Video::class, - 'cache' => Core\Cache\ICache::class, - 'config' => Core\Config\IConfiguration::class, - 'pConfig' => Core\Config\IPConfiguration::class, - 'l10n' => Core\L10n\L10n::class, - 'lock' => Core\Lock\ILock::class, - 'process' => Core\Process::class, - 'session' => Core\Session\ISession::class, - 'facStorage' => Core\StorageManager::class, - 'dba' => Database\Database::class, - 'mstdnAccount' => Factory\Mastodon\Account::class, + 'app' => App::class, + 'auth' => App\Authentication::class, + 'args' => App\Arguments::class, + 'baseUrl' => App\BaseURL::class, + 'mode' => App\Mode::class, + 'module' => App\Module::class, + 'page' => App\Page::class, + 'router' => App\Router::class, + 'contentItem' => Content\Item::class, + 'bbCodeVideo' => Content\Text\BBCode\Video::class, + 'cache' => Core\Cache\ICache::class, + 'config' => Core\Config\IConfiguration::class, + 'pConfig' => Core\Config\IPConfiguration::class, + 'l10n' => Core\L10n\L10n::class, + 'lock' => Core\Lock\ILock::class, + 'process' => Core\Process::class, + 'session' => Core\Session\ISession::class, + 'storageManager' => Core\StorageManager::class, + 'dba' => Database\Database::class, + 'mstdnAccount' => Factory\Mastodon\Account::class, 'mstdnFollowRequest' => Factory\Mastodon\FollowRequest::class, 'mstdnRelationship' => Factory\Mastodon\Relationship::class, - 'cookie' => Model\User\Cookie::class, - 'notify' => Model\Notify::class, - 'storage' => Model\Storage\IStorage::class, - 'intro' => Repository\Introduction::class, - 'activity' => Protocol\Activity::class, - 'aclFormatter' => Util\ACLFormatter::class, - 'dtFormat' => Util\DateTimeFormat::class, - 'fs' => Util\FileSystem::class, - 'workerLogger' => Util\Logger\WorkerLogger::class, - 'profiler' => Util\Profiler::class, - 'logger' => LoggerInterface::class, - 'devLogger' => '$devLogger', + 'cookie' => Model\User\Cookie::class, + 'notify' => Model\Notify::class, + 'storage' => Model\Storage\IStorage::class, + 'intro' => Repository\Introduction::class, + 'activity' => Protocol\Activity::class, + 'aclFormatter' => Util\ACLFormatter::class, + 'dtFormat' => Util\DateTimeFormat::class, + 'fs' => Util\FileSystem::class, + 'workerLogger' => Util\Logger\WorkerLogger::class, + 'profiler' => Util\Profiler::class, + 'logger' => LoggerInterface::class, + 'devLogger' => '$devLogger', ]; /** @var Dice */ diff --git a/src/Model/Attach.php b/src/Model/Attach.php index 7a04461768..e98f80a91d 100644 --- a/src/Model/Attach.php +++ b/src/Model/Attach.php @@ -259,7 +259,7 @@ class Attach $items = self::selectToArray(['backend-class','backend-ref'], $conditions); foreach($items as $item) { - $backend_class = DI::facStorage()->getByName($item['backend-class'] ?? ''); + $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? ''); if ($backend_class !== '') { $fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? ''); } else { @@ -291,7 +291,7 @@ class Attach $items = self::selectToArray(['backend-class','backend-ref'], $conditions); foreach($items as $item) { - $backend_class = DI::facStorage()->getByName($item['backend-class'] ?? ''); + $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? ''); if ($backend_class !== null) { $backend_class->delete($item['backend-ref'] ?? ''); } diff --git a/src/Model/Photo.php b/src/Model/Photo.php index b13aaa79aa..9e26711401 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -179,7 +179,7 @@ class Photo } $data = $i['data']; } else { - $backendClass = DI::facStorage()->getByName($photo['backend-class'] ?? ''); + $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? ''); $backendRef = $photo['backend-ref'] ?? ''; $data = $backendClass->get($backendRef); } @@ -272,7 +272,7 @@ class Photo if (DBA::isResult($existing_photo)) { $backend_ref = (string)$existing_photo["backend-ref"]; - $storage = DI::facStorage()->getByName($existing_photo["backend-class"] ?? ''); + $storage = DI::storageManager()->getByName($existing_photo["backend-class"] ?? ''); } else { $storage = DI::storage(); } @@ -336,7 +336,7 @@ class Photo $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions); foreach($photos as $photo) { - $backend_class = DI::facStorage()->getByName($photo['backend-class'] ?? ''); + $backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? ''); if ($backend_class !== null) { $backend_class->delete($photo["backend-ref"] ?? ''); } @@ -365,7 +365,7 @@ class Photo $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions); foreach($photos as $photo) { - $backend_class = DI::facStorage()->getByName($photo['backend-class'] ?? ''); + $backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? ''); if ($backend_class !== null) { $fields["backend-ref"] = $backend_class->put($img->asString(), $photo['backend-ref']); } else { diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index e68f379537..433cddf6f7 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -202,7 +202,7 @@ class Site extends BaseAdminModule $storagebackend = Strings::escapeTags(trim($_POST['storagebackend'] ?? '')); // save storage backend form - if (DI::facStorage()->setBackend($storagebackend)) { + if (DI::storageManager()->setBackend($storagebackend)) { $storage_opts = DI::storage()->getOptions(); $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $storagebackend); $storage_opts_data = []; @@ -534,7 +534,7 @@ class Site extends BaseAdminModule $available_storage_backends[''] = L10n::t('Database (legacy)'); } - foreach (DI::facStorage()->listBackends() as $name => $class) { + foreach (DI::storageManager()->listBackends() as $name => $class) { $available_storage_backends[$name] = $name; } diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index 6fa09197b1..6a8d65464d 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -325,7 +325,7 @@ class CronJobs private static function moveStorage() { $current = DI::storage(); - $moved = DI::facStorage()->move($current); + $moved = DI::storageManager()->move($current); if ($moved) { Worker::add(PRIORITY_LOW, "CronJobs", "move_storage"); diff --git a/tests/src/Core/StorageManagerTest.php b/tests/src/Core/StorageManagerTest.php index 2d131c6325..083d12d579 100644 --- a/tests/src/Core/StorageManagerTest.php +++ b/tests/src/Core/StorageManagerTest.php @@ -28,7 +28,6 @@ use Friendica\Test\Util\SampleStorageBackend; * @todo Rework Hook:: methods to dynamic to remove the separated process annotation * * @runTestsInSeparateProcesses - * @preserveGlobalState disabled */ class StorageManagerTest extends DatabaseTest {