aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2024-10-28 10:19:41 +0100
committerGitHub <noreply@github.com>2024-10-28 10:19:41 +0100
commit5efb175665a71ac32fb6a6d5a141c72d12e8534c (patch)
treef27662fc76503cce1e1b0fc551db3b125396ecd7 /apps
parent2eaa9f79b4fbc76b062d9f2bd1f5cfffb2143f57 (diff)
parent0de4843b73ee4779c7e455dd80c36a6b506e0024 (diff)
downloadnextcloud-server-5efb175665a71ac32fb6a6d5a141c72d12e8534c.tar.gz
nextcloud-server-5efb175665a71ac32fb6a6d5a141c72d12e8534c.zip
Merge pull request #48614 from nextcloud/refactor/storage/constructors
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Storage/PublicOwnerWrapper.php8
-rw-r--r--apps/dav/lib/Storage/PublicShareWrapper.php8
-rw-r--r--apps/files_external/lib/Lib/SessionStorageWrapper.php9
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php2
-rw-r--r--apps/files_external/lib/Lib/Storage/FTP.php24
-rw-r--r--apps/files_external/lib/Lib/Storage/OwnCloud.php20
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php18
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php40
-rw-r--r--apps/files_external/lib/Lib/Storage/Swift.php42
-rw-r--r--apps/files_sharing/lib/SharedStorage.php14
10 files changed, 92 insertions, 93 deletions
diff --git a/apps/dav/lib/Storage/PublicOwnerWrapper.php b/apps/dav/lib/Storage/PublicOwnerWrapper.php
index 635ae04fe64..a0f1607d971 100644
--- a/apps/dav/lib/Storage/PublicOwnerWrapper.php
+++ b/apps/dav/lib/Storage/PublicOwnerWrapper.php
@@ -15,14 +15,14 @@ class PublicOwnerWrapper extends Wrapper {
private string $owner;
/**
- * @param array $arguments ['storage' => $storage, 'owner' => $owner]
+ * @param array $parameters ['storage' => $storage, 'owner' => $owner]
*
* $storage: The storage the permissions mask should be applied on
* $owner: The owner to use in case no owner is found
*/
- public function __construct($arguments) {
- parent::__construct($arguments);
- $this->owner = $arguments['owner'];
+ public function __construct(array $parameters) {
+ parent::__construct($parameters);
+ $this->owner = $parameters['owner'];
}
public function getOwner(string $path): string|false {
diff --git a/apps/dav/lib/Storage/PublicShareWrapper.php b/apps/dav/lib/Storage/PublicShareWrapper.php
index 058dbe2bcea..fb0db4dca4c 100644
--- a/apps/dav/lib/Storage/PublicShareWrapper.php
+++ b/apps/dav/lib/Storage/PublicShareWrapper.php
@@ -17,14 +17,14 @@ class PublicShareWrapper extends Wrapper implements ISharedStorage {
private IShare $share;
/**
- * @param array $arguments ['storage' => $storage, 'share' => $share]
+ * @param array $parameters ['storage' => $storage, 'share' => $share]
*
* $storage: The storage the permissions mask should be applied on
* $share: The share to use in case no share is found
*/
- public function __construct($arguments) {
- parent::__construct($arguments);
- $this->share = $arguments['share'];
+ public function __construct(array $parameters) {
+ parent::__construct($parameters);
+ $this->share = $parameters['share'];
}
public function getShare(): IShare {
diff --git a/apps/files_external/lib/Lib/SessionStorageWrapper.php b/apps/files_external/lib/Lib/SessionStorageWrapper.php
index 38e86905386..06bece3bf7c 100644
--- a/apps/files_external/lib/Lib/SessionStorageWrapper.php
+++ b/apps/files_external/lib/Lib/SessionStorageWrapper.php
@@ -13,13 +13,12 @@ use OCP\Constants;
* Wrap Storage in PermissionsMask for session ephemeral use
*/
class SessionStorageWrapper extends PermissionsMask {
-
/**
- * @param array $arguments ['storage' => $storage]
+ * @param array $parameters ['storage' => $storage]
*/
- public function __construct($arguments) {
+ public function __construct(array $parameters) {
// disable sharing permission
- $arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE;
- parent::__construct($arguments);
+ $parameters['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE;
+ parent::__construct($parameters);
}
}
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 63f08dd4131..03a365fd559 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -46,7 +46,7 @@ class AmazonS3 extends Common {
private ?bool $versioningEnabled = null;
private ICache $memCache;
- public function __construct($parameters) {
+ public function __construct(array $parameters) {
parent::__construct($parameters);
$this->parseParams($parameters);
$this->id = 'amazon::external::' . md5($this->params['hostname'] . ':' . $this->params['bucket'] . ':' . $this->params['key']);
diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php
index 142fa746184..51b269b3eb0 100644
--- a/apps/files_external/lib/Lib/Storage/FTP.php
+++ b/apps/files_external/lib/Lib/Storage/FTP.php
@@ -29,23 +29,23 @@ class FTP extends Common {
/** @var FtpConnection|null */
private $connection;
- public function __construct($params) {
- if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
- $this->host = $params['host'];
- $this->username = $params['user'];
- $this->password = $params['password'];
- if (isset($params['secure'])) {
- if (is_string($params['secure'])) {
- $this->secure = ($params['secure'] === 'true');
+ public function __construct(array $parameters) {
+ if (isset($parameters['host']) && isset($parameters['user']) && isset($parameters['password'])) {
+ $this->host = $parameters['host'];
+ $this->username = $parameters['user'];
+ $this->password = $parameters['password'];
+ if (isset($parameters['secure'])) {
+ if (is_string($parameters['secure'])) {
+ $this->secure = ($parameters['secure'] === 'true');
} else {
- $this->secure = (bool)$params['secure'];
+ $this->secure = (bool)$parameters['secure'];
}
} else {
$this->secure = false;
}
- $this->root = isset($params['root']) ? '/' . ltrim($params['root']) : '/';
- $this->port = $params['port'] ?? 21;
- $this->utf8Mode = isset($params['utf8']) && $params['utf8'];
+ $this->root = isset($parameters['root']) ? '/' . ltrim($parameters['root']) : '/';
+ $this->port = $parameters['port'] ?? 21;
+ $this->utf8Mode = isset($parameters['utf8']) && $parameters['utf8'];
} else {
throw new \Exception('Creating ' . self::class . ' storage failed, required parameters not set');
}
diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php
index ff519c60e2d..1bcf19b460e 100644
--- a/apps/files_external/lib/Lib/Storage/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php
@@ -20,17 +20,17 @@ use Sabre\DAV\Client;
class OwnCloud extends DAV implements IDisableEncryptionStorage {
public const OC_URL_SUFFIX = 'remote.php/webdav';
- public function __construct($params) {
+ public function __construct(array $parameters) {
// extract context path from host if specified
// (owncloud install path on host)
- $host = $params['host'];
+ $host = $parameters['host'];
// strip protocol
if (substr($host, 0, 8) === 'https://') {
$host = substr($host, 8);
- $params['secure'] = true;
+ $parameters['secure'] = true;
} elseif (substr($host, 0, 7) === 'http://') {
$host = substr($host, 7);
- $params['secure'] = false;
+ $parameters['secure'] = false;
}
$contextPath = '';
$hostSlashPos = strpos($host, '/');
@@ -43,17 +43,17 @@ class OwnCloud extends DAV implements IDisableEncryptionStorage {
$contextPath .= '/';
}
- if (isset($params['root'])) {
- $root = '/' . ltrim($params['root'], '/');
+ if (isset($parameters['root'])) {
+ $root = '/' . ltrim($parameters['root'], '/');
} else {
$root = '/';
}
- $params['host'] = $host;
- $params['root'] = $contextPath . self::OC_URL_SUFFIX . $root;
- $params['authType'] = Client::AUTH_BASIC;
+ $parameters['host'] = $host;
+ $parameters['root'] = $contextPath . self::OC_URL_SUFFIX . $root;
+ $parameters['authType'] = Client::AUTH_BASIC;
- parent::__construct($params);
+ parent::__construct($parameters);
}
public function needsPartFile(): bool {
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index c430cc2b5fd..44073beedec 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -57,25 +57,25 @@ class SFTP extends Common {
}
}
- public function __construct($params) {
+ public function __construct(array $parameters) {
// Register sftp://
Stream::register();
- $parsedHost = $this->splitHost($params['host']);
+ $parsedHost = $this->splitHost($parameters['host']);
$this->host = $parsedHost[0];
$this->port = $parsedHost[1];
- if (!isset($params['user'])) {
+ if (!isset($parameters['user'])) {
throw new \UnexpectedValueException('no authentication parameters specified');
}
- $this->user = $params['user'];
+ $this->user = $parameters['user'];
- if (isset($params['public_key_auth'])) {
- $this->auth[] = $params['public_key_auth'];
+ if (isset($parameters['public_key_auth'])) {
+ $this->auth[] = $parameters['public_key_auth'];
}
- if (isset($params['password']) && $params['password'] !== '') {
- $this->auth[] = $params['password'];
+ if (isset($parameters['password']) && $parameters['password'] !== '') {
+ $this->auth[] = $parameters['password'];
}
if ($this->auth === []) {
@@ -83,7 +83,7 @@ class SFTP extends Common {
}
$this->root
- = isset($params['root']) ? $this->cleanPath($params['root']) : '/';
+ = isset($parameters['root']) ? $this->cleanPath($parameters['root']) : '/';
$this->root = '/' . ltrim($this->root, '/');
$this->root = rtrim($this->root, '/') . '/';
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 0946a3d0135..dd7f1ae8224 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -69,55 +69,55 @@ class SMB extends Common implements INotifyStorage {
/** @var bool */
protected $checkAcl;
- public function __construct($params) {
- if (!isset($params['host'])) {
+ public function __construct(array $parameters) {
+ if (!isset($parameters['host'])) {
throw new \Exception('Invalid configuration, no host provided');
}
- if (isset($params['auth'])) {
- $auth = $params['auth'];
- } elseif (isset($params['user']) && isset($params['password']) && isset($params['share'])) {
- [$workgroup, $user] = $this->splitUser($params['user']);
- $auth = new BasicAuth($user, $workgroup, $params['password']);
+ if (isset($parameters['auth'])) {
+ $auth = $parameters['auth'];
+ } elseif (isset($parameters['user']) && isset($parameters['password']) && isset($parameters['share'])) {
+ [$workgroup, $user] = $this->splitUser($parameters['user']);
+ $auth = new BasicAuth($user, $workgroup, $parameters['password']);
} else {
throw new \Exception('Invalid configuration, no credentials provided');
}
- if (isset($params['logger'])) {
- if (!$params['logger'] instanceof LoggerInterface) {
+ if (isset($parameters['logger'])) {
+ if (!$parameters['logger'] instanceof LoggerInterface) {
throw new \Exception(
'Invalid logger. Got '
- . get_class($params['logger'])
+ . get_class($parameters['logger'])
. ' Expected ' . LoggerInterface::class
);
}
- $this->logger = $params['logger'];
+ $this->logger = $parameters['logger'];
} else {
$this->logger = \OCP\Server::get(LoggerInterface::class);
}
$options = new Options();
- if (isset($params['timeout'])) {
- $timeout = (int)$params['timeout'];
+ if (isset($parameters['timeout'])) {
+ $timeout = (int)$parameters['timeout'];
if ($timeout > 0) {
$options->setTimeout($timeout);
}
}
$system = \OCP\Server::get(SystemBridge::class);
$serverFactory = new ServerFactory($options, $system);
- $this->server = $serverFactory->createServer($params['host'], $auth);
- $this->share = $this->server->getShare(trim($params['share'], '/'));
+ $this->server = $serverFactory->createServer($parameters['host'], $auth);
+ $this->share = $this->server->getShare(trim($parameters['share'], '/'));
- $this->root = $params['root'] ?? '/';
+ $this->root = $parameters['root'] ?? '/';
$this->root = '/' . ltrim($this->root, '/');
$this->root = rtrim($this->root, '/') . '/';
- $this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
- $this->caseSensitive = (bool)($params['case_sensitive'] ?? true);
- $this->checkAcl = isset($params['check_acl']) && $params['check_acl'];
+ $this->showHidden = isset($parameters['show_hidden']) && $parameters['show_hidden'];
+ $this->caseSensitive = (bool)($parameters['case_sensitive'] ?? true);
+ $this->checkAcl = isset($parameters['check_acl']) && $parameters['check_acl'];
$this->statCache = new CappedMemoryCache();
- parent::__construct($params);
+ parent::__construct($parameters);
}
private function splitUser(string $user): array {
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index 70b62e56474..cb72ab8c070 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -122,44 +122,44 @@ class Swift extends Common {
return $this->fetchObject($path) !== false;
}
- public function __construct($params) {
- if ((empty($params['key']) and empty($params['password']))
- or (empty($params['user']) && empty($params['userid'])) or empty($params['bucket'])
- or empty($params['region'])
+ public function __construct(array $parameters) {
+ if ((empty($parameters['key']) and empty($parameters['password']))
+ or (empty($parameters['user']) && empty($parameters['userid'])) or empty($parameters['bucket'])
+ or empty($parameters['region'])
) {
throw new StorageBadConfigException('API Key or password, Login, Bucket and Region have to be configured.');
}
- $user = $params['user'];
- $this->id = 'swift::' . $user . md5($params['bucket']);
+ $user = $parameters['user'];
+ $this->id = 'swift::' . $user . md5($parameters['bucket']);
- $bucketUrl = new Uri($params['bucket']);
+ $bucketUrl = new Uri($parameters['bucket']);
if ($bucketUrl->getHost()) {
- $params['bucket'] = basename($bucketUrl->getPath());
- $params['endpoint_url'] = (string)$bucketUrl->withPath(dirname($bucketUrl->getPath()));
+ $parameters['bucket'] = basename($bucketUrl->getPath());
+ $parameters['endpoint_url'] = (string)$bucketUrl->withPath(dirname($bucketUrl->getPath()));
}
- if (empty($params['url'])) {
- $params['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
+ if (empty($parameters['url'])) {
+ $parameters['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
}
- if (empty($params['service_name'])) {
- $params['service_name'] = 'cloudFiles';
+ if (empty($parameters['service_name'])) {
+ $parameters['service_name'] = 'cloudFiles';
}
- $params['autocreate'] = true;
+ $parameters['autocreate'] = true;
- if (isset($params['domain'])) {
- $params['user'] = [
- 'name' => $params['user'],
- 'password' => $params['password'],
+ if (isset($parameters['domain'])) {
+ $parameters['user'] = [
+ 'name' => $parameters['user'],
+ 'password' => $parameters['password'],
'domain' => [
- 'name' => $params['domain'],
+ 'name' => $parameters['domain'],
]
];
}
- $this->params = $params;
+ $this->params = $parameters;
// FIXME: private class...
$this->objectCache = new CappedMemoryCache();
$this->connectionFactory = new SwiftFactory(
@@ -168,7 +168,7 @@ class Swift extends Common {
\OC::$server->get(LoggerInterface::class)
);
$this->objectStore = new \OC\Files\ObjectStore\Swift($this->params, $this->connectionFactory);
- $this->bucket = $params['bucket'];
+ $this->bucket = $parameters['bucket'];
$this->mimeDetector = \OC::$server->get(IMimeTypeDetector::class);
}
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 335b18d1cd8..fc1ee9341c0 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -89,16 +89,16 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
*/
protected $storage;
- public function __construct($arguments) {
- $this->ownerView = $arguments['ownerView'];
+ public function __construct(array $parameters) {
+ $this->ownerView = $parameters['ownerView'];
$this->logger = \OC::$server->get(LoggerInterface::class);
- $this->superShare = $arguments['superShare'];
- $this->groupedShares = $arguments['groupedShares'];
+ $this->superShare = $parameters['superShare'];
+ $this->groupedShares = $parameters['groupedShares'];
- $this->user = $arguments['user'];
- if (isset($arguments['sharingDisabledForUser'])) {
- $this->sharingDisabledForUser = $arguments['sharingDisabledForUser'];
+ $this->user = $parameters['user'];
+ if (isset($parameters['sharingDisabledForUser'])) {
+ $this->sharingDisabledForUser = $parameters['sharingDisabledForUser'];
} else {
$this->sharingDisabledForUser = false;
}