aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-02-03 15:34:01 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2025-02-13 11:46:42 +0100
commit64863c9d4631c42d4ce3997d7033bca8f06ca66a (patch)
treeb7e88154522cd827da8163719aeb91b51d5640cd /apps/files_external
parent007335dadfcda18330bb853a73bf451ed41c8254 (diff)
downloadnextcloud-server-64863c9d4631c42d4ce3997d7033bca8f06ca66a.tar.gz
nextcloud-server-64863c9d4631c42d4ce3997d7033bca8f06ca66a.zip
chore: Apply new rector configuration to apps folder
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/ajax/applicable.php9
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php5
-rw-r--r--apps/files_external/lib/Lib/Storage/FTP.php11
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php3
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php6
-rw-r--r--apps/files_external/lib/Lib/Storage/Swift.php29
-rw-r--r--apps/files_external/lib/MountConfig.php11
-rw-r--r--apps/files_external/lib/Service/BackendService.php5
-rw-r--r--apps/files_external/lib/Service/LegacyStoragesService.php5
-rw-r--r--apps/files_external/lib/Service/StoragesService.php5
-rw-r--r--apps/files_external/templates/settings.php4
-rw-r--r--apps/files_external/tests/Service/DBConfigServiceTest.php6
-rw-r--r--apps/files_external/tests/Service/StoragesServiceTest.php12
-rw-r--r--apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php3
-rw-r--r--apps/files_external/tests/Service/UserStoragesServiceTest.php6
-rw-r--r--apps/files_external/tests/Storage/WebdavTest.php4
16 files changed, 77 insertions, 47 deletions
diff --git a/apps/files_external/ajax/applicable.php b/apps/files_external/ajax/applicable.php
index c1b7748ad15..ece913ffc06 100644
--- a/apps/files_external/ajax/applicable.php
+++ b/apps/files_external/ajax/applicable.php
@@ -1,4 +1,9 @@
<?php
+
+use OCP\IGroupManager;
+use OCP\IUserManager;
+use OCP\Server;
+
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -23,12 +28,12 @@ if (isset($_GET['offset'])) {
}
$groups = [];
-foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) {
+foreach (Server::get(IGroupManager::class)->search($pattern, $limit, $offset) as $group) {
$groups[$group->getGID()] = $group->getDisplayName();
}
$users = [];
-foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) {
+foreach (Server::get(IUserManager::class)->searchDisplayName($pattern, $limit, $offset) as $user) {
$users[$user->getUID()] = $user->getDisplayName();
}
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 1a866e8c22b..47967a3908d 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -20,6 +20,7 @@ use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeDetector;
use OCP\ICache;
use OCP\ICacheFactory;
+use OCP\ITempManager;
use OCP\Server;
use Psr\Log\LoggerInterface;
@@ -451,7 +452,7 @@ class AmazonS3 extends Common {
}
case 'w':
case 'wb':
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile();
$handle = fopen($tmpFile, 'w');
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile): void {
@@ -472,7 +473,7 @@ class AmazonS3 extends Common {
} else {
$ext = '';
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile($ext);
if ($this->file_exists($path)) {
$source = $this->readObject($path);
file_put_contents($tmpFile, $source);
diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php
index 51b269b3eb0..e23fc791297 100644
--- a/apps/files_external/lib/Lib/Storage/FTP.php
+++ b/apps/files_external/lib/Lib/Storage/FTP.php
@@ -12,7 +12,10 @@ use OC\Files\Storage\Common;
use OC\Files\Storage\PolyFill\CopyDirectory;
use OCP\Constants;
use OCP\Files\FileInfo;
+use OCP\Files\IMimeTypeDetector;
use OCP\Files\StorageNotAvailableException;
+use OCP\ITempManager;
+use OCP\Server;
use Psr\Log\LoggerInterface;
class FTP extends Common {
@@ -101,7 +104,7 @@ class FTP extends Common {
if ($this->is_dir($path)) {
$list = $this->getConnection()->mlsd($this->buildPath($path));
if (!$list) {
- \OC::$server->get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), failed to list folder contents");
+ Server::get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), failed to list folder contents");
return time();
}
$currentDir = current(array_filter($list, function ($item) {
@@ -115,7 +118,7 @@ class FTP extends Common {
}
return $time->getTimestamp();
} else {
- \OC::$server->get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), folder contents doesn't include current folder");
+ Server::get(LoggerInterface::class)->warning("Unable to get last modified date for ftp folder ($path), folder contents doesn't include current folder");
return time();
}
} else {
@@ -270,7 +273,7 @@ class FTP extends Common {
if (!$this->isCreatable(dirname($path))) {
return false;
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile();
}
$source = fopen($tmpFile, $mode);
return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $path): void {
@@ -322,7 +325,7 @@ class FTP extends Common {
public function getDirectoryContent(string $directory): \Traversable {
$files = $this->getConnection()->mlsd($this->buildPath($directory));
- $mimeTypeDetector = \OC::$server->getMimeTypeDetector();
+ $mimeTypeDetector = Server::get(IMimeTypeDetector::class);
foreach ($files as $file) {
$name = $file['name'];
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index 9907acdc469..2619e678565 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -16,6 +16,7 @@ use OCP\Cache\CappedMemoryCache;
use OCP\Constants;
use OCP\Files\FileInfo;
use OCP\Files\IMimeTypeDetector;
+use OCP\Server;
use phpseclib\Net\SFTP\Stream;
/**
@@ -94,7 +95,7 @@ class SFTP extends Common {
$this->knownMTimes = new CappedMemoryCache();
- $this->mimeTypeDetector = \OC::$server->get(IMimeTypeDetector::class);
+ $this->mimeTypeDetector = Server::get(IMimeTypeDetector::class);
}
/**
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index ef203021566..f08401f73c5 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -31,12 +31,14 @@ use OCA\Files_External\Lib\Notify\SMBNotifyHandler;
use OCP\Cache\CappedMemoryCache;
use OCP\Constants;
use OCP\Files\EntityTooLargeException;
+use OCP\Files\IMimeTypeDetector;
use OCP\Files\Notify\IChange;
use OCP\Files\Notify\IRenameChange;
use OCP\Files\NotPermittedException;
use OCP\Files\Storage\INotifyStorage;
use OCP\Files\StorageAuthException;
use OCP\Files\StorageNotAvailableException;
+use OCP\ITempManager;
use Psr\Log\LoggerInterface;
class SMB extends Common implements INotifyStorage {
@@ -458,7 +460,7 @@ class SMB extends Common implements INotifyStorage {
if (!$this->isCreatable(dirname($path))) {
return false;
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
+ $tmpFile = \OCP\Server::get(ITempManager::class)->getTemporaryFile($ext);
}
$source = fopen($tmpFile, $mode);
$share = $this->share;
@@ -553,7 +555,7 @@ class SMB extends Common implements INotifyStorage {
if ($fileInfo->isDirectory()) {
$data['mimetype'] = 'httpd/unix-directory';
} else {
- $data['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($fileInfo->getPath());
+ $data['mimetype'] = \OCP\Server::get(IMimeTypeDetector::class)->detectPath($fileInfo->getPath());
}
$data['mtime'] = $fileInfo->getMTime();
if ($fileInfo->isDirectory()) {
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index cb72ab8c070..a71331766d4 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -21,6 +21,9 @@ use OCP\Files\StorageAuthException;
use OCP\Files\StorageBadConfigException;
use OCP\Files\StorageNotAvailableException;
use OCP\ICache;
+use OCP\ICacheFactory;
+use OCP\ITempManager;
+use OCP\Server;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\ObjectStore\v1\Models\Container;
use OpenStack\ObjectStore\v1\Models\StorageObject;
@@ -101,7 +104,7 @@ class Swift extends Common {
} catch (BadResponseError $e) {
// Expected response is "404 Not Found", so only log if it isn't
if ($e->getResponse()->getStatusCode() !== 404) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -163,13 +166,13 @@ class Swift extends Common {
// FIXME: private class...
$this->objectCache = new CappedMemoryCache();
$this->connectionFactory = new SwiftFactory(
- \OC::$server->getMemCacheFactory()->createDistributed('swift/'),
+ Server::get(ICacheFactory::class)->createDistributed('swift/'),
$this->params,
- \OC::$server->get(LoggerInterface::class)
+ Server::get(LoggerInterface::class)
);
$this->objectStore = new \OC\Files\ObjectStore\Swift($this->params, $this->connectionFactory);
$this->bucket = $parameters['bucket'];
- $this->mimeDetector = \OC::$server->get(IMimeTypeDetector::class);
+ $this->mimeDetector = Server::get(IMimeTypeDetector::class);
}
public function mkdir(string $path): bool {
@@ -193,7 +196,7 @@ class Swift extends Common {
// with all properties
$this->objectCache->remove($path);
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -237,7 +240,7 @@ class Swift extends Common {
$this->objectStore->deleteObject($path . '/');
$this->objectCache->remove($path . '/');
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -275,7 +278,7 @@ class Swift extends Common {
return IteratorDirectory::wrap($files);
} catch (\Exception $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -298,7 +301,7 @@ class Swift extends Common {
return false;
}
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -352,7 +355,7 @@ class Swift extends Common {
$this->objectCache->remove($path . '/');
} catch (BadResponseError $e) {
if ($e->getResponse()->getStatusCode() !== 404) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -376,7 +379,7 @@ class Swift extends Common {
try {
return $this->objectStore->readObject($path);
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -396,7 +399,7 @@ class Swift extends Common {
} else {
$ext = '';
}
- $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
+ $tmpFile = Server::get(ITempManager::class)->getTemporaryFile($ext);
// Fetch existing file if required
if ($mode[0] !== 'w' && $this->file_exists($path)) {
if ($mode[0] === 'x') {
@@ -463,7 +466,7 @@ class Swift extends Common {
$this->objectCache->remove($target);
$this->objectCache->remove($target . '/');
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
@@ -479,7 +482,7 @@ class Swift extends Common {
$this->objectCache->remove($target);
$this->objectCache->remove($target . '/');
} catch (BadResponseError $e) {
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'exception' => $e,
'app' => 'files_external',
]);
diff --git a/apps/files_external/lib/MountConfig.php b/apps/files_external/lib/MountConfig.php
index ca14275ab13..2289a5008e5 100644
--- a/apps/files_external/lib/MountConfig.php
+++ b/apps/files_external/lib/MountConfig.php
@@ -16,7 +16,10 @@ use OCA\Files_External\Service\UserGlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\AppFramework\QueryException;
use OCP\Files\StorageNotAvailableException;
+use OCP\IConfig;
use OCP\IL10N;
+use OCP\Security\ISecureRandom;
+use OCP\Server;
use OCP\Util;
use phpseclib\Crypt\AES;
use Psr\Log\LoggerInterface;
@@ -51,7 +54,7 @@ class MountConfig {
*/
public static function substitutePlaceholdersInConfig($input, ?string $userId = null) {
/** @var BackendService $backendService */
- $backendService = \OC::$server->get(BackendService::class);
+ $backendService = Server::get(BackendService::class);
/** @var IConfigHandler[] $handlers */
$handlers = $backendService->getConfigHandlers();
foreach ($handlers as $handler) {
@@ -99,7 +102,7 @@ class MountConfig {
throw $e;
}
} catch (\Exception $exception) {
- \OC::$server->get(LoggerInterface::class)->error($exception->getMessage(), ['exception' => $exception, 'app' => 'files_external']);
+ Server::get(LoggerInterface::class)->error($exception->getMessage(), ['exception' => $exception, 'app' => 'files_external']);
throw $exception;
}
}
@@ -191,7 +194,7 @@ class MountConfig {
*/
private static function encryptPassword($password) {
$cipher = self::getCipher();
- $iv = \OC::$server->getSecureRandom()->generate(16);
+ $iv = Server::get(ISecureRandom::class)->generate(16);
$cipher->setIV($iv);
return base64_encode($iv . $cipher->encrypt($password));
}
@@ -218,7 +221,7 @@ class MountConfig {
*/
private static function getCipher() {
$cipher = new AES(AES::MODE_CBC);
- $cipher->setKey(\OC::$server->getConfig()->getSystemValue('passwordsalt', null));
+ $cipher->setKey(Server::get(IConfig::class)->getSystemValue('passwordsalt', null));
return $cipher;
}
diff --git a/apps/files_external/lib/Service/BackendService.php b/apps/files_external/lib/Service/BackendService.php
index e37a0ab4649..b452b27e175 100644
--- a/apps/files_external/lib/Service/BackendService.php
+++ b/apps/files_external/lib/Service/BackendService.php
@@ -8,13 +8,14 @@ namespace OCA\Files_External\Service;
use OCA\Files_External\Config\IConfigHandler;
use OCA\Files_External\Lib\Auth\AuthMechanism;
-
use OCA\Files_External\Lib\Backend\Backend;
+
use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
use OCA\Files_External\Lib\Config\IBackendProvider;
use OCP\EventDispatcher\GenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
+use OCP\Server;
/**
* Service class to manage backend definitions
@@ -88,7 +89,7 @@ class BackendService {
private function callForRegistrations() {
static $eventSent = false;
if (!$eventSent) {
- \OC::$server->get(IEventDispatcher::class)->dispatch(
+ Server::get(IEventDispatcher::class)->dispatch(
'OCA\\Files_External::loadAdditionalBackends',
new GenericEvent()
);
diff --git a/apps/files_external/lib/Service/LegacyStoragesService.php b/apps/files_external/lib/Service/LegacyStoragesService.php
index 20a26a07e8b..5be1a084b66 100644
--- a/apps/files_external/lib/Service/LegacyStoragesService.php
+++ b/apps/files_external/lib/Service/LegacyStoragesService.php
@@ -8,6 +8,7 @@ namespace OCA\Files_External\Service;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\MountConfig;
+use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -124,7 +125,7 @@ abstract class LegacyStoragesService {
$parts = explode('/', ltrim($rootMountPath, '/'), 3);
if (count($parts) < 3) {
// something went wrong, skip
- \OC::$server->get(LoggerInterface::class)->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']);
+ Server::get(LoggerInterface::class)->error('Could not parse mount point "' . $rootMountPath . '"', ['app' => 'files_external']);
continue;
}
$relativeMountPath = rtrim($parts[2], '/');
@@ -172,7 +173,7 @@ abstract class LegacyStoragesService {
}
} catch (\UnexpectedValueException $e) {
// don't die if a storage backend doesn't exist
- \OC::$server->get(LoggerInterface::class)->error('Could not load storage.', [
+ Server::get(LoggerInterface::class)->error('Could not load storage.', [
'app' => 'files_external',
'exception' => $e,
]);
diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php
index 67de6e8b6b8..73642d85f88 100644
--- a/apps/files_external/lib/Service/StoragesService.php
+++ b/apps/files_external/lib/Service/StoragesService.php
@@ -19,6 +19,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\StorageNotAvailableException;
+use OCP\Server;
use OCP\Util;
use Psr\Log\LoggerInterface;
@@ -76,13 +77,13 @@ abstract class StoragesService {
return $config;
} catch (\UnexpectedValueException $e) {
// don't die if a storage backend doesn't exist
- \OC::$server->get(LoggerInterface::class)->error('Could not load storage.', [
+ Server::get(LoggerInterface::class)->error('Could not load storage.', [
'app' => 'files_external',
'exception' => $e,
]);
return null;
} catch (\InvalidArgumentException $e) {
- \OC::$server->get(LoggerInterface::class)->error('Could not load storage.', [
+ Server::get(LoggerInterface::class)->error('Could not load storage.', [
'app' => 'files_external',
'exception' => $e,
]);
diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php
index c5af1bddaa7..d1a8f78076a 100644
--- a/apps/files_external/templates/settings.php
+++ b/apps/files_external/templates/settings.php
@@ -107,7 +107,7 @@ function writeParameterInput($parameter, $options, $classes = []) {
</div>
<?php
- $canCreateNewLocalStorage = \OC::$server->getConfig()->getSystemValue('files_external_allow_create_new_local', true);
+ $canCreateNewLocalStorage = \OCP\Server::get(\OCP\IConfig::class)->getSystemValue('files_external_allow_create_new_local', true);
?>
<form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" data-can-create-local="<?php echo $canCreateNewLocalStorage?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>">
<h2 class="inlineblock" data-anchor-name="external-storage"><?php p($l->t('External storage')); ?></h2>
@@ -168,7 +168,7 @@ uasort($sortedBackends, function ($a, $b) {
continue;
} // ignore deprecated backends?>
<option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option>
- <?php endforeach; ?>
+<?php endforeach; ?>
</select>
</td>
<td class="authentication" data-mechanisms='<?php p(json_encode($_['authMechanisms'])); ?>'></td>
diff --git a/apps/files_external/tests/Service/DBConfigServiceTest.php b/apps/files_external/tests/Service/DBConfigServiceTest.php
index 968c166a505..51051d6c9f2 100644
--- a/apps/files_external/tests/Service/DBConfigServiceTest.php
+++ b/apps/files_external/tests/Service/DBConfigServiceTest.php
@@ -8,6 +8,8 @@ namespace OCA\Files_External\Tests\Service;
use OCA\Files_External\Service\DBConfigService;
use OCP\IDBConnection;
+use OCP\Security\ICrypto;
+use OCP\Server;
use Test\TestCase;
/**
@@ -28,8 +30,8 @@ class DBConfigServiceTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
- $this->dbConfig = new DBConfigService($this->connection, \OC::$server->getCrypto());
+ $this->connection = Server::get(IDBConnection::class);
+ $this->dbConfig = new DBConfigService($this->connection, Server::get(ICrypto::class));
}
protected function tearDown(): void {
diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php
index 797d4382ae9..8d24b98d6af 100644
--- a/apps/files_external/tests/Service/StoragesServiceTest.php
+++ b/apps/files_external/tests/Service/StoragesServiceTest.php
@@ -10,9 +10,9 @@ use OC\Files\Cache\Storage;
use OC\Files\Filesystem;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\InvalidAuth;
-
use OCA\Files_External\Lib\Backend\Backend;
use OCA\Files_External\Lib\Backend\InvalidBackend;
+
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
@@ -25,8 +25,10 @@ use OCP\Files\Cache\ICache;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage\IStorage;
+use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
+use OCP\Security\ICrypto;
use OCP\Server;
use OCP\Util;
@@ -87,9 +89,9 @@ abstract class StoragesServiceTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto());
+ $this->dbConfig = new CleaningDBConfig(Server::get(IDBConnection::class), Server::get(ICrypto::class));
self::$hookCalls = [];
- $config = \OC::$server->getConfig();
+ $config = Server::get(IConfig::class);
$this->dataDir = $config->getSystemValue(
'datadirectory',
\OC::$SERVERROOT . '/data/'
@@ -301,7 +303,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$storageCache = new Storage($rustyStorageId, true, Server::get(IDBConnection::class));
/** @var IUserMountCache $mountCache */
- $mountCache = \OC::$server->get(IUserMountCache::class);
+ $mountCache = Server::get(IUserMountCache::class);
$mountCache->clear();
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('test');
@@ -340,7 +342,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertTrue($caught);
// storage id was removed from oc_storages
- $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $qb = Server::get(IDBConnection::class)->getQueryBuilder();
$storageCheckQuery = $qb->select('*')
->from('storages')
->where($qb->expr()->eq('numeric_id', $qb->expr()->literal($numericId)));
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
index 571664b32c8..e3c5cd486e9 100644
--- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
@@ -15,6 +15,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
+use OCP\Server;
use Test\Traits\UserTrait;
/**
@@ -47,7 +48,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$this->globalStoragesService = $this->service;
- $this->user = new User(self::USER_ID, null, \OC::$server->get(IEventDispatcher::class));
+ $this->user = new User(self::USER_ID, null, Server::get(IEventDispatcher::class));
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
$userSession
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php
index 7bf101ebfc4..a7b9f200417 100644
--- a/apps/files_external/tests/Service/UserStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php
@@ -9,12 +9,14 @@ namespace OCA\Files_External\Tests\Service;
use OC\Files\Filesystem;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\MountConfig;
-
use OCA\Files_External\NotFoundException;
use OCA\Files_External\Service\GlobalStoragesService;
+
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
+use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\Server;
use Test\Traits\UserTrait;
/**
@@ -39,7 +41,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
$this->userId = $this->getUniqueID('user_');
$this->createUser($this->userId, $this->userId);
- $this->user = \OC::$server->getUserManager()->get($this->userId);
+ $this->user = Server::get(IUserManager::class)->get($this->userId);
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
diff --git a/apps/files_external/tests/Storage/WebdavTest.php b/apps/files_external/tests/Storage/WebdavTest.php
index 872f1b5d0e2..f1d3415e91e 100644
--- a/apps/files_external/tests/Storage/WebdavTest.php
+++ b/apps/files_external/tests/Storage/WebdavTest.php
@@ -8,6 +8,8 @@ namespace OCA\Files_External\Tests\Storage;
use OC\Files\Storage\DAV;
use OC\Files\Type\Detection;
+use OCP\Files\IMimeTypeDetector;
+use OCP\Server;
/**
* Class WebdavTest
@@ -45,7 +47,7 @@ class WebdavTest extends \Test\Files\Storage\Storage {
$this->instance->file_put_contents('foo.bar', 'asd');
/** @var Detection $mimeDetector */
- $mimeDetector = \OC::$server->getMimeTypeDetector();
+ $mimeDetector = Server::get(IMimeTypeDetector::class);
$mimeDetector->registerType('bar', 'application/x-bar');
$this->assertEquals('application/x-bar', $this->instance->getMimeType('foo.bar'));