mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
refactor: Run rector on lib/private
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
parent
5d0d0c17e5
commit
7b6078875b
370 changed files with 2595 additions and 3249 deletions
|
|
@ -108,6 +108,7 @@ class TagsPlugin extends \Sabre\DAV\ServerPlugin {
|
|||
private function getTagger() {
|
||||
if (!$this->tagger) {
|
||||
$this->tagger = $this->tagManager->load('files');
|
||||
assert($this->tagger !== null);
|
||||
}
|
||||
return $this->tagger;
|
||||
}
|
||||
|
|
|
|||
6
apps/files_sharing/lib/External/Scanner.php
vendored
6
apps/files_sharing/lib/External/Scanner.php
vendored
|
|
@ -13,10 +13,10 @@ use OCP\Files\NotFoundException;
|
|||
use OCP\Files\StorageInvalidException;
|
||||
use OCP\Files\StorageNotAvailableException;
|
||||
|
||||
/**
|
||||
* @property Storage $storage
|
||||
*/
|
||||
class Scanner extends \OC\Files\Cache\Scanner {
|
||||
/** @var Storage */
|
||||
protected $storage;
|
||||
|
||||
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
|
||||
// Disable locking for federated shares
|
||||
parent::scan($path, $recursive, $reuse, false);
|
||||
|
|
|
|||
|
|
@ -10,17 +10,14 @@ namespace OCA\Files_Sharing;
|
|||
|
||||
use OC\Files\ObjectStore\ObjectStoreScanner;
|
||||
use OC\Files\Storage\Storage;
|
||||
use OCP\Files\Cache\IScanner;
|
||||
|
||||
/**
|
||||
* Scanner for SharedStorage
|
||||
* @property SharedStorage $storage
|
||||
*/
|
||||
class Scanner extends \OC\Files\Cache\Scanner {
|
||||
/**
|
||||
* @var SharedStorage $storage
|
||||
*/
|
||||
protected $storage;
|
||||
|
||||
private $sourceScanner;
|
||||
private ?IScanner $sourceScanner = null;
|
||||
|
||||
/**
|
||||
* Returns metadata from the shared storage, but
|
||||
|
|
@ -40,7 +37,7 @@ class Scanner extends \OC\Files\Cache\Scanner {
|
|||
return $data;
|
||||
}
|
||||
|
||||
private function getSourceScanner() {
|
||||
private function getSourceScanner(): ?IScanner {
|
||||
if ($this->sourceScanner) {
|
||||
return $this->sourceScanner;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3214,14 +3214,6 @@
|
|||
<code><![CDATA[getName]]></code>
|
||||
</UndefinedMethod>
|
||||
</file>
|
||||
<file src="lib/private/AppFramework/DependencyInjection/DIContainer.php">
|
||||
<InvalidReturnStatement>
|
||||
<code><![CDATA[$this->server]]></code>
|
||||
</InvalidReturnStatement>
|
||||
<InvalidReturnType>
|
||||
<code><![CDATA[\OCP\IServerContainer]]></code>
|
||||
</InvalidReturnType>
|
||||
</file>
|
||||
<file src="lib/private/AppFramework/Http/Output.php">
|
||||
<InvalidReturnStatement>
|
||||
<code><![CDATA[@readfile($path)]]></code>
|
||||
|
|
@ -3261,9 +3253,6 @@
|
|||
<NoInterfaceProperties>
|
||||
<code><![CDATA[$this->request->server]]></code>
|
||||
</NoInterfaceProperties>
|
||||
<UndefinedClass>
|
||||
<code><![CDATA[\OCA\Talk\Controller\PageController]]></code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/private/AppFramework/Services/AppConfig.php">
|
||||
<MoreSpecificImplementedParamType>
|
||||
|
|
@ -3612,18 +3601,6 @@
|
|||
<code><![CDATA[array{int, string, int}]]></code>
|
||||
</MoreSpecificReturnType>
|
||||
</file>
|
||||
<file src="lib/private/Files/Filesystem.php">
|
||||
<LessSpecificReturnStatement>
|
||||
<code><![CDATA[$mount->getStorage()]]></code>
|
||||
<code><![CDATA[self::getMountManager()->findByNumericId($id)]]></code>
|
||||
<code><![CDATA[self::getMountManager()->findByStorageId($id)]]></code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType>
|
||||
<code><![CDATA[Mount\MountPoint[]]]></code>
|
||||
<code><![CDATA[Mount\MountPoint[]]]></code>
|
||||
<code><![CDATA[\OC\Files\Storage\Storage|null]]></code>
|
||||
</MoreSpecificReturnType>
|
||||
</file>
|
||||
<file src="lib/private/Files/Mount/MountPoint.php">
|
||||
<UndefinedInterfaceMethod>
|
||||
<code><![CDATA[wrap]]></code>
|
||||
|
|
@ -3799,32 +3776,7 @@
|
|||
<code><![CDATA[is_null($this->getContent())]]></code>
|
||||
</TypeDoesNotContainNull>
|
||||
</file>
|
||||
<file src="lib/private/Group/Group.php">
|
||||
<LessSpecificReturnStatement>
|
||||
<code><![CDATA[$users]]></code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType>
|
||||
<code><![CDATA[\OC\User\User[]]]></code>
|
||||
</MoreSpecificReturnType>
|
||||
<RedundantCondition>
|
||||
<code><![CDATA[$this->emitter]]></code>
|
||||
<code><![CDATA[$this->emitter]]></code>
|
||||
<code><![CDATA[$this->emitter]]></code>
|
||||
</RedundantCondition>
|
||||
<UndefinedMethod>
|
||||
<code><![CDATA[addToGroup]]></code>
|
||||
<code><![CDATA[countUsersInGroup]]></code>
|
||||
<code><![CDATA[deleteGroup]]></code>
|
||||
<code><![CDATA[removeFromGroup]]></code>
|
||||
</UndefinedMethod>
|
||||
</file>
|
||||
<file src="lib/private/Group/Manager.php">
|
||||
<LessSpecificReturnStatement>
|
||||
<code><![CDATA[$groups]]></code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType>
|
||||
<code><![CDATA[\OC\Group\Group[]]]></code>
|
||||
</MoreSpecificReturnType>
|
||||
<UndefinedInterfaceMethod>
|
||||
<code><![CDATA[createGroup]]></code>
|
||||
<code><![CDATA[getGroupDetails]]></code>
|
||||
|
|
@ -3913,11 +3865,6 @@
|
|||
<code><![CDATA[mixed]]></code>
|
||||
</LessSpecificImplementedReturnType>
|
||||
</file>
|
||||
<file src="lib/private/Notification/Manager.php">
|
||||
<UndefinedClass>
|
||||
<code><![CDATA[\OCA\Notifications\App]]></code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/private/Profile/Actions/FediverseAction.php">
|
||||
<NoValue>
|
||||
<code><![CDATA[$instance]]></code>
|
||||
|
|
@ -3979,25 +3926,6 @@
|
|||
<code><![CDATA[setPassword]]></code>
|
||||
</InternalMethod>
|
||||
</file>
|
||||
<file src="lib/private/Server.php">
|
||||
<ImplementedReturnTypeMismatch>
|
||||
<code><![CDATA[\OCP\Files\Folder|null]]></code>
|
||||
</ImplementedReturnTypeMismatch>
|
||||
<LessSpecificReturnStatement>
|
||||
<code><![CDATA[$this->get(IFile::class)]]></code>
|
||||
<code><![CDATA[$this->get(IGroupManager::class)]]></code>
|
||||
<code><![CDATA[$this->get(IUserManager::class)]]></code>
|
||||
<code><![CDATA[$this->get(IUserSession::class)]]></code>
|
||||
<code><![CDATA[$this->get(\OCP\Encryption\IManager::class)]]></code>
|
||||
</LessSpecificReturnStatement>
|
||||
<MoreSpecificReturnType>
|
||||
<code><![CDATA[\OC\Encryption\File]]></code>
|
||||
<code><![CDATA[\OC\Encryption\Manager]]></code>
|
||||
<code><![CDATA[\OC\Group\Manager]]></code>
|
||||
<code><![CDATA[\OC\User\Manager]]></code>
|
||||
<code><![CDATA[\OC\User\Session]]></code>
|
||||
</MoreSpecificReturnType>
|
||||
</file>
|
||||
<file src="lib/private/ServerContainer.php">
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$this->hasNoAppContainer]]></code>
|
||||
|
|
@ -4035,11 +3963,6 @@
|
|||
<code><![CDATA[$this->dbprettyname]]></code>
|
||||
</UndefinedThisPropertyFetch>
|
||||
</file>
|
||||
<file src="lib/private/Share20/Manager.php">
|
||||
<UndefinedClass>
|
||||
<code><![CDATA[\OCA\Circles\Api\v1\Circles]]></code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/private/Share20/ProviderFactory.php">
|
||||
<InvalidReturnStatement>
|
||||
<code><![CDATA[$provider]]></code>
|
||||
|
|
@ -4065,14 +3988,6 @@
|
|||
<code><![CDATA[getSupportedApps]]></code>
|
||||
</UndefinedInterfaceMethod>
|
||||
</file>
|
||||
<file src="lib/private/TagManager.php">
|
||||
<InvalidNullableReturnType>
|
||||
<code><![CDATA[\OCP\ITags]]></code>
|
||||
</InvalidNullableReturnType>
|
||||
<NullableReturnStatement>
|
||||
<code><![CDATA[null]]></code>
|
||||
</NullableReturnStatement>
|
||||
</file>
|
||||
<file src="lib/private/Tags.php">
|
||||
<InvalidScalarArgument>
|
||||
<code><![CDATA[$from]]></code>
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ return (require 'rector-shared.php')
|
|||
$nextcloudDir . '/remote.php',
|
||||
$nextcloudDir . '/status.php',
|
||||
$nextcloudDir . '/version.php',
|
||||
$nextcloudDir . '/lib/private/Share20/ProviderFactory.php',
|
||||
$nextcloudDir . '/lib/private/Template',
|
||||
$nextcloudDir . '/lib/private',
|
||||
$nextcloudDir . '/tests',
|
||||
// $nextcloudDir . '/config',
|
||||
// $nextcloudDir . '/lib',
|
||||
// $nextcloudDir . '/themes',
|
||||
])
|
||||
->withTypeCoverageLevel(0);
|
||||
|
|
|
|||
|
|
@ -11,14 +11,12 @@ use OCP\Activity\IEventMerger;
|
|||
use OCP\IL10N;
|
||||
|
||||
class EventMerger implements IEventMerger {
|
||||
/** @var IL10N */
|
||||
protected $l10n;
|
||||
|
||||
/**
|
||||
* @param IL10N $l10n
|
||||
*/
|
||||
public function __construct(IL10N $l10n) {
|
||||
$this->l10n = $l10n;
|
||||
public function __construct(
|
||||
protected IL10N $l10n,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use OCP\IUser;
|
|||
use OCP\IUserSession;
|
||||
use OCP\RichObjectStrings\IRichTextFormatter;
|
||||
use OCP\RichObjectStrings\IValidator;
|
||||
use OCP\Server;
|
||||
|
||||
class Manager implements IManager {
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ class Manager implements IManager {
|
|||
private $consumers = [];
|
||||
|
||||
/**
|
||||
* @return \OCP\Activity\IConsumer[]
|
||||
* @return IConsumer[]
|
||||
*/
|
||||
protected function getConsumers(): array {
|
||||
if (!empty($this->consumers)) {
|
||||
|
|
@ -183,7 +184,7 @@ class Manager implements IManager {
|
|||
public function getFilters(): array {
|
||||
foreach ($this->filterClasses as $class => $false) {
|
||||
/** @var IFilter $filter */
|
||||
$filter = \OCP\Server::get($class);
|
||||
$filter = Server::get($class);
|
||||
|
||||
if (!$filter instanceof IFilter) {
|
||||
throw new \InvalidArgumentException('Invalid activity filter registered');
|
||||
|
|
@ -230,7 +231,7 @@ class Manager implements IManager {
|
|||
public function getProviders(): array {
|
||||
foreach ($this->providerClasses as $class => $false) {
|
||||
/** @var IProvider $provider */
|
||||
$provider = \OCP\Server::get($class);
|
||||
$provider = Server::get($class);
|
||||
|
||||
if (!$provider instanceof IProvider) {
|
||||
throw new \InvalidArgumentException('Invalid activity provider registered');
|
||||
|
|
@ -264,7 +265,7 @@ class Manager implements IManager {
|
|||
public function getSettings(): array {
|
||||
foreach ($this->settingsClasses as $class => $false) {
|
||||
/** @var ISetting $setting */
|
||||
$setting = \OCP\Server::get($class);
|
||||
$setting = Server::get($class);
|
||||
|
||||
if ($setting instanceof ISetting) {
|
||||
if (!$setting instanceof ActivitySettings) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use OCP\Config\IUserConfig;
|
|||
use OCP\Config\ValueType;
|
||||
use OCP\IConfig;
|
||||
use OCP\PreConditionNotMetException;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
* Class to combine all the configuration options Nextcloud offers
|
||||
|
|
@ -24,7 +25,7 @@ class AllConfig implements IConfig {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets and deletes system-wide values
|
||||
* Sets and deletes system wide values
|
||||
*
|
||||
* @param array $configs Associative array with `key => value` pairs
|
||||
* If value is null, the config key will be deleted
|
||||
|
|
@ -124,7 +125,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 29.0.0 Use {@see IAppConfig} directly
|
||||
*/
|
||||
public function getAppKeys($appName) {
|
||||
return \OC::$server->get(AppConfig::class)->getKeys($appName);
|
||||
return Server::get(AppConfig::class)->getKeys($appName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -136,7 +137,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 29.0.0 Use {@see IAppConfig} directly
|
||||
*/
|
||||
public function setAppValue($appName, $key, $value) {
|
||||
\OC::$server->get(AppConfig::class)->setValue($appName, $key, $value);
|
||||
Server::get(AppConfig::class)->setValue($appName, $key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -149,7 +150,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 29.0.0 Use {@see IAppConfig} directly
|
||||
*/
|
||||
public function getAppValue($appName, $key, $default = '') {
|
||||
return \OC::$server->get(AppConfig::class)->getValue($appName, $key, $default) ?? $default;
|
||||
return Server::get(AppConfig::class)->getValue($appName, $key, $default) ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -160,7 +161,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 29.0.0 Use {@see IAppConfig} directly
|
||||
*/
|
||||
public function deleteAppValue($appName, $key) {
|
||||
\OC::$server->get(AppConfig::class)->deleteKey($appName, $key);
|
||||
Server::get(AppConfig::class)->deleteKey($appName, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -170,7 +171,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 29.0.0 Use {@see IAppConfig} directly
|
||||
*/
|
||||
public function deleteAppValues($appName) {
|
||||
\OC::$server->get(AppConfig::class)->deleteApp($appName);
|
||||
Server::get(AppConfig::class)->deleteApp($appName);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -183,7 +184,7 @@ class AllConfig implements IConfig {
|
|||
* @param string|float|int $value the value that you want to store
|
||||
* @param string $preCondition only update if the config value was previously the value passed as $preCondition
|
||||
*
|
||||
* @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
|
||||
* @throws PreConditionNotMetException if a precondition is specified and is not met
|
||||
* @throws \UnexpectedValueException when trying to store an unexpected value
|
||||
* @deprecated 31.0.0 - use {@see IUserConfig} directly
|
||||
* @see IUserConfig::getValueString
|
||||
|
|
@ -198,7 +199,7 @@ class AllConfig implements IConfig {
|
|||
}
|
||||
|
||||
/** @var UserConfig $userPreferences */
|
||||
$userPreferences = \OCP\Server::get(IUserConfig::class);
|
||||
$userPreferences = Server::get(IUserConfig::class);
|
||||
if ($preCondition !== null) {
|
||||
try {
|
||||
if ($userPreferences->hasKey($userId, $appName, $key) && $userPreferences->getValueMixed($userId, $appName, $key) !== (string)$preCondition) {
|
||||
|
|
@ -232,7 +233,7 @@ class AllConfig implements IConfig {
|
|||
return $default;
|
||||
}
|
||||
/** @var UserConfig $userPreferences */
|
||||
$userPreferences = \OCP\Server::get(IUserConfig::class);
|
||||
$userPreferences = Server::get(IUserConfig::class);
|
||||
// because $default can be null ...
|
||||
if (!$userPreferences->hasKey($userId, $appName, $key)) {
|
||||
return $default;
|
||||
|
|
@ -250,7 +251,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 31.0.0 - use {@see IUserConfig::getKeys} directly
|
||||
*/
|
||||
public function getUserKeys($userId, $appName) {
|
||||
return \OCP\Server::get(IUserConfig::class)->getKeys($userId, $appName);
|
||||
return Server::get(IUserConfig::class)->getKeys($userId, $appName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -263,7 +264,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 31.0.0 - use {@see IUserConfig::deleteUserConfig} directly
|
||||
*/
|
||||
public function deleteUserValue($userId, $appName, $key) {
|
||||
\OCP\Server::get(IUserConfig::class)->deleteUserConfig($userId, $appName, $key);
|
||||
Server::get(IUserConfig::class)->deleteUserConfig($userId, $appName, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -277,7 +278,7 @@ class AllConfig implements IConfig {
|
|||
if ($userId === null) {
|
||||
return;
|
||||
}
|
||||
\OCP\Server::get(IUserConfig::class)->deleteAllUserConfig($userId);
|
||||
Server::get(IUserConfig::class)->deleteAllUserConfig($userId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -288,7 +289,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 31.0.0 - use {@see IUserConfig::deleteApp} directly
|
||||
*/
|
||||
public function deleteAppFromAllUsers($appName) {
|
||||
\OCP\Server::get(IUserConfig::class)->deleteApp($appName);
|
||||
Server::get(IUserConfig::class)->deleteApp($appName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -308,7 +309,7 @@ class AllConfig implements IConfig {
|
|||
return [];
|
||||
}
|
||||
|
||||
$values = \OCP\Server::get(IUserConfig::class)->getAllValues($userId);
|
||||
$values = Server::get(IUserConfig::class)->getAllValues($userId);
|
||||
$result = [];
|
||||
foreach ($values as $app => $list) {
|
||||
foreach ($list as $key => $value) {
|
||||
|
|
@ -329,7 +330,7 @@ class AllConfig implements IConfig {
|
|||
* @deprecated 31.0.0 - use {@see IUserConfig::getValuesByUsers} directly
|
||||
*/
|
||||
public function getUserValueForUsers($appName, $key, $userIds) {
|
||||
return \OCP\Server::get(IUserConfig::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds);
|
||||
return Server::get(IUserConfig::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -344,7 +345,7 @@ class AllConfig implements IConfig {
|
|||
*/
|
||||
public function getUsersForUserValue($appName, $key, $value) {
|
||||
/** @var list<string> $result */
|
||||
$result = iterator_to_array(\OCP\Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value));
|
||||
$result = iterator_to_array(Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value));
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use OC\AppConfig;
|
|||
use OC\AppFramework\Bootstrap\Coordinator;
|
||||
use OC\Config\ConfigManager;
|
||||
use OC\DB\MigrationService;
|
||||
use OC\Migration\BackgroundRepair;
|
||||
use OCP\Activity\IManager as IActivityManager;
|
||||
use OCP\App\AppPathNotFoundException;
|
||||
use OCP\App\Events\AppDisableEvent;
|
||||
|
|
@ -211,7 +212,7 @@ class AppManager implements IAppManager {
|
|||
/**
|
||||
* List all apps enabled for a user
|
||||
*
|
||||
* @param \OCP\IUser $user
|
||||
* @param IUser $user
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getEnabledAppsForUser(IUser $user) {
|
||||
|
|
@ -344,7 +345,7 @@ class AppManager implements IAppManager {
|
|||
* Check if an app is enabled for user
|
||||
*
|
||||
* @param string $appId
|
||||
* @param \OCP\IUser|null $user (optional) if not defined, the currently logged in user will be used
|
||||
* @param IUser|null $user (optional) if not defined, the currently logged in user will be used
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabledForUser($appId, $user = null) {
|
||||
|
|
@ -465,7 +466,7 @@ class AppManager implements IAppManager {
|
|||
]);
|
||||
return;
|
||||
}
|
||||
$eventLogger = \OC::$server->get(IEventLogger::class);
|
||||
$eventLogger = Server::get(IEventLogger::class);
|
||||
$eventLogger->start("bootstrap:load_app:$app", "Load app: $app");
|
||||
|
||||
// in case someone calls loadApp() directly
|
||||
|
|
@ -483,7 +484,7 @@ class AppManager implements IAppManager {
|
|||
$eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it");
|
||||
$info = $this->getAppInfo($app);
|
||||
if (!empty($info['activity'])) {
|
||||
$activityManager = \OC::$server->get(IActivityManager::class);
|
||||
$activityManager = Server::get(IActivityManager::class);
|
||||
if (!empty($info['activity']['filters'])) {
|
||||
foreach ($info['activity']['filters'] as $filter) {
|
||||
$activityManager->registerFilter($filter);
|
||||
|
|
@ -502,7 +503,7 @@ class AppManager implements IAppManager {
|
|||
}
|
||||
|
||||
if (!empty($info['settings'])) {
|
||||
$settingsManager = \OCP\Server::get(ISettingsManager::class);
|
||||
$settingsManager = Server::get(ISettingsManager::class);
|
||||
if (!empty($info['settings']['admin'])) {
|
||||
foreach ($info['settings']['admin'] as $setting) {
|
||||
$settingsManager->registerSetting('admin', $setting);
|
||||
|
|
@ -547,10 +548,10 @@ class AppManager implements IAppManager {
|
|||
'shareType' => $plugin['@attributes']['share-type'],
|
||||
'class' => $plugin['@value'],
|
||||
];
|
||||
$collaboratorSearch ??= \OC::$server->get(ICollaboratorSearch::class);
|
||||
$collaboratorSearch ??= Server::get(ICollaboratorSearch::class);
|
||||
$collaboratorSearch->registerPlugin($pluginInfo);
|
||||
} elseif ($plugin['@attributes']['type'] === 'autocomplete-sort') {
|
||||
$autoCompleteManager ??= \OC::$server->get(IAutoCompleteManager::class);
|
||||
$autoCompleteManager ??= Server::get(IAutoCompleteManager::class);
|
||||
$autoCompleteManager->registerSorter($plugin['@value']);
|
||||
}
|
||||
}
|
||||
|
|
@ -1075,7 +1076,7 @@ class AppManager implements IAppManager {
|
|||
\OC_App::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
|
||||
$queue = Server::get(IJobList::class);
|
||||
foreach ($appData['repair-steps']['live-migration'] as $step) {
|
||||
$queue->add(\OC\Migration\BackgroundRepair::class, [
|
||||
$queue->add(BackgroundRepair::class, [
|
||||
'app' => $appId,
|
||||
'step' => $step]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ namespace OC\App;
|
|||
|
||||
use OCP\IBinaryFinder;
|
||||
use OCP\IConfig;
|
||||
use OCP\Server;
|
||||
use OCP\Util;
|
||||
|
||||
/**
|
||||
* Class Platform
|
||||
|
|
@ -32,7 +34,7 @@ class Platform {
|
|||
}
|
||||
|
||||
public function getOcVersion(): string {
|
||||
$v = \OCP\Util::getVersion();
|
||||
$v = Util::getVersion();
|
||||
return implode('.', $v);
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +55,7 @@ class Platform {
|
|||
* @param $command
|
||||
*/
|
||||
public function isCommandKnown(string $command): bool {
|
||||
return \OCP\Server::get(IBinaryFinder::class)->findBinaryPath($command) !== false;
|
||||
return Server::get(IBinaryFinder::class)->findBinaryPath($command) !== false;
|
||||
}
|
||||
|
||||
public function getLibraryVersion(string $name): ?string {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use OCP\ICacheFactory;
|
|||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -85,7 +86,7 @@ class AppConfig implements IAppConfig {
|
|||
public readonly CacheFactory $cacheFactory,
|
||||
) {
|
||||
if ($config->getSystemValueBool('cache_app_config', true) && $cacheFactory->isLocalCacheAvailable()) {
|
||||
$cacheFactory->withServerVersionPrefix(function (ICacheFactory $factory) {
|
||||
$cacheFactory->withServerVersionPrefix(function (ICacheFactory $factory): void {
|
||||
$this->localCache = $factory->createLocal();
|
||||
});
|
||||
}
|
||||
|
|
@ -1783,7 +1784,7 @@ class AppConfig implements IAppConfig {
|
|||
public function getConfigDetailsFromLexicon(string $appId): array {
|
||||
if (!array_key_exists($appId, $this->configLexiconDetails)) {
|
||||
$entries = $aliases = [];
|
||||
$bootstrapCoordinator = \OCP\Server::get(Coordinator::class);
|
||||
$bootstrapCoordinator = Server::get(Coordinator::class);
|
||||
$configLexicon = $bootstrapCoordinator->getRegistrationContext()?->getConfigLexicon($appId);
|
||||
foreach ($configLexicon?->getAppConfigs() ?? [] as $configEntry) {
|
||||
$entries[$configEntry->getKey()] = $configEntry;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use OCP\Diagnostics\IEventLogger;
|
|||
use OCP\HintException;
|
||||
use OCP\IRequest;
|
||||
use OCP\Profiler\IProfiler;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
* Entry point for every request in your app. You can consider this as your
|
||||
|
|
@ -46,7 +47,7 @@ class App {
|
|||
return $topNamespace . self::$nameSpaceCache[$appId];
|
||||
}
|
||||
|
||||
$appInfo = \OCP\Server::get(IAppManager::class)->getAppInfo($appId);
|
||||
$appInfo = Server::get(IAppManager::class)->getAppInfo($appId);
|
||||
if (isset($appInfo['namespace'])) {
|
||||
self::$nameSpaceCache[$appId] = trim($appInfo['namespace']);
|
||||
} else {
|
||||
|
|
@ -93,7 +94,7 @@ class App {
|
|||
// Disable profiler on the profiler UI
|
||||
$profiler->setEnabled($profiler->isEnabled() && !is_null($urlParams) && isset($urlParams['_route']) && !str_starts_with($urlParams['_route'], 'profiler.'));
|
||||
if ($profiler->isEnabled()) {
|
||||
\OC::$server->get(IEventLogger::class)->activate();
|
||||
Server::get(IEventLogger::class)->activate();
|
||||
$profiler->add(new RoutingDataCollector($container['appName'], $controllerName, $methodName));
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +186,7 @@ class App {
|
|||
$expireDate,
|
||||
$container->getServer()->getWebRoot(),
|
||||
null,
|
||||
$container->getServer()->getRequest()->getServerProtocol() === 'https',
|
||||
$container->getServer()->get(IRequest::class)->getServerProtocol() === 'https',
|
||||
true,
|
||||
$sameSite
|
||||
);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,9 @@ namespace OC\AppFramework\Bootstrap;
|
|||
* @psalm-immutable
|
||||
*/
|
||||
abstract class ARegistration {
|
||||
/** @var string */
|
||||
private $appId;
|
||||
|
||||
public function __construct(string $appId) {
|
||||
$this->appId = $appId;
|
||||
public function __construct(
|
||||
private string $appId,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,11 +13,9 @@ use OCP\AppFramework\IAppContainer;
|
|||
use OCP\IServerContainer;
|
||||
|
||||
class BootContext implements IBootContext {
|
||||
/** @var IAppContainer */
|
||||
private $appContainer;
|
||||
|
||||
public function __construct(IAppContainer $appContainer) {
|
||||
$this->appContainer = $appContainer;
|
||||
public function __construct(
|
||||
private IAppContainer $appContainer,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getAppContainer(): IAppContainer {
|
||||
|
|
|
|||
|
|
@ -8,24 +8,20 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OC\AppFramework\Bootstrap;
|
||||
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
* @template-extends ServiceRegistration<\OCP\EventDispatcher\IEventListener>
|
||||
* @template-extends ServiceRegistration<IEventListener>
|
||||
*/
|
||||
class EventListenerRegistration extends ServiceRegistration {
|
||||
/** @var string */
|
||||
private $event;
|
||||
|
||||
/** @var int */
|
||||
private $priority;
|
||||
|
||||
public function __construct(string $appId,
|
||||
string $event,
|
||||
public function __construct(
|
||||
string $appId,
|
||||
private string $event,
|
||||
string $service,
|
||||
int $priority) {
|
||||
private int $priority,
|
||||
) {
|
||||
parent::__construct($appId, $service);
|
||||
$this->event = $event;
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@ use ReflectionParameter;
|
|||
use function array_map;
|
||||
|
||||
class FunctionInjector {
|
||||
/** @var ContainerInterface */
|
||||
private $container;
|
||||
|
||||
public function __construct(ContainerInterface $container) {
|
||||
$this->container = $container;
|
||||
public function __construct(
|
||||
private ContainerInterface $container,
|
||||
) {
|
||||
}
|
||||
|
||||
public function injectFn(callable $fn) {
|
||||
|
|
|
|||
|
|
@ -16,11 +16,12 @@ use OCP\AppFramework\Middleware;
|
|||
* @template-extends ServiceRegistration<Middleware>
|
||||
*/
|
||||
class MiddlewareRegistration extends ServiceRegistration {
|
||||
private bool $global;
|
||||
|
||||
public function __construct(string $appId, string $service, bool $global) {
|
||||
public function __construct(
|
||||
string $appId,
|
||||
string $service,
|
||||
private bool $global,
|
||||
) {
|
||||
parent::__construct($appId, $service);
|
||||
$this->global = $global;
|
||||
}
|
||||
|
||||
public function isGlobal(): bool {
|
||||
|
|
|
|||
|
|
@ -12,18 +12,15 @@ namespace OC\AppFramework\Bootstrap;
|
|||
* @psalm-immutable
|
||||
*/
|
||||
final class ParameterRegistration extends ARegistration {
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/** @var mixed */
|
||||
private $value;
|
||||
|
||||
public function __construct(string $appId,
|
||||
string $name,
|
||||
$value) {
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __construct(
|
||||
string $appId,
|
||||
private string $name,
|
||||
private $value,
|
||||
) {
|
||||
parent::__construct($appId);
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace OC\AppFramework\Bootstrap;
|
||||
|
||||
use OCP\Preview\IProviderV2;
|
||||
|
||||
/**
|
||||
* @psalm-immutable
|
||||
* @template-extends ServiceRegistration<\OCP\Preview\IProviderV2>
|
||||
* @template-extends ServiceRegistration<IProviderV2>
|
||||
*/
|
||||
class PreviewProviderRegistration extends ServiceRegistration {
|
||||
/** @var string */
|
||||
private $mimeTypeRegex;
|
||||
|
||||
public function __construct(string $appId,
|
||||
public function __construct(
|
||||
string $appId,
|
||||
string $service,
|
||||
string $mimeTypeRegex) {
|
||||
private string $mimeTypeRegex,
|
||||
) {
|
||||
parent::__construct($appId, $service);
|
||||
$this->mimeTypeRegex = $mimeTypeRegex;
|
||||
}
|
||||
|
||||
public function getMimeTypeRegex(): string {
|
||||
|
|
|
|||
|
|
@ -25,18 +25,21 @@ use OCP\Config\Lexicon\ILexicon;
|
|||
use OCP\Dashboard\IManager;
|
||||
use OCP\Dashboard\IWidget;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Files\Conversion\IConversionProvider;
|
||||
use OCP\Files\Template\ICustomTemplateProvider;
|
||||
use OCP\Http\WellKnown\IHandler;
|
||||
use OCP\Mail\Provider\IProvider as IMailProvider;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Profile\ILinkAction;
|
||||
use OCP\Search\IProvider;
|
||||
use OCP\Server;
|
||||
use OCP\Settings\IDeclarativeSettingsForm;
|
||||
use OCP\SetupCheck\ISetupCheck;
|
||||
use OCP\Share\IPublicShareTemplateProvider;
|
||||
use OCP\SpeechToText\ISpeechToTextProvider;
|
||||
use OCP\Support\CrashReport\IReporter;
|
||||
use OCP\Talk\ITalkBackend;
|
||||
use OCP\TaskProcessing\ITaskType;
|
||||
use OCP\Teams\ITeamResourceProvider;
|
||||
use OCP\TextProcessing\IProvider as ITextProcessingProvider;
|
||||
use OCP\Translation\ITranslationProvider;
|
||||
|
|
@ -131,8 +134,6 @@ class RegistrationContext {
|
|||
/** @var ServiceRegistration<IPublicShareTemplateProvider>[] */
|
||||
private $publicShareTemplateProviders = [];
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
/** @var ServiceRegistration<ISetupCheck>[] */
|
||||
private array $setupChecks = [];
|
||||
|
||||
|
|
@ -151,30 +152,26 @@ class RegistrationContext {
|
|||
/** @var ServiceRegistration<\OCP\TaskProcessing\IProvider>[] */
|
||||
private array $taskProcessingProviders = [];
|
||||
|
||||
/** @var ServiceRegistration<\OCP\TaskProcessing\ITaskType>[] */
|
||||
/** @var ServiceRegistration<ITaskType>[] */
|
||||
private array $taskProcessingTaskTypes = [];
|
||||
|
||||
/** @var ServiceRegistration<\OCP\Files\Conversion\IConversionProvider>[] */
|
||||
/** @var ServiceRegistration<IConversionProvider>[] */
|
||||
private array $fileConversionProviders = [];
|
||||
|
||||
/** @var ServiceRegistration<IMailProvider>[] */
|
||||
private $mailProviders = [];
|
||||
|
||||
public function __construct(LoggerInterface $logger) {
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
public function for(string $appId): IRegistrationContext {
|
||||
return new class($appId, $this) implements IRegistrationContext {
|
||||
/** @var string */
|
||||
private $appId;
|
||||
|
||||
/** @var RegistrationContext */
|
||||
private $context;
|
||||
|
||||
public function __construct(string $appId, RegistrationContext $context) {
|
||||
$this->appId = $appId;
|
||||
$this->context = $context;
|
||||
public function __construct(
|
||||
private string $appId,
|
||||
private RegistrationContext $context,
|
||||
) {
|
||||
}
|
||||
|
||||
public function registerCapability(string $capability): void {
|
||||
|
|
@ -630,14 +627,14 @@ class RegistrationContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* @psalm-param class-string<\OCP\TaskProcessing\ITaskType> $declarativeSettingsClass
|
||||
* @psalm-param class-string<ITaskType> $declarativeSettingsClass
|
||||
*/
|
||||
public function registerTaskProcessingTaskType(string $appId, string $taskProcessingTaskTypeClass) {
|
||||
$this->taskProcessingTaskTypes[] = new ServiceRegistration($appId, $taskProcessingTaskTypeClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-param class-string<\OCP\Files\Conversion\IConversionProvider> $class
|
||||
* @psalm-param class-string<IConversionProvider> $class
|
||||
*/
|
||||
public function registerFileConversionProvider(string $appId, string $class): void {
|
||||
$this->fileConversionProviders[] = new ServiceRegistration($appId, $class);
|
||||
|
|
@ -996,14 +993,14 @@ class RegistrationContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return ServiceRegistration<\OCP\TaskProcessing\ITaskType>[]
|
||||
* @return ServiceRegistration<ITaskType>[]
|
||||
*/
|
||||
public function getTaskProcessingTaskTypes(): array {
|
||||
return $this->taskProcessingTaskTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ServiceRegistration<\OCP\Files\Conversion\IConversionProvider>[]
|
||||
* @return ServiceRegistration<IConversionProvider>[]
|
||||
*/
|
||||
public function getFileConversionProviders(): array {
|
||||
return $this->fileConversionProviders;
|
||||
|
|
@ -1029,6 +1026,6 @@ class RegistrationContext {
|
|||
return null;
|
||||
}
|
||||
|
||||
return \OCP\Server::get($this->configLexiconClasses[$appId]);
|
||||
return Server::get($this->configLexiconClasses[$appId]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,28 +12,22 @@ namespace OC\AppFramework\Bootstrap;
|
|||
* @psalm-immutable
|
||||
*/
|
||||
class ServiceAliasRegistration extends ARegistration {
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var string|class-string
|
||||
*/
|
||||
private $alias;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var string|class-string
|
||||
*/
|
||||
private $target;
|
||||
|
||||
/**
|
||||
* @psalm-param string|class-string $alias
|
||||
* @paslm-param string|class-string $target
|
||||
*/
|
||||
public function __construct(string $appId,
|
||||
string $alias,
|
||||
string $target) {
|
||||
public function __construct(
|
||||
string $appId,
|
||||
/**
|
||||
* @psalm-var string|class-string
|
||||
*/
|
||||
private string $alias,
|
||||
/**
|
||||
* @psalm-var string|class-string
|
||||
*/
|
||||
private string $target,
|
||||
) {
|
||||
parent::__construct($appId);
|
||||
$this->alias = $alias;
|
||||
$this->target = $target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,29 +12,23 @@ namespace OC\AppFramework\Bootstrap;
|
|||
* @psalm-immutable
|
||||
*/
|
||||
class ServiceFactoryRegistration extends ARegistration {
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var string|class-string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
* @psalm-var callable(\Psr\Container\ContainerInterface): mixed
|
||||
*/
|
||||
private $factory;
|
||||
|
||||
/** @var bool */
|
||||
private $shared;
|
||||
|
||||
public function __construct(string $appId,
|
||||
string $alias,
|
||||
public function __construct(
|
||||
string $appId,
|
||||
/**
|
||||
* @psalm-var string|class-string
|
||||
*/
|
||||
private string $name,
|
||||
callable $target,
|
||||
bool $shared) {
|
||||
private bool $shared,
|
||||
) {
|
||||
parent::__construct($appId);
|
||||
$this->name = $alias;
|
||||
$this->factory = $target;
|
||||
$this->shared = $shared;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
|
|
|
|||
|
|
@ -13,18 +13,14 @@ namespace OC\AppFramework\Bootstrap;
|
|||
* @template T
|
||||
*/
|
||||
class ServiceRegistration extends ARegistration {
|
||||
/**
|
||||
* @var string
|
||||
* @psalm-var class-string<T>
|
||||
*/
|
||||
private $service;
|
||||
|
||||
/**
|
||||
* @psalm-param class-string<T> $service
|
||||
*/
|
||||
public function __construct(string $appId, string $service) {
|
||||
public function __construct(
|
||||
string $appId,
|
||||
private string $service,
|
||||
) {
|
||||
parent::__construct($appId);
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OC\AppFramework\DependencyInjection;
|
||||
|
||||
use OC\AppFramework\App;
|
||||
use OC\AppFramework\Bootstrap\Coordinator;
|
||||
use OC\AppFramework\Http;
|
||||
use OC\AppFramework\Http\Dispatcher;
|
||||
use OC\AppFramework\Http\Output;
|
||||
|
|
@ -32,6 +34,8 @@ use OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware;
|
|||
use OC\AppFramework\Middleware\Security\SecurityMiddleware;
|
||||
use OC\AppFramework\Middleware\SessionMiddleware;
|
||||
use OC\AppFramework\ScopedPsrLogger;
|
||||
use OC\AppFramework\Services\AppConfig;
|
||||
use OC\AppFramework\Services\InitialState;
|
||||
use OC\AppFramework\Utility\ControllerMethodReflector;
|
||||
use OC\AppFramework\Utility\SimpleContainer;
|
||||
use OC\Core\Middleware\TwoFactorMiddleware;
|
||||
|
|
@ -39,6 +43,7 @@ use OC\Diagnostics\EventLogger;
|
|||
use OC\Log\PsrLoggerAdapter;
|
||||
use OC\ServerContainer;
|
||||
use OC\Settings\AuthorizedGroupMapper;
|
||||
use OC\User\Session;
|
||||
use OCA\WorkflowEngine\Manager;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Http\IOutput;
|
||||
|
|
@ -49,6 +54,7 @@ use OCP\AppFramework\Services\IInitialState;
|
|||
use OCP\Files\AppData\IAppDataFactory;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Group\ISubAdmin;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
|
|
@ -60,19 +66,23 @@ use OCP\IServerContainer;
|
|||
use OCP\ISession;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Security\Ip\IRemoteAddress;
|
||||
use OCP\Server;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class DIContainer extends SimpleContainer implements IAppContainer {
|
||||
protected string $appName;
|
||||
private array $middleWares = [];
|
||||
private ServerContainer $server;
|
||||
|
||||
public function __construct(string $appName, array $urlParams = [], ?ServerContainer $server = null) {
|
||||
public function __construct(
|
||||
protected string $appName,
|
||||
array $urlParams = [],
|
||||
?ServerContainer $server = null,
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->appName = $appName;
|
||||
$this->registerParameter('appName', $appName);
|
||||
$this->registerParameter('appName', $this->appName);
|
||||
$this->registerParameter('urlParams', $urlParams);
|
||||
|
||||
/** @deprecated 32.0.0 */
|
||||
|
|
@ -82,7 +92,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
$server = \OC::$server;
|
||||
}
|
||||
$this->server = $server;
|
||||
$this->server->registerAppContainer($appName, $this);
|
||||
$this->server->registerAppContainer($this->appName, $this);
|
||||
|
||||
// aliases
|
||||
/** @deprecated 26.0.0 inject $appName */
|
||||
|
|
@ -99,7 +109,11 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
$this->registerService(IOutput::class, fn (ContainerInterface $c): IOutput => new Output($c->get('webRoot')));
|
||||
|
||||
$this->registerService(Folder::class, function () {
|
||||
return $this->getServer()->getUserFolder();
|
||||
$user = $this->get(IUserSession::class)->getUser();
|
||||
if ($user === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->getServer()->get(IRootFolder::class)->getUserFolder($user->getUID());
|
||||
});
|
||||
|
||||
$this->registerService(IAppData::class, function (ContainerInterface $c): IAppData {
|
||||
|
|
@ -107,7 +121,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
});
|
||||
|
||||
$this->registerService(IL10N::class, function (ContainerInterface $c) {
|
||||
return $this->getServer()->getL10N($c->get('appName'));
|
||||
return $this->getServer()->get(IFactory::class)->get($c->get('appName'));
|
||||
});
|
||||
|
||||
// Log wrappers
|
||||
|
|
@ -199,11 +213,11 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
$c->get(IURLGenerator::class),
|
||||
$c->get(LoggerInterface::class),
|
||||
$c->get('appName'),
|
||||
$server->getUserSession()->isLoggedIn(),
|
||||
$server->get(IUserSession::class)->isLoggedIn(),
|
||||
$c->get(IGroupManager::class),
|
||||
$c->get(ISubAdmin::class),
|
||||
$c->get(IAppManager::class),
|
||||
$server->getL10N('lib'),
|
||||
$server->get(IFactory::class)->get('lib'),
|
||||
$c->get(AuthorizedGroupMapper::class),
|
||||
$c->get(IUserSession::class),
|
||||
$c->get(IRemoteAddress::class),
|
||||
|
|
@ -218,7 +232,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
$dispatcher->registerMiddleware($c->get(PublicShareMiddleware::class));
|
||||
$dispatcher->registerMiddleware($c->get(AdditionalScriptsMiddleware::class));
|
||||
|
||||
$coordinator = $c->get(\OC\AppFramework\Bootstrap\Coordinator::class);
|
||||
$coordinator = $c->get(Coordinator::class);
|
||||
$registrationContext = $coordinator->getRegistrationContext();
|
||||
if ($registrationContext !== null) {
|
||||
$appId = $this->get('appName');
|
||||
|
|
@ -237,14 +251,11 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
return $dispatcher;
|
||||
});
|
||||
|
||||
$this->registerAlias(IAppConfig::class, \OC\AppFramework\Services\AppConfig::class);
|
||||
$this->registerAlias(IInitialState::class, \OC\AppFramework\Services\InitialState::class);
|
||||
$this->registerAlias(IAppConfig::class, AppConfig::class);
|
||||
$this->registerAlias(IInitialState::class, InitialState::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\IServerContainer
|
||||
*/
|
||||
public function getServer() {
|
||||
public function getServer(): ServerContainer {
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +283,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
* @return boolean
|
||||
*/
|
||||
public function isLoggedIn() {
|
||||
return \OC::$server->getUserSession()->isLoggedIn();
|
||||
return Server::get(IUserSession::class)->isLoggedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -285,7 +296,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
}
|
||||
|
||||
private function getUserId(): string {
|
||||
return $this->getServer()->getSession()->get('user_id');
|
||||
return $this->getServer()->get(Session::class)->getSession()->get('user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -294,7 +305,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
* @param string $serviceName e.g. 'OCA\Files\Capabilities'
|
||||
*/
|
||||
public function registerCapability($serviceName) {
|
||||
$this->query('OC\CapabilitiesManager')->registerCapability(function () use ($serviceName) {
|
||||
$this->query(\OC\CapabilitiesManager::class)->registerCapability(function () use ($serviceName) {
|
||||
return $this->query($serviceName);
|
||||
});
|
||||
}
|
||||
|
|
@ -357,7 +368,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
|
|||
return parent::query($name, chain: $chain);
|
||||
} elseif ($this->appName === 'core' && str_starts_with($name, 'OC\\Core\\')) {
|
||||
return parent::query($name, chain: $chain);
|
||||
} elseif (str_starts_with($name, \OC\AppFramework\App::buildAppNamespace($this->appName) . '\\')) {
|
||||
} elseif (str_starts_with($name, App::buildAppNamespace($this->appName) . '\\')) {
|
||||
return parent::query($name, chain: $chain);
|
||||
} elseif (
|
||||
str_starts_with($name, 'OC\\AppFramework\\Services\\')
|
||||
|
|
|
|||
|
|
@ -10,18 +10,16 @@ namespace OC\AppFramework;
|
|||
use OCP\AppFramework\Http as BaseHttp;
|
||||
|
||||
class Http extends BaseHttp {
|
||||
private $server;
|
||||
private $protocolVersion;
|
||||
protected $headers;
|
||||
|
||||
/**
|
||||
* @param array $server $_SERVER
|
||||
* @param string $protocolVersion the http version to use defaults to HTTP/1.1
|
||||
*/
|
||||
public function __construct($server, $protocolVersion = 'HTTP/1.1') {
|
||||
$this->server = $server;
|
||||
$this->protocolVersion = $protocolVersion;
|
||||
|
||||
public function __construct(
|
||||
private $server,
|
||||
private $protocolVersion = 'HTTP/1.1',
|
||||
) {
|
||||
$this->headers = [
|
||||
self::STATUS_CONTINUE => 'Continue',
|
||||
self::STATUS_SWITCHING_PROTOCOLS => 'Switching Protocols',
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OC\Security\TrustedDomainHelper;
|
|||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\IRequestId;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\IpUtils;
|
||||
|
||||
|
|
@ -44,8 +45,6 @@ class Request implements \ArrayAccess, \Countable, IRequest {
|
|||
public const USER_AGENT_ANDROID_MOBILE_CHROME = '#Android.*Chrome/[.0-9]*#';
|
||||
public const USER_AGENT_FREEBOX = '#^Mozilla/5\.0$#';
|
||||
public const REGEX_LOCALHOST = '/^(127\.0\.0\.1|localhost|\[::1\])$/';
|
||||
|
||||
protected string $inputStream;
|
||||
private bool $isPutStreamContentAlreadySent = false;
|
||||
protected array $items = [];
|
||||
protected array $allowedKeys = [
|
||||
|
|
@ -60,9 +59,6 @@ class Request implements \ArrayAccess, \Countable, IRequest {
|
|||
'method',
|
||||
'requesttoken',
|
||||
];
|
||||
protected IRequestId $requestId;
|
||||
protected IConfig $config;
|
||||
protected ?CsrfTokenManager $csrfTokenManager;
|
||||
|
||||
protected bool $contentDecoded = false;
|
||||
private ?\JsonException $decodingException = null;
|
||||
|
|
@ -81,19 +77,17 @@ class Request implements \ArrayAccess, \Countable, IRequest {
|
|||
* @param IRequestId $requestId
|
||||
* @param IConfig $config
|
||||
* @param CsrfTokenManager|null $csrfTokenManager
|
||||
* @param string $stream
|
||||
* @param string $inputStream
|
||||
* @see https://www.php.net/manual/en/reserved.variables.php
|
||||
*/
|
||||
public function __construct(array $vars,
|
||||
IRequestId $requestId,
|
||||
IConfig $config,
|
||||
?CsrfTokenManager $csrfTokenManager = null,
|
||||
string $stream = 'php://input') {
|
||||
$this->inputStream = $stream;
|
||||
public function __construct(
|
||||
array $vars,
|
||||
protected IRequestId $requestId,
|
||||
protected IConfig $config,
|
||||
protected ?CsrfTokenManager $csrfTokenManager = null,
|
||||
protected string $inputStream = 'php://input',
|
||||
) {
|
||||
$this->items['params'] = [];
|
||||
$this->requestId = $requestId;
|
||||
$this->config = $config;
|
||||
$this->csrfTokenManager = $csrfTokenManager;
|
||||
|
||||
if (!array_key_exists('method', $vars)) {
|
||||
$vars['method'] = 'GET';
|
||||
|
|
@ -660,7 +654,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
|
|||
|
||||
if ($proto !== 'https' && $proto !== 'http') {
|
||||
// log unrecognized value so admin has a chance to fix it
|
||||
\OCP\Server::get(LoggerInterface::class)->critical(
|
||||
Server::get(LoggerInterface::class)->critical(
|
||||
'Server protocol is malformed [falling back to http] (check overwriteprotocol and/or X-Forwarded-Proto to remedy): ' . $proto,
|
||||
['app' => 'core']
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,13 +11,10 @@ use OCP\IRequestId;
|
|||
use OCP\Security\ISecureRandom;
|
||||
|
||||
class RequestId implements IRequestId {
|
||||
protected ISecureRandom $secureRandom;
|
||||
protected string $requestId;
|
||||
|
||||
public function __construct(string $uniqueId,
|
||||
ISecureRandom $secureRandom) {
|
||||
$this->requestId = $uniqueId;
|
||||
$this->secureRandom = $secureRandom;
|
||||
public function __construct(
|
||||
protected string $requestId,
|
||||
protected ISecureRandom $secureRandom,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ class CompressionMiddleware extends Middleware {
|
|||
/** @var bool */
|
||||
private $useGZip;
|
||||
|
||||
/** @var IRequest */
|
||||
private $request;
|
||||
|
||||
public function __construct(IRequest $request) {
|
||||
$this->request = $request;
|
||||
public function __construct(
|
||||
private IRequest $request,
|
||||
) {
|
||||
$this->useGZip = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@ use OCP\AppFramework\Middleware;
|
|||
use OCP\IRequest;
|
||||
|
||||
class NotModifiedMiddleware extends Middleware {
|
||||
/** @var IRequest */
|
||||
private $request;
|
||||
|
||||
public function __construct(IRequest $request) {
|
||||
$this->request = $request;
|
||||
public function __construct(
|
||||
private IRequest $request,
|
||||
) {
|
||||
}
|
||||
|
||||
public function afterController($controller, $methodName, Response $response) {
|
||||
|
|
|
|||
|
|
@ -20,17 +20,15 @@ use OCP\AppFramework\OCSController;
|
|||
use OCP\IRequest;
|
||||
|
||||
class OCSMiddleware extends Middleware {
|
||||
/** @var IRequest */
|
||||
private $request;
|
||||
|
||||
/** @var int */
|
||||
private $ocsVersion;
|
||||
|
||||
/**
|
||||
* @param IRequest $request
|
||||
*/
|
||||
public function __construct(IRequest $request) {
|
||||
$this->request = $request;
|
||||
public function __construct(
|
||||
private IRequest $request,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,7 +57,7 @@ class OCSMiddleware extends Middleware {
|
|||
if ($controller instanceof OCSController && $exception instanceof OCSException) {
|
||||
$code = $exception->getCode();
|
||||
if ($code === 0) {
|
||||
$code = \OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR;
|
||||
$code = OCSController::RESPOND_UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
return $this->buildNewResponse($controller, $code, $exception->getMessage());
|
||||
|
|
@ -72,7 +70,7 @@ class OCSMiddleware extends Middleware {
|
|||
* @param Controller $controller
|
||||
* @param string $methodName
|
||||
* @param Response $response
|
||||
* @return \OCP\AppFramework\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function afterController($controller, $methodName, Response $response) {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@ use OCP\AppFramework\Http\Response;
|
|||
use OCP\AppFramework\Middleware;
|
||||
|
||||
class FeaturePolicyMiddleware extends Middleware {
|
||||
/** @var FeaturePolicyManager */
|
||||
private $policyManager;
|
||||
|
||||
public function __construct(FeaturePolicyManager $policyManager) {
|
||||
$this->policyManager = $policyManager;
|
||||
public function __construct(
|
||||
private FeaturePolicyManager $policyManager,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,14 +19,10 @@ use OCP\IURLGenerator;
|
|||
* a reload but if the session variable is set we properly redirect to the login page.
|
||||
*/
|
||||
class ReloadExecutionMiddleware extends Middleware {
|
||||
/** @var ISession */
|
||||
private $session;
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
|
||||
public function __construct(ISession $session, IURLGenerator $urlGenerator) {
|
||||
$this->session = $session;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
public function __construct(
|
||||
private ISession $session,
|
||||
private IURLGenerator $urlGenerator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function beforeController($controller, $methodName) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
|
|||
use OC\AppFramework\Middleware\Security\Exceptions\StrictCookieMissingException;
|
||||
use OC\Settings\AuthorizedGroupMapper;
|
||||
use OC\User\Session;
|
||||
use OCA\Talk\Controller\PageController;
|
||||
use OCP\App\AppPathNotFoundException;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
|
@ -108,7 +109,8 @@ class SecurityMiddleware extends Middleware {
|
|||
// for normal HTML requests and not for AJAX requests
|
||||
$this->navigationManager->setActiveEntry($this->appName);
|
||||
|
||||
if (get_class($controller) === \OCA\Talk\Controller\PageController::class && $methodName === 'showCall') {
|
||||
/** @psalm-suppress UndefinedClass */
|
||||
if (get_class($controller) === PageController::class && $methodName === 'showCall') {
|
||||
$this->navigationManager->setActiveEntry('spreed');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,16 +17,10 @@ use OCP\ISession;
|
|||
use ReflectionMethod;
|
||||
|
||||
class SessionMiddleware extends Middleware {
|
||||
/** @var ControllerMethodReflector */
|
||||
private $reflector;
|
||||
|
||||
/** @var ISession */
|
||||
private $session;
|
||||
|
||||
public function __construct(ControllerMethodReflector $reflector,
|
||||
ISession $session) {
|
||||
$this->reflector = $reflector;
|
||||
$this->session = $session;
|
||||
public function __construct(
|
||||
private ControllerMethodReflector $reflector,
|
||||
private ISession $session,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,39 +21,20 @@ abstract class BaseResponse extends Response {
|
|||
/** @var array */
|
||||
protected $data;
|
||||
|
||||
/** @var string */
|
||||
protected $format;
|
||||
|
||||
/** @var ?string */
|
||||
protected $statusMessage;
|
||||
|
||||
/** @var ?int */
|
||||
protected $itemsCount;
|
||||
|
||||
/** @var ?int */
|
||||
protected $itemsPerPage;
|
||||
|
||||
/**
|
||||
* BaseResponse constructor.
|
||||
*
|
||||
* @param DataResponse<S, T, H> $dataResponse
|
||||
* @param string $format
|
||||
* @param string|null $statusMessage
|
||||
* @param int|null $itemsCount
|
||||
* @param int|null $itemsPerPage
|
||||
*/
|
||||
public function __construct(DataResponse $dataResponse,
|
||||
$format = 'xml',
|
||||
$statusMessage = null,
|
||||
$itemsCount = null,
|
||||
$itemsPerPage = null) {
|
||||
public function __construct(
|
||||
DataResponse $dataResponse,
|
||||
protected string $format = 'xml',
|
||||
protected ?string $statusMessage = null,
|
||||
protected ?int $itemsCount = null,
|
||||
protected ?int $itemsPerPage = null,
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->format = $format;
|
||||
$this->statusMessage = $statusMessage;
|
||||
$this->itemsCount = $itemsCount;
|
||||
$this->itemsPerPage = $itemsPerPage;
|
||||
|
||||
$this->data = $dataResponse->getData();
|
||||
|
||||
$this->setHeaders($dataResponse->getHeaders());
|
||||
|
|
@ -67,7 +48,7 @@ abstract class BaseResponse extends Response {
|
|||
$this->throttle($throttleMetadata);
|
||||
}
|
||||
|
||||
if ($format === 'json') {
|
||||
if ($this->format === 'json') {
|
||||
$this->addHeader(
|
||||
'Content-Type', 'application/json; charset=utf-8'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,18 +11,15 @@ use OC\AppFramework\App;
|
|||
use OC\AppFramework\DependencyInjection\DIContainer;
|
||||
|
||||
class RouteActionHandler {
|
||||
private $controllerName;
|
||||
private $actionName;
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* @param string $controllerName
|
||||
* @param string $actionName
|
||||
*/
|
||||
public function __construct(DIContainer $container, $controllerName, $actionName) {
|
||||
$this->controllerName = $controllerName;
|
||||
$this->actionName = $actionName;
|
||||
$this->container = $container;
|
||||
public function __construct(
|
||||
private DIContainer $container,
|
||||
private $controllerName,
|
||||
private $actionName,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke($params) {
|
||||
|
|
|
|||
|
|
@ -12,16 +12,10 @@ use Psr\Log\LoggerInterface;
|
|||
use function array_merge;
|
||||
|
||||
class ScopedPsrLogger implements LoggerInterface {
|
||||
/** @var LoggerInterface */
|
||||
private $inner;
|
||||
|
||||
/** @var string */
|
||||
private $appId;
|
||||
|
||||
public function __construct(LoggerInterface $inner,
|
||||
string $appId) {
|
||||
$this->inner = $inner;
|
||||
$this->appId = $appId;
|
||||
public function __construct(
|
||||
private LoggerInterface $inner,
|
||||
private string $appId,
|
||||
) {
|
||||
}
|
||||
|
||||
public function emergency($message, array $context = []): void {
|
||||
|
|
|
|||
|
|
@ -12,15 +12,10 @@ use OCP\AppFramework\Services\IInitialState;
|
|||
use OCP\IInitialStateService;
|
||||
|
||||
class InitialState implements IInitialState {
|
||||
/** @var IInitialStateService */
|
||||
private $state;
|
||||
|
||||
/** @var string */
|
||||
private $appName;
|
||||
|
||||
public function __construct(IInitialStateService $state, string $appName) {
|
||||
$this->state = $state;
|
||||
$this->appName = $appName;
|
||||
public function __construct(
|
||||
private IInitialStateService $state,
|
||||
private string $appName,
|
||||
) {
|
||||
}
|
||||
|
||||
public function provideInitialState(string $key, $data): void {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@ use Psr\Log\LoggerInterface;
|
|||
* Implementation based on https://github.com/marcj/topsort.php
|
||||
*/
|
||||
class AppScriptSort {
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(LoggerInterface $logger) {
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
namespace OC\Archive;
|
||||
|
||||
use Icewind\Streams\CallbackWrapper;
|
||||
use OCP\Files;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
|
||||
class TAR extends Archive {
|
||||
public const PLAIN = 0;
|
||||
|
|
@ -25,12 +28,11 @@ class TAR extends Archive {
|
|||
|
||||
private \Archive_Tar $tar;
|
||||
|
||||
private string $path;
|
||||
|
||||
public function __construct(string $source) {
|
||||
public function __construct(
|
||||
private string $path,
|
||||
) {
|
||||
$types = [null, 'gz', 'bz2'];
|
||||
$this->path = $source;
|
||||
$this->tar = new \Archive_Tar($source, $types[self::getTarType($source)]);
|
||||
$this->tar = new \Archive_Tar($this->path, $types[self::getTarType($this->path)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -60,7 +62,7 @@ class TAR extends Archive {
|
|||
* add an empty folder to the archive
|
||||
*/
|
||||
public function addFolder(string $path): bool {
|
||||
$tmpBase = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$tmpBase = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
$path = rtrim($path, '/') . '/';
|
||||
if ($this->fileExists($path)) {
|
||||
return false;
|
||||
|
|
@ -103,7 +105,7 @@ class TAR extends Archive {
|
|||
*/
|
||||
public function rename(string $source, string $dest): bool {
|
||||
//no proper way to delete, rename entire archive, rename file and remake archive
|
||||
$tmp = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$tmp = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
$this->tar->extract($tmp);
|
||||
rename($tmp . $source, $tmp . $dest);
|
||||
$this->tar->_close();
|
||||
|
|
@ -216,7 +218,7 @@ class TAR extends Archive {
|
|||
* extract a single file from the archive
|
||||
*/
|
||||
public function extractFile(string $path, string $dest): bool {
|
||||
$tmp = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$tmp = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
if (!$this->fileExists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -228,7 +230,7 @@ class TAR extends Archive {
|
|||
if ($success) {
|
||||
rename($tmp . $path, $dest);
|
||||
}
|
||||
\OCP\Files::rmdirr($tmp);
|
||||
Files::rmdirr($tmp);
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
|
@ -272,9 +274,9 @@ class TAR extends Archive {
|
|||
$this->fileList = false;
|
||||
$this->cachedHeaders = false;
|
||||
//no proper way to delete, extract entire archive, delete file and remake archive
|
||||
$tmp = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$tmp = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
$this->tar->extract($tmp);
|
||||
\OCP\Files::rmdirr($tmp . $path);
|
||||
Files::rmdirr($tmp . $path);
|
||||
unlink($this->path);
|
||||
$this->reopen();
|
||||
$this->tar->createModify([$tmp], '', $tmp);
|
||||
|
|
@ -293,7 +295,7 @@ class TAR extends Archive {
|
|||
} else {
|
||||
$ext = '';
|
||||
}
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||
$tmpFile = Server::get(ITempManager::class)->getTemporaryFile($ext);
|
||||
if ($this->fileExists($path)) {
|
||||
$this->extractFile($path, $tmpFile);
|
||||
} elseif ($mode === 'r' || $mode === 'rb') {
|
||||
|
|
@ -303,7 +305,7 @@ class TAR extends Archive {
|
|||
return fopen($tmpFile, $mode);
|
||||
} else {
|
||||
$handle = fopen($tmpFile, $mode);
|
||||
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
|
||||
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile): void {
|
||||
$this->writeBack($tmpFile, $path);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
namespace OC\Archive;
|
||||
|
||||
use Icewind\Streams\CallbackWrapper;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ZIP extends Archive {
|
||||
|
|
@ -16,17 +18,13 @@ class ZIP extends Archive {
|
|||
*/
|
||||
private $zip;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $path;
|
||||
|
||||
public function __construct(string $source) {
|
||||
$this->path = $source;
|
||||
public function __construct(
|
||||
private string $path,
|
||||
) {
|
||||
$this->zip = new \ZipArchive();
|
||||
if ($this->zip->open($source, \ZipArchive::CREATE)) {
|
||||
if ($this->zip->open($this->path, \ZipArchive::CREATE)) {
|
||||
} else {
|
||||
\OC::$server->get(LoggerInterface::class)->warning('Error while opening archive ' . $source, ['app' => 'files_archive']);
|
||||
Server::get(LoggerInterface::class)->warning('Error while opening archive ' . $this->path, ['app' => 'files_archive']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,12 +198,12 @@ class ZIP extends Archive {
|
|||
} else {
|
||||
$ext = '';
|
||||
}
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||
$tmpFile = Server::get(ITempManager::class)->getTemporaryFile($ext);
|
||||
if ($this->fileExists($path)) {
|
||||
$this->extractFile($path, $tmpFile);
|
||||
}
|
||||
$handle = fopen($tmpFile, $mode);
|
||||
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
|
||||
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile): void {
|
||||
$this->writeBack($tmpFile, $path);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ use OC\Authentication\Token\IToken;
|
|||
use OCP\EventDispatcher\Event;
|
||||
|
||||
abstract class ARemoteWipeEvent extends Event {
|
||||
/** @var IToken */
|
||||
private $token;
|
||||
|
||||
public function __construct(IToken $token) {
|
||||
public function __construct(
|
||||
private IToken $token,
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
public function getToken(): IToken {
|
||||
|
|
|
|||
|
|
@ -11,14 +11,11 @@ namespace OC\Authentication\Events;
|
|||
use OCP\EventDispatcher\Event;
|
||||
|
||||
class LoginFailed extends Event {
|
||||
private string $loginName;
|
||||
private ?string $password;
|
||||
|
||||
public function __construct(string $loginName, ?string $password) {
|
||||
public function __construct(
|
||||
private string $loginName,
|
||||
private ?string $password,
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->loginName = $loginName;
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
public function getLoginName(): string {
|
||||
|
|
|
|||
|
|
@ -18,18 +18,13 @@ use OCP\IUserManager;
|
|||
use OCP\Util;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<\OC\Authentication\Events\LoginFailed>
|
||||
* @template-implements IEventListener<LoginFailed>
|
||||
*/
|
||||
class LoginFailedListener implements IEventListener {
|
||||
/** @var IEventDispatcher */
|
||||
private $dispatcher;
|
||||
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
public function __construct(IEventDispatcher $dispatcher, IUserManager $userManager) {
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->userManager = $userManager;
|
||||
public function __construct(
|
||||
private IEventDispatcher $dispatcher,
|
||||
private IUserManager $userManager,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
namespace OC\Authentication\Listeners;
|
||||
|
||||
use BadMethodCallException;
|
||||
use OC\Authentication\Events\ARemoteWipeEvent;
|
||||
use OC\Authentication\Events\RemoteWipeFinished;
|
||||
use OC\Authentication\Events\RemoteWipeStarted;
|
||||
use OC\Authentication\Token\IToken;
|
||||
|
|
@ -18,19 +19,13 @@ use OCP\EventDispatcher\IEventListener;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<\OC\Authentication\Events\ARemoteWipeEvent>
|
||||
* @template-implements IEventListener<ARemoteWipeEvent>
|
||||
*/
|
||||
class RemoteWipeActivityListener implements IEventListener {
|
||||
/** @var IActvityManager */
|
||||
private $activityManager;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(IActvityManager $activityManager,
|
||||
LoggerInterface $logger) {
|
||||
$this->activityManager = $activityManager;
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private IActvityManager $activityManager,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
namespace OC\Authentication\Listeners;
|
||||
|
||||
use Exception;
|
||||
use OC\Authentication\Events\ARemoteWipeEvent;
|
||||
use OC\Authentication\Events\RemoteWipeFinished;
|
||||
use OC\Authentication\Events\RemoteWipeStarted;
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
|
@ -23,29 +24,19 @@ use Psr\Log\LoggerInterface;
|
|||
use function substr;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<\OC\Authentication\Events\ARemoteWipeEvent>
|
||||
* @template-implements IEventListener<ARemoteWipeEvent>
|
||||
*/
|
||||
class RemoteWipeEmailListener implements IEventListener {
|
||||
/** @var IMailer */
|
||||
private $mailer;
|
||||
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(IMailer $mailer,
|
||||
IUserManager $userManager,
|
||||
public function __construct(
|
||||
private IMailer $mailer,
|
||||
private IUserManager $userManager,
|
||||
IL10nFactory $l10nFactory,
|
||||
LoggerInterface $logger) {
|
||||
$this->mailer = $mailer;
|
||||
$this->userManager = $userManager;
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
$this->l10n = $l10nFactory->get('core');
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OC\Authentication\Listeners;
|
||||
|
||||
use OC\Authentication\Events\ARemoteWipeEvent;
|
||||
use OC\Authentication\Events\RemoteWipeFinished;
|
||||
use OC\Authentication\Events\RemoteWipeStarted;
|
||||
use OC\Authentication\Token\IToken;
|
||||
|
|
@ -17,19 +18,13 @@ use OCP\EventDispatcher\IEventListener;
|
|||
use OCP\Notification\IManager as INotificationManager;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<\OC\Authentication\Events\ARemoteWipeEvent>
|
||||
* @template-implements IEventListener<ARemoteWipeEvent>
|
||||
*/
|
||||
class RemoteWipeNotificationsListener implements IEventListener {
|
||||
/** @var INotificationManager */
|
||||
private $notificationManager;
|
||||
|
||||
/** @var ITimeFactory */
|
||||
private $timeFactory;
|
||||
|
||||
public function __construct(INotificationManager $notificationManager,
|
||||
ITimeFactory $timeFactory) {
|
||||
$this->notificationManager = $notificationManager;
|
||||
$this->timeFactory = $timeFactory;
|
||||
public function __construct(
|
||||
private INotificationManager $notificationManager,
|
||||
private ITimeFactory $timeFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
|
|
|||
|
|
@ -14,14 +14,12 @@ use OCP\EventDispatcher\IEventListener;
|
|||
use OCP\User\Events\UserDeletedEvent;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<\OCP\User\Events\UserDeletedEvent>
|
||||
* @template-implements IEventListener<UserDeletedEvent>
|
||||
*/
|
||||
class UserDeletedStoreCleanupListener implements IEventListener {
|
||||
/** @var Registry */
|
||||
private $registry;
|
||||
|
||||
public function __construct(Registry $registry) {
|
||||
$this->registry = $registry;
|
||||
public function __construct(
|
||||
private Registry $registry,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
|
|
|||
|
|
@ -16,19 +16,13 @@ use Psr\Log\LoggerInterface;
|
|||
use Throwable;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<\OCP\User\Events\UserDeletedEvent>
|
||||
* @template-implements IEventListener<UserDeletedEvent>
|
||||
*/
|
||||
class UserDeletedTokenCleanupListener implements IEventListener {
|
||||
/** @var Manager */
|
||||
private $manager;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(Manager $manager,
|
||||
LoggerInterface $logger) {
|
||||
$this->manager = $manager;
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private Manager $manager,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@ use OCP\User\Events\UserDeletedEvent;
|
|||
|
||||
/** @template-implements IEventListener<UserDeletedEvent> */
|
||||
class UserDeletedWebAuthnCleanupListener implements IEventListener {
|
||||
/** @var PublicKeyCredentialMapper */
|
||||
private $credentialMapper;
|
||||
|
||||
public function __construct(PublicKeyCredentialMapper $credentialMapper) {
|
||||
$this->credentialMapper = $credentialMapper;
|
||||
public function __construct(
|
||||
private PublicKeyCredentialMapper $credentialMapper,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
|
|
|||
|
|
@ -14,14 +14,12 @@ use OCP\EventDispatcher\IEventListener;
|
|||
use OCP\User\Events\PostLoginEvent;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<\OCP\User\Events\PostLoginEvent>
|
||||
* @template-implements IEventListener<PostLoginEvent>
|
||||
*/
|
||||
class UserLoggedInListener implements IEventListener {
|
||||
/** @var Manager */
|
||||
private $manager;
|
||||
|
||||
public function __construct(Manager $manager) {
|
||||
$this->manager = $manager;
|
||||
public function __construct(
|
||||
private Manager $manager,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@ namespace OC\Authentication\Login;
|
|||
use OCP\IConfig;
|
||||
|
||||
class ClearLostPasswordTokensCommand extends ALoginCommand {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
public function __construct(IConfig $config) {
|
||||
$this->config = $config;
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@ namespace OC\Authentication\Login;
|
|||
use OC\User\Session;
|
||||
|
||||
class CompleteLoginCommand extends ALoginCommand {
|
||||
/** @var Session */
|
||||
private $userSession;
|
||||
|
||||
public function __construct(Session $userSession) {
|
||||
$this->userSession = $userSession;
|
||||
public function __construct(
|
||||
private Session $userSession,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -13,16 +13,10 @@ use OC\User\Session;
|
|||
use OCP\IConfig;
|
||||
|
||||
class CreateSessionTokenCommand extends ALoginCommand {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/** @var Session */
|
||||
private $userSession;
|
||||
|
||||
public function __construct(IConfig $config,
|
||||
Session $userSession) {
|
||||
$this->config = $config;
|
||||
$this->userSession = $userSession;
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private Session $userSession,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -12,14 +12,10 @@ use OC\User\Session;
|
|||
use OCP\IConfig;
|
||||
|
||||
class FinishRememberedLoginCommand extends ALoginCommand {
|
||||
/** @var Session */
|
||||
private $userSession;
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
public function __construct(Session $userSession, IConfig $config) {
|
||||
$this->userSession = $userSession;
|
||||
$this->config = $config;
|
||||
public function __construct(
|
||||
private Session $userSession,
|
||||
private IConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -14,15 +14,10 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class LoggedInCheckCommand extends ALoginCommand {
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
/** @var IEventDispatcher */
|
||||
private $dispatcher;
|
||||
|
||||
public function __construct(LoggerInterface $logger,
|
||||
IEventDispatcher $dispatcher) {
|
||||
$this->logger = $logger;
|
||||
$this->dispatcher = $dispatcher;
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
private IEventDispatcher $dispatcher,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -11,21 +11,16 @@ namespace OC\Authentication\Login;
|
|||
use OC\Core\Controller\LoginController;
|
||||
|
||||
class LoginResult {
|
||||
/** @var bool */
|
||||
private $success;
|
||||
|
||||
/** @var LoginData */
|
||||
private $loginData;
|
||||
|
||||
/** @var string|null */
|
||||
private $redirectUrl;
|
||||
|
||||
/** @var string|null */
|
||||
private $errorMessage;
|
||||
|
||||
private function __construct(bool $success, LoginData $loginData) {
|
||||
$this->success = $success;
|
||||
$this->loginData = $loginData;
|
||||
private function __construct(
|
||||
private bool $success,
|
||||
private LoginData $loginData,
|
||||
) {
|
||||
}
|
||||
|
||||
private function setRedirectUrl(string $url) {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,9 @@ use OC\Hooks\PublicEmitter;
|
|||
use OCP\IUserManager;
|
||||
|
||||
class PreLoginHookCommand extends ALoginCommand {
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
public function __construct(IUserManager $userManager) {
|
||||
$this->userManager = $userManager;
|
||||
public function __construct(
|
||||
private IUserManager $userManager,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -14,16 +14,10 @@ use OCP\IConfig;
|
|||
use OCP\ISession;
|
||||
|
||||
class SetUserTimezoneCommand extends ALoginCommand {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/** @var ISession */
|
||||
private $session;
|
||||
|
||||
public function __construct(IConfig $config,
|
||||
ISession $session) {
|
||||
$this->config = $config;
|
||||
$this->session = $session;
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private ISession $session,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -16,21 +16,11 @@ use function array_pop;
|
|||
use function count;
|
||||
|
||||
class TwoFactorCommand extends ALoginCommand {
|
||||
/** @var Manager */
|
||||
private $twoFactorManager;
|
||||
|
||||
/** @var MandatoryTwoFactor */
|
||||
private $mandatoryTwoFactor;
|
||||
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
|
||||
public function __construct(Manager $twoFactorManager,
|
||||
MandatoryTwoFactor $mandatoryTwoFactor,
|
||||
IURLGenerator $urlGenerator) {
|
||||
$this->twoFactorManager = $twoFactorManager;
|
||||
$this->mandatoryTwoFactor = $mandatoryTwoFactor;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
public function __construct(
|
||||
private Manager $twoFactorManager,
|
||||
private MandatoryTwoFactor $mandatoryTwoFactor,
|
||||
private IURLGenerator $urlGenerator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,9 @@ use OC\User\Manager;
|
|||
use OCP\IUser;
|
||||
|
||||
class UidLoginCommand extends ALoginCommand {
|
||||
/** @var Manager */
|
||||
private $userManager;
|
||||
|
||||
public function __construct(Manager $userManager) {
|
||||
$this->userManager = $userManager;
|
||||
public function __construct(
|
||||
private Manager $userManager,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@ namespace OC\Authentication\Login;
|
|||
use OCP\ISession;
|
||||
|
||||
class UpdateLastPasswordConfirmCommand extends ALoginCommand {
|
||||
/** @var ISession */
|
||||
private $session;
|
||||
|
||||
public function __construct(ISession $session) {
|
||||
$this->session = $session;
|
||||
public function __construct(
|
||||
private ISession $session,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -13,16 +13,10 @@ use OCP\IUserManager;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class UserDisabledCheckCommand extends ALoginCommand {
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(IUserManager $userManager,
|
||||
LoggerInterface $logger) {
|
||||
$this->userManager = $userManager;
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private IUserManager $userManager,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -9,57 +9,18 @@ declare(strict_types=1);
|
|||
namespace OC\Authentication\Login;
|
||||
|
||||
class WebAuthnChain {
|
||||
/** @var UserDisabledCheckCommand */
|
||||
private $userDisabledCheckCommand;
|
||||
|
||||
/** @var LoggedInCheckCommand */
|
||||
private $loggedInCheckCommand;
|
||||
|
||||
/** @var CompleteLoginCommand */
|
||||
private $completeLoginCommand;
|
||||
|
||||
/** @var CreateSessionTokenCommand */
|
||||
private $createSessionTokenCommand;
|
||||
|
||||
/** @var ClearLostPasswordTokensCommand */
|
||||
private $clearLostPasswordTokensCommand;
|
||||
|
||||
/** @var UpdateLastPasswordConfirmCommand */
|
||||
private $updateLastPasswordConfirmCommand;
|
||||
|
||||
/** @var SetUserTimezoneCommand */
|
||||
private $setUserTimezoneCommand;
|
||||
|
||||
/** @var TwoFactorCommand */
|
||||
private $twoFactorCommand;
|
||||
|
||||
/** @var FinishRememberedLoginCommand */
|
||||
private $finishRememberedLoginCommand;
|
||||
|
||||
/** @var WebAuthnLoginCommand */
|
||||
private $webAuthnLoginCommand;
|
||||
|
||||
public function __construct(UserDisabledCheckCommand $userDisabledCheckCommand,
|
||||
WebAuthnLoginCommand $webAuthnLoginCommand,
|
||||
LoggedInCheckCommand $loggedInCheckCommand,
|
||||
CompleteLoginCommand $completeLoginCommand,
|
||||
CreateSessionTokenCommand $createSessionTokenCommand,
|
||||
ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand,
|
||||
UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand,
|
||||
SetUserTimezoneCommand $setUserTimezoneCommand,
|
||||
TwoFactorCommand $twoFactorCommand,
|
||||
FinishRememberedLoginCommand $finishRememberedLoginCommand,
|
||||
public function __construct(
|
||||
private UserDisabledCheckCommand $userDisabledCheckCommand,
|
||||
private WebAuthnLoginCommand $webAuthnLoginCommand,
|
||||
private LoggedInCheckCommand $loggedInCheckCommand,
|
||||
private CompleteLoginCommand $completeLoginCommand,
|
||||
private CreateSessionTokenCommand $createSessionTokenCommand,
|
||||
private ClearLostPasswordTokensCommand $clearLostPasswordTokensCommand,
|
||||
private UpdateLastPasswordConfirmCommand $updateLastPasswordConfirmCommand,
|
||||
private SetUserTimezoneCommand $setUserTimezoneCommand,
|
||||
private TwoFactorCommand $twoFactorCommand,
|
||||
private FinishRememberedLoginCommand $finishRememberedLoginCommand,
|
||||
) {
|
||||
$this->userDisabledCheckCommand = $userDisabledCheckCommand;
|
||||
$this->webAuthnLoginCommand = $webAuthnLoginCommand;
|
||||
$this->loggedInCheckCommand = $loggedInCheckCommand;
|
||||
$this->completeLoginCommand = $completeLoginCommand;
|
||||
$this->createSessionTokenCommand = $createSessionTokenCommand;
|
||||
$this->clearLostPasswordTokensCommand = $clearLostPasswordTokensCommand;
|
||||
$this->updateLastPasswordConfirmCommand = $updateLastPasswordConfirmCommand;
|
||||
$this->setUserTimezoneCommand = $setUserTimezoneCommand;
|
||||
$this->twoFactorCommand = $twoFactorCommand;
|
||||
$this->finishRememberedLoginCommand = $finishRememberedLoginCommand;
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@ namespace OC\Authentication\Login;
|
|||
use OCP\IUserManager;
|
||||
|
||||
class WebAuthnLoginCommand extends ALoginCommand {
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
public function __construct(IUserManager $userManager) {
|
||||
$this->userManager = $userManager;
|
||||
public function __construct(
|
||||
private IUserManager $userManager,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(LoginData $loginData): LoginResult {
|
||||
|
|
|
|||
|
|
@ -9,24 +9,16 @@ namespace OC\Authentication\LoginCredentials;
|
|||
use OCP\Authentication\LoginCredentials\ICredentials;
|
||||
|
||||
class Credentials implements ICredentials {
|
||||
/** @var string */
|
||||
private $uid;
|
||||
|
||||
/** @var string */
|
||||
private $loginName;
|
||||
|
||||
/** @var string */
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @param string $uid
|
||||
* @param string $loginName
|
||||
* @param string $password
|
||||
*/
|
||||
public function __construct($uid, $loginName, $password) {
|
||||
$this->uid = $uid;
|
||||
$this->loginName = $loginName;
|
||||
$this->password = $password;
|
||||
public function __construct(
|
||||
private $uid,
|
||||
private $loginName,
|
||||
private $password,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,25 +22,12 @@ use OCP\Util;
|
|||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Store implements IStore {
|
||||
/** @var ISession */
|
||||
private $session;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
/** @var IProvider|null */
|
||||
private $tokenProvider;
|
||||
|
||||
public function __construct(
|
||||
ISession $session,
|
||||
LoggerInterface $logger,
|
||||
private ISession $session,
|
||||
private LoggerInterface $logger,
|
||||
private readonly ICrypto $crypto,
|
||||
?IProvider $tokenProvider = null,
|
||||
private ?IProvider $tokenProvider = null,
|
||||
) {
|
||||
$this->session = $session;
|
||||
$this->logger = $logger;
|
||||
$this->tokenProvider = $tokenProvider;
|
||||
|
||||
Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@ use OCP\Notification\INotifier;
|
|||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class Notifier implements INotifier {
|
||||
/** @var IL10nFactory */
|
||||
private $factory;
|
||||
|
||||
public function __construct(IL10nFactory $l10nFactory) {
|
||||
$this->factory = $l10nFactory;
|
||||
public function __construct(
|
||||
private IL10nFactory $factory,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,11 +17,9 @@ use OCP\Authentication\Token\IToken as OCPIToken;
|
|||
use OCP\DB\Exception;
|
||||
|
||||
class Manager implements IProvider, OCPIProvider {
|
||||
/** @var PublicKeyTokenProvider */
|
||||
private $publicKeyTokenProvider;
|
||||
|
||||
public function __construct(PublicKeyTokenProvider $publicKeyTokenProvider) {
|
||||
$this->publicKeyTokenProvider = $publicKeyTokenProvider;
|
||||
public function __construct(
|
||||
private PublicKeyTokenProvider $publicKeyTokenProvider,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,53 +34,23 @@ class PublicKeyTokenProvider implements IProvider {
|
|||
|
||||
use TTransactional;
|
||||
|
||||
/** @var PublicKeyTokenMapper */
|
||||
private $mapper;
|
||||
|
||||
/** @var ICrypto */
|
||||
private $crypto;
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
private IDBConnection $db;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
/** @var ITimeFactory */
|
||||
private $time;
|
||||
|
||||
/** @var ICache */
|
||||
private $cache;
|
||||
|
||||
/** @var IHasher */
|
||||
private $hasher;
|
||||
|
||||
private IEventDispatcher $eventDispatcher;
|
||||
|
||||
public function __construct(PublicKeyTokenMapper $mapper,
|
||||
ICrypto $crypto,
|
||||
IConfig $config,
|
||||
IDBConnection $db,
|
||||
LoggerInterface $logger,
|
||||
ITimeFactory $time,
|
||||
IHasher $hasher,
|
||||
public function __construct(
|
||||
private PublicKeyTokenMapper $mapper,
|
||||
private ICrypto $crypto,
|
||||
private IConfig $config,
|
||||
private IDBConnection $db,
|
||||
private LoggerInterface $logger,
|
||||
private ITimeFactory $time,
|
||||
private IHasher $hasher,
|
||||
ICacheFactory $cacheFactory,
|
||||
IEventDispatcher $eventDispatcher,
|
||||
private IEventDispatcher $eventDispatcher,
|
||||
) {
|
||||
$this->mapper = $mapper;
|
||||
$this->crypto = $crypto;
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
$this->logger = $logger;
|
||||
$this->time = $time;
|
||||
|
||||
$this->cache = $cacheFactory->isLocalCacheAvailable()
|
||||
? $cacheFactory->createLocal('authtoken_')
|
||||
: $cacheFactory->createInMemory();
|
||||
$this->hasher = $hasher;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -365,7 +335,7 @@ class PublicKeyTokenProvider implements IProvider {
|
|||
throw new InvalidTokenException('Invalid token type');
|
||||
}
|
||||
|
||||
$this->atomic(function () use ($password, $token) {
|
||||
$this->atomic(function () use ($password, $token): void {
|
||||
// When changing passwords all temp tokens are deleted
|
||||
$this->mapper->deleteTempToken($token);
|
||||
|
||||
|
|
@ -530,7 +500,7 @@ class PublicKeyTokenProvider implements IProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
$this->atomic(function () use ($password, $uid) {
|
||||
$this->atomic(function () use ($password, $uid): void {
|
||||
// Update the password for all tokens
|
||||
$tokens = $this->mapper->getTokenByUser($uid);
|
||||
$newPasswordHash = null;
|
||||
|
|
|
|||
|
|
@ -18,21 +18,11 @@ use Psr\Log\LoggerInterface;
|
|||
use function array_filter;
|
||||
|
||||
class RemoteWipe {
|
||||
/** @var IProvider */
|
||||
private $tokenProvider;
|
||||
|
||||
/** @var IEventDispatcher */
|
||||
private $eventDispatcher;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(IProvider $tokenProvider,
|
||||
IEventDispatcher $eventDispatcher,
|
||||
LoggerInterface $logger) {
|
||||
$this->tokenProvider = $tokenProvider;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private IProvider $tokenProvider,
|
||||
private IEventDispatcher $eventDispatcher,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ use OCP\AppFramework\Utility\ITimeFactory;
|
|||
use OCP\BackgroundJob\TimedJob;
|
||||
|
||||
class TokenCleanupJob extends TimedJob {
|
||||
private IProvider $provider;
|
||||
|
||||
public function __construct(ITimeFactory $time, IProvider $provider) {
|
||||
public function __construct(
|
||||
ITimeFactory $time,
|
||||
private IProvider $provider,
|
||||
) {
|
||||
parent::__construct($time);
|
||||
$this->provider = $provider;
|
||||
// Run once a day at off-peak time
|
||||
$this->setInterval(24 * 60 * 60);
|
||||
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
|
||||
|
|
|
|||
|
|
@ -18,11 +18,9 @@ use function array_map;
|
|||
class ProviderUserAssignmentDao {
|
||||
public const TABLE_NAME = 'twofactor_providers';
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $conn;
|
||||
|
||||
public function __construct(IDBConnection $dbConn) {
|
||||
$this->conn = $dbConn;
|
||||
public function __construct(
|
||||
private IDBConnection $conn,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,15 +11,6 @@ namespace OC\Authentication\TwoFactorAuth;
|
|||
use JsonSerializable;
|
||||
|
||||
class EnforcementState implements JsonSerializable {
|
||||
/** @var bool */
|
||||
private $enforced;
|
||||
|
||||
/** @var array */
|
||||
private $enforcedGroups;
|
||||
|
||||
/** @var array */
|
||||
private $excludedGroups;
|
||||
|
||||
/**
|
||||
* EnforcementState constructor.
|
||||
*
|
||||
|
|
@ -27,12 +18,11 @@ class EnforcementState implements JsonSerializable {
|
|||
* @param string[] $enforcedGroups
|
||||
* @param string[] $excludedGroups
|
||||
*/
|
||||
public function __construct(bool $enforced,
|
||||
array $enforcedGroups = [],
|
||||
array $excludedGroups = []) {
|
||||
$this->enforced = $enforced;
|
||||
$this->enforcedGroups = $enforcedGroups;
|
||||
$this->excludedGroups = $excludedGroups;
|
||||
public function __construct(
|
||||
private bool $enforced,
|
||||
private array $enforcedGroups = [],
|
||||
private array $excludedGroups = [],
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace OC\Authentication\TwoFactorAuth;
|
|||
use BadMethodCallException;
|
||||
use Exception;
|
||||
use OC\Authentication\Token\IProvider as TokenProvider;
|
||||
use OC\User\Session;
|
||||
use OCP\Activity\IManager;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
|
|
@ -26,6 +27,8 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
use OCP\IConfig;
|
||||
use OCP\ISession;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Server;
|
||||
use OCP\Session\Exceptions\SessionNotAvailableException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use function array_diff;
|
||||
|
|
@ -37,59 +40,21 @@ class Manager {
|
|||
public const REMEMBER_LOGIN = 'two_factor_remember_login';
|
||||
public const BACKUP_CODES_PROVIDER_ID = 'backup_codes';
|
||||
|
||||
/** @var ProviderLoader */
|
||||
private $providerLoader;
|
||||
|
||||
/** @var IRegistry */
|
||||
private $providerRegistry;
|
||||
|
||||
/** @var MandatoryTwoFactor */
|
||||
private $mandatoryTwoFactor;
|
||||
|
||||
/** @var ISession */
|
||||
private $session;
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/** @var IManager */
|
||||
private $activityManager;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
/** @var TokenProvider */
|
||||
private $tokenProvider;
|
||||
|
||||
/** @var ITimeFactory */
|
||||
private $timeFactory;
|
||||
|
||||
/** @var IEventDispatcher */
|
||||
private $dispatcher;
|
||||
|
||||
/** @psalm-var array<string, bool> */
|
||||
private $userIsTwoFactorAuthenticated = [];
|
||||
|
||||
public function __construct(ProviderLoader $providerLoader,
|
||||
IRegistry $providerRegistry,
|
||||
MandatoryTwoFactor $mandatoryTwoFactor,
|
||||
ISession $session,
|
||||
IConfig $config,
|
||||
IManager $activityManager,
|
||||
LoggerInterface $logger,
|
||||
TokenProvider $tokenProvider,
|
||||
ITimeFactory $timeFactory,
|
||||
IEventDispatcher $eventDispatcher) {
|
||||
$this->providerLoader = $providerLoader;
|
||||
$this->providerRegistry = $providerRegistry;
|
||||
$this->mandatoryTwoFactor = $mandatoryTwoFactor;
|
||||
$this->session = $session;
|
||||
$this->config = $config;
|
||||
$this->activityManager = $activityManager;
|
||||
$this->logger = $logger;
|
||||
$this->tokenProvider = $tokenProvider;
|
||||
$this->timeFactory = $timeFactory;
|
||||
$this->dispatcher = $eventDispatcher;
|
||||
public function __construct(
|
||||
private ProviderLoader $providerLoader,
|
||||
private IRegistry $providerRegistry,
|
||||
private MandatoryTwoFactor $mandatoryTwoFactor,
|
||||
private ISession $session,
|
||||
private IConfig $config,
|
||||
private IManager $activityManager,
|
||||
private LoggerInterface $logger,
|
||||
private TokenProvider $tokenProvider,
|
||||
private ITimeFactory $timeFactory,
|
||||
private IEventDispatcher $dispatcher,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -239,7 +204,9 @@ class Manager {
|
|||
if ($passed) {
|
||||
if ($this->session->get(self::REMEMBER_LOGIN) === true) {
|
||||
// TODO: resolve cyclic dependency and use DI
|
||||
\OC::$server->getUserSession()->createRememberMeToken($user);
|
||||
/** @var Session $session */
|
||||
$session = Server::get(IUserSession::class);
|
||||
$session->createRememberMeToken($user);
|
||||
}
|
||||
$this->session->remove(self::SESSION_UID_KEY);
|
||||
$this->session->remove(self::REMEMBER_LOGIN);
|
||||
|
|
|
|||
|
|
@ -13,15 +13,10 @@ use OCP\IGroupManager;
|
|||
use OCP\IUser;
|
||||
|
||||
class MandatoryTwoFactor {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
|
||||
public function __construct(IConfig $config, IGroupManager $groupManager) {
|
||||
$this->config = $config;
|
||||
$this->groupManager = $groupManager;
|
||||
public function __construct(
|
||||
private IConfig $config,
|
||||
private IGroupManager $groupManager,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OCP\App\IAppManager;
|
|||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Authentication\TwoFactorAuth\IProvider;
|
||||
use OCP\IUser;
|
||||
use OCP\Server;
|
||||
|
||||
class ProviderLoader {
|
||||
public const BACKUP_CODES_APP_ID = 'twofactor_backupcodes';
|
||||
|
|
@ -46,7 +47,7 @@ class ProviderLoader {
|
|||
foreach ($providerClasses as $class) {
|
||||
try {
|
||||
$this->loadTwoFactorApp($appId);
|
||||
$provider = \OCP\Server::get($class);
|
||||
$provider = Server::get($class);
|
||||
$providers[$provider->getId()] = $provider;
|
||||
} catch (QueryException $exc) {
|
||||
// Provider class can not be resolved
|
||||
|
|
@ -60,7 +61,7 @@ class ProviderLoader {
|
|||
foreach ($registeredProviders as $provider) {
|
||||
try {
|
||||
$this->loadTwoFactorApp($provider->getAppId());
|
||||
$providerInstance = \OCP\Server::get($provider->getService());
|
||||
$providerInstance = Server::get($provider->getService());
|
||||
$providers[$providerInstance->getId()] = $providerInstance;
|
||||
} catch (QueryException $exc) {
|
||||
// Provider class can not be resolved
|
||||
|
|
|
|||
|
|
@ -16,15 +16,10 @@ use OCP\Authentication\TwoFactorAuth\IRegistry;
|
|||
use OCP\IUser;
|
||||
|
||||
class ProviderManager {
|
||||
/** @var ProviderLoader */
|
||||
private $providerLoader;
|
||||
|
||||
/** @var IRegistry */
|
||||
private $providerRegistry;
|
||||
|
||||
public function __construct(ProviderLoader $providerLoader, IRegistry $providerRegistry) {
|
||||
$this->providerLoader = $providerLoader;
|
||||
$this->providerRegistry = $providerRegistry;
|
||||
public function __construct(
|
||||
private ProviderLoader $providerLoader,
|
||||
private IRegistry $providerRegistry,
|
||||
) {
|
||||
}
|
||||
|
||||
private function getProvider(string $providerId, IUser $user): IProvider {
|
||||
|
|
|
|||
|
|
@ -19,19 +19,18 @@ class ProviderSet {
|
|||
/** @var IProvider */
|
||||
private $providers;
|
||||
|
||||
/** @var bool */
|
||||
private $providerMissing;
|
||||
|
||||
/**
|
||||
* @param IProvider[] $providers
|
||||
* @param bool $providerMissing
|
||||
*/
|
||||
public function __construct(array $providers, bool $providerMissing) {
|
||||
public function __construct(
|
||||
array $providers,
|
||||
private bool $providerMissing,
|
||||
) {
|
||||
$this->providers = [];
|
||||
foreach ($providers as $provider) {
|
||||
$this->providers[$provider->getId()] = $provider;
|
||||
}
|
||||
$this->providerMissing = $providerMissing;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,16 +20,10 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
use OCP\IUser;
|
||||
|
||||
class Registry implements IRegistry {
|
||||
/** @var ProviderUserAssignmentDao */
|
||||
private $assignmentDao;
|
||||
|
||||
/** @var IEventDispatcher */
|
||||
private $dispatcher;
|
||||
|
||||
public function __construct(ProviderUserAssignmentDao $assignmentDao,
|
||||
IEventDispatcher $dispatcher) {
|
||||
$this->assignmentDao = $assignmentDao;
|
||||
$this->dispatcher = $dispatcher;
|
||||
public function __construct(
|
||||
private ProviderUserAssignmentDao $assignmentDao,
|
||||
private IEventDispatcher $dispatcher,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getProviderStates(IUser $user): array {
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@ use Webauthn\PublicKeyCredentialSourceRepository;
|
|||
use Webauthn\PublicKeyCredentialUserEntity;
|
||||
|
||||
class CredentialRepository implements PublicKeyCredentialSourceRepository {
|
||||
/** @var PublicKeyCredentialMapper */
|
||||
private $credentialMapper;
|
||||
|
||||
public function __construct(PublicKeyCredentialMapper $credentialMapper) {
|
||||
$this->credentialMapper = $credentialMapper;
|
||||
public function __construct(
|
||||
private PublicKeyCredentialMapper $credentialMapper,
|
||||
) {
|
||||
}
|
||||
|
||||
public function findOneByCredentialId(string $publicKeyCredentialId): ?PublicKeyCredentialSource {
|
||||
|
|
|
|||
|
|
@ -37,28 +37,12 @@ use Webauthn\PublicKeyCredentialUserEntity;
|
|||
use Webauthn\TokenBinding\TokenBindingNotSupportedHandler;
|
||||
|
||||
class Manager {
|
||||
/** @var CredentialRepository */
|
||||
private $repository;
|
||||
|
||||
/** @var PublicKeyCredentialMapper */
|
||||
private $credentialMapper;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
public function __construct(
|
||||
CredentialRepository $repository,
|
||||
PublicKeyCredentialMapper $credentialMapper,
|
||||
LoggerInterface $logger,
|
||||
IConfig $config,
|
||||
private CredentialRepository $repository,
|
||||
private PublicKeyCredentialMapper $credentialMapper,
|
||||
private LoggerInterface $logger,
|
||||
private IConfig $config,
|
||||
) {
|
||||
$this->repository = $repository;
|
||||
$this->credentialMapper = $credentialMapper;
|
||||
$this->logger = $logger;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function startRegistration(IUser $user, string $serverHost): PublicKeyCredentialCreationOptions {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use OCP\Color;
|
|||
use OCP\Files\NotFoundException;
|
||||
use OCP\IAvatar;
|
||||
use OCP\IConfig;
|
||||
use OCP\Image;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +71,7 @@ abstract class Avatar implements IAvatar {
|
|||
return false;
|
||||
}
|
||||
|
||||
$avatar = new \OCP\Image();
|
||||
$avatar = new Image();
|
||||
$avatar->loadFromData($file->getContent());
|
||||
return $avatar;
|
||||
}
|
||||
|
|
@ -137,7 +138,7 @@ abstract class Avatar implements IAvatar {
|
|||
$avatar->setFont($font);
|
||||
$avatar->readImageBlob($svg);
|
||||
$avatar->setImageFormat('png');
|
||||
$image = new \OCP\Image();
|
||||
$image = new Image();
|
||||
$image->loadFromData((string)$avatar);
|
||||
return $image->data();
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use OCP\Color;
|
|||
use OCP\Files\SimpleFS\InMemoryFile;
|
||||
use OCP\Files\SimpleFS\ISimpleFile;
|
||||
use OCP\IConfig;
|
||||
use OCP\IImage;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -49,7 +50,7 @@ class GuestAvatar extends Avatar {
|
|||
/**
|
||||
* Setting avatars isn't implemented for guests.
|
||||
*
|
||||
* @param \OCP\IImage|resource|string $data
|
||||
* @param IImage|resource|string $data
|
||||
*/
|
||||
public function set($data): void {
|
||||
// unimplemented for guest user avatars
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use OCP\Files\SimpleFS\ISimpleFile;
|
|||
use OCP\Files\SimpleFS\ISimpleFolder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IImage;
|
||||
use OCP\PreConditionNotMetException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -70,8 +71,8 @@ class PlaceholderAvatar extends Avatar {
|
|||
* If there is no avatar file yet, one is generated.
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @throws \OCP\Files\NotPermittedException
|
||||
* @throws \OCP\PreConditionNotMetException
|
||||
* @throws NotPermittedException
|
||||
* @throws PreConditionNotMetException
|
||||
*/
|
||||
public function getFile(int $size, bool $darkTheme = false): ISimpleFile {
|
||||
$ext = 'png';
|
||||
|
|
@ -120,7 +121,7 @@ class PlaceholderAvatar extends Avatar {
|
|||
* @param mixed $oldValue The previous value
|
||||
* @param mixed $newValue The new value
|
||||
* @throws NotPermittedException
|
||||
* @throws \OCP\PreConditionNotMetException
|
||||
* @throws PreConditionNotMetException
|
||||
*/
|
||||
public function userChanged(string $feature, $oldValue, $newValue): void {
|
||||
$this->remove();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ use OCP\Files\SimpleFS\ISimpleFolder;
|
|||
use OCP\IConfig;
|
||||
use OCP\IImage;
|
||||
use OCP\IL10N;
|
||||
use OCP\Image;
|
||||
use OCP\PreConditionNotMetException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -80,7 +82,7 @@ class UserAvatar extends Avatar {
|
|||
return $data;
|
||||
}
|
||||
|
||||
$img = new \OCP\Image();
|
||||
$img = new Image();
|
||||
if (
|
||||
(is_resource($data) && get_resource_type($data) === 'gd')
|
||||
|| (is_object($data) && get_class($data) === \GdImage::class)
|
||||
|
|
@ -145,8 +147,8 @@ class UserAvatar extends Avatar {
|
|||
|
||||
/**
|
||||
* Removes the users avatar.
|
||||
* @throws \OCP\Files\NotPermittedException
|
||||
* @throws \OCP\PreConditionNotMetException
|
||||
* @throws NotPermittedException
|
||||
* @throws PreConditionNotMetException
|
||||
*/
|
||||
public function remove(bool $silent = false): void {
|
||||
$avatars = $this->folder->getDirectoryListing();
|
||||
|
|
@ -192,8 +194,8 @@ class UserAvatar extends Avatar {
|
|||
* If there is no avatar file yet, one is generated.
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* @throws \OCP\Files\NotPermittedException
|
||||
* @throws \OCP\PreConditionNotMetException
|
||||
* @throws NotPermittedException
|
||||
* @throws PreConditionNotMetException
|
||||
*/
|
||||
public function getFile(int $size, bool $darkTheme = false): ISimpleFile {
|
||||
$generated = $this->folder->fileExists('generated');
|
||||
|
|
@ -240,7 +242,7 @@ class UserAvatar extends Avatar {
|
|||
$data = $this->generateAvatar($userDisplayName, $size, $darkTheme);
|
||||
}
|
||||
} else {
|
||||
$avatar = new \OCP\Image();
|
||||
$avatar = new Image();
|
||||
$file = $this->folder->getFile('avatar.' . $ext);
|
||||
$avatar->loadFromData($file->getContent());
|
||||
$avatar->resize($size);
|
||||
|
|
@ -278,7 +280,7 @@ class UserAvatar extends Avatar {
|
|||
* @param mixed $oldValue The previous value
|
||||
* @param mixed $newValue The new value
|
||||
* @throws NotPermittedException
|
||||
* @throws \OCP\PreConditionNotMetException
|
||||
* @throws PreConditionNotMetException
|
||||
*/
|
||||
public function userChanged(string $feature, $oldValue, $newValue): void {
|
||||
// If the avatar is not generated (so an uploaded image) we skip this
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@ use OCP\AutoloadNotAllowedException;
|
|||
use OCP\BackgroundJob\IJob;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\BackgroundJob\IParallelAwareJob;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCP\DB\Exception;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
use OCP\Snowflake\ISnowflakeGenerator;
|
||||
use Override;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
|
|
@ -217,7 +219,7 @@ class JobList implements IJobList {
|
|||
unset($this->alreadyVisitedParallelBlocked[get_class($job)]);
|
||||
}
|
||||
|
||||
if ($job instanceof \OCP\BackgroundJob\TimedJob) {
|
||||
if ($job instanceof TimedJob) {
|
||||
$now = $this->timeFactory->getTime();
|
||||
$nextPossibleRun = $job->getLastRun() + $job->getInterval();
|
||||
if ($now < $nextPossibleRun) {
|
||||
|
|
@ -312,7 +314,7 @@ class JobList implements IJobList {
|
|||
try {
|
||||
// Try to load the job as a service
|
||||
/** @var IJob $job */
|
||||
$job = \OCP\Server::get($row['class']);
|
||||
$job = Server::get($row['class']);
|
||||
} catch (ContainerExceptionInterface $e) {
|
||||
if (class_exists($row['class'])) {
|
||||
$class = $row['class'];
|
||||
|
|
@ -363,7 +365,7 @@ class JobList implements IJobList {
|
|||
->set('last_run', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT))
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($job->getId())));
|
||||
|
||||
if ($job instanceof \OCP\BackgroundJob\TimedJob
|
||||
if ($job instanceof TimedJob
|
||||
&& !$job->isTimeSensitive()) {
|
||||
$query->set('time_sensitive', $query->createNamedParameter(IJob::TIME_INSENSITIVE));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use OCP\IBinaryFinder;
|
|||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\Util;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +48,7 @@ class BinaryFinder implements IBinaryFinder {
|
|||
return $result;
|
||||
}
|
||||
$result = false;
|
||||
if (\OCP\Util::isFunctionEnabled('exec')) {
|
||||
if (Util::isFunctionEnabled('exec')) {
|
||||
$exeSniffer = new ExecutableFinder();
|
||||
// Returns null if nothing is found
|
||||
$result = $exeSniffer->find(
|
||||
|
|
|
|||
|
|
@ -14,13 +14,10 @@ use OCP\EventDispatcher\ABroadcastedEvent;
|
|||
use OCP\EventDispatcher\Event;
|
||||
|
||||
class BroadcastEvent extends Event implements IBroadcastEvent {
|
||||
/** @var ABroadcastedEvent */
|
||||
private $event;
|
||||
|
||||
public function __construct(ABroadcastedEvent $event) {
|
||||
public function __construct(
|
||||
private ABroadcastedEvent $event,
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->event = $event;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,12 @@ namespace OC\Cache;
|
|||
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\View;
|
||||
use OC\ForbiddenException;
|
||||
use OC\User\NoUserException;
|
||||
use OCP\Files\LockNotAcquiredException;
|
||||
use OCP\ICache;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Lock\LockedException;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -22,9 +26,9 @@ class File implements ICache {
|
|||
/**
|
||||
* Returns the cache storage for the logged in user
|
||||
*
|
||||
* @return \OC\Files\View cache storage
|
||||
* @throws \OC\ForbiddenException
|
||||
* @throws \OC\User\NoUserException
|
||||
* @return View cache storage
|
||||
* @throws ForbiddenException
|
||||
* @throws NoUserException
|
||||
*/
|
||||
protected function getStorage() {
|
||||
if ($this->storage !== null) {
|
||||
|
|
@ -42,14 +46,14 @@ class File implements ICache {
|
|||
return $this->storage;
|
||||
} else {
|
||||
Server::get(LoggerInterface::class)->error('Can\'t get cache storage, user not logged in', ['app' => 'core']);
|
||||
throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
|
||||
throw new ForbiddenException('Can\t get cache storage, user not logged in');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return mixed|null
|
||||
* @throws \OC\ForbiddenException
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function get($key) {
|
||||
$result = null;
|
||||
|
|
@ -80,7 +84,7 @@ class File implements ICache {
|
|||
* @param mixed $value
|
||||
* @param int $ttl
|
||||
* @return bool|mixed
|
||||
* @throws \OC\ForbiddenException
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function set($key, $value, $ttl = 0) {
|
||||
$storage = $this->getStorage();
|
||||
|
|
@ -107,7 +111,7 @@ class File implements ICache {
|
|||
/**
|
||||
* @param string $key
|
||||
* @return bool
|
||||
* @throws \OC\ForbiddenException
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function hasKey($key) {
|
||||
$storage = $this->getStorage();
|
||||
|
|
@ -120,7 +124,7 @@ class File implements ICache {
|
|||
/**
|
||||
* @param string $key
|
||||
* @return bool|mixed
|
||||
* @throws \OC\ForbiddenException
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function remove($key) {
|
||||
$storage = $this->getStorage();
|
||||
|
|
@ -133,7 +137,7 @@ class File implements ICache {
|
|||
/**
|
||||
* @param string $prefix
|
||||
* @return bool
|
||||
* @throws \OC\ForbiddenException
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function clear($prefix = '') {
|
||||
$storage = $this->getStorage();
|
||||
|
|
@ -152,7 +156,7 @@ class File implements ICache {
|
|||
|
||||
/**
|
||||
* Runs GC
|
||||
* @throws \OC\ForbiddenException
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function gc() {
|
||||
$storage = $this->getStorage();
|
||||
|
|
@ -171,12 +175,12 @@ class File implements ICache {
|
|||
if ($mtime < $now) {
|
||||
$storage->unlink('/' . $file);
|
||||
}
|
||||
} catch (\OCP\Lock\LockedException $e) {
|
||||
} catch (LockedException $e) {
|
||||
// ignore locked chunks
|
||||
Server::get(LoggerInterface::class)->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']);
|
||||
} catch (\OCP\Files\ForbiddenException $e) {
|
||||
Server::get(LoggerInterface::class)->debug('Could not cleanup forbidden chunk "' . $file . '"', ['app' => 'core']);
|
||||
} catch (\OCP\Files\LockNotAcquiredException $e) {
|
||||
} catch (LockNotAcquiredException $e) {
|
||||
Server::get(LoggerInterface::class)->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace OC\Calendar\Resource;
|
|||
|
||||
use OC\AppFramework\Bootstrap\Coordinator;
|
||||
use OC\Calendar\ResourcesRoomsUpdater;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Calendar\Resource\IBackend;
|
||||
use OCP\Calendar\Resource\IManager;
|
||||
use OCP\IServerContainer;
|
||||
|
|
@ -69,7 +70,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* @return IBackend[]
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
* @throws QueryException
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getBackends():array {
|
||||
|
|
@ -88,7 +89,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* @param string $backendId
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function getBackend($backendId): ?IBackend {
|
||||
$backends = $this->getBackends();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace OC\Calendar\Room;
|
|||
|
||||
use OC\AppFramework\Bootstrap\Coordinator;
|
||||
use OC\Calendar\ResourcesRoomsUpdater;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Calendar\Room\IBackend;
|
||||
use OCP\Calendar\Room\IManager;
|
||||
use OCP\IServerContainer;
|
||||
|
|
@ -70,7 +71,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* @return IBackend[]
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
* @throws QueryException
|
||||
* @since 14.0.0
|
||||
*/
|
||||
public function getBackends():array {
|
||||
|
|
@ -95,7 +96,7 @@ class Manager implements IManager {
|
|||
|
||||
/**
|
||||
* @param string $backendId
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function getBackend($backendId): ?IBackend {
|
||||
$backends = $this->getBackends();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use OCP\AppFramework\QueryException;
|
|||
use OCP\Capabilities\ICapability;
|
||||
use OCP\Capabilities\IInitialStateExcludedCapability;
|
||||
use OCP\Capabilities\IPublicCapability;
|
||||
use OCP\ILogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CapabilitiesManager {
|
||||
|
|
@ -24,11 +25,9 @@ class CapabilitiesManager {
|
|||
/** @var \Closure[] */
|
||||
private $capabilities = [];
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(LoggerInterface $logger) {
|
||||
$this->logger = $logger;
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,11 +62,11 @@ class CapabilitiesManager {
|
|||
$timeSpent = $endTime - $startTime;
|
||||
if ($timeSpent > self::ACCEPTABLE_LOADING_TIME) {
|
||||
$logLevel = match (true) {
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 16 => \OCP\ILogger::FATAL,
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 8 => \OCP\ILogger::ERROR,
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 4 => \OCP\ILogger::WARN,
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 2 => \OCP\ILogger::INFO,
|
||||
default => \OCP\ILogger::DEBUG,
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 16 => ILogger::FATAL,
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 8 => ILogger::ERROR,
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 4 => ILogger::WARN,
|
||||
$timeSpent > self::ACCEPTABLE_LOADING_TIME * 2 => ILogger::INFO,
|
||||
default => ILogger::DEBUG,
|
||||
};
|
||||
$this->logger->log(
|
||||
$logLevel,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
namespace OC\Collaboration\Collaborators;
|
||||
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Collaboration\Collaborators\ISearch;
|
||||
use OCP\Collaboration\Collaborators\ISearchPlugin;
|
||||
use OCP\Collaboration\Collaborators\ISearchResult;
|
||||
|
|
@ -26,7 +27,7 @@ class Search implements ISearch {
|
|||
* @param bool $lookup
|
||||
* @param int|null $limit
|
||||
* @param int|null $offset
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function search($search, array $shareTypes, $lookup, $limit, $offset): array {
|
||||
$hasMoreResults = false;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class Collection implements ICollection {
|
|||
* @since 16.0.0
|
||||
*/
|
||||
public function addResource(IResource $resource): void {
|
||||
array_map(function (IResource $r) use ($resource) {
|
||||
array_map(function (IResource $r) use ($resource): void {
|
||||
if ($this->isSameResource($r, $resource)) {
|
||||
throw new ResourceException('Already part of the collection');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,37 +13,38 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
use OCP\Group\Events\BeforeGroupDeletedEvent;
|
||||
use OCP\Group\Events\UserAddedEvent;
|
||||
use OCP\Group\Events\UserRemovedEvent;
|
||||
use OCP\Server;
|
||||
use OCP\User\Events\UserDeletedEvent;
|
||||
|
||||
class Listener {
|
||||
public static function register(IEventDispatcher $eventDispatcher): void {
|
||||
$eventDispatcher->addListener(UserAddedEvent::class, function (UserAddedEvent $event) {
|
||||
$eventDispatcher->addListener(UserAddedEvent::class, function (UserAddedEvent $event): void {
|
||||
$user = $event->getUser();
|
||||
/** @var IManager $resourceManager */
|
||||
$resourceManager = \OCP\Server::get(IManager::class);
|
||||
$resourceManager = Server::get(IManager::class);
|
||||
|
||||
$resourceManager->invalidateAccessCacheForUser($user);
|
||||
});
|
||||
$eventDispatcher->addListener(UserRemovedEvent::class, function (UserRemovedEvent $event) {
|
||||
$eventDispatcher->addListener(UserRemovedEvent::class, function (UserRemovedEvent $event): void {
|
||||
$user = $event->getUser();
|
||||
/** @var IManager $resourceManager */
|
||||
$resourceManager = \OCP\Server::get(IManager::class);
|
||||
$resourceManager = Server::get(IManager::class);
|
||||
|
||||
$resourceManager->invalidateAccessCacheForUser($user);
|
||||
});
|
||||
|
||||
$eventDispatcher->addListener(UserDeletedEvent::class, function (UserDeletedEvent $event) {
|
||||
$eventDispatcher->addListener(UserDeletedEvent::class, function (UserDeletedEvent $event): void {
|
||||
$user = $event->getUser();
|
||||
/** @var IManager $resourceManager */
|
||||
$resourceManager = \OCP\Server::get(IManager::class);
|
||||
$resourceManager = Server::get(IManager::class);
|
||||
|
||||
$resourceManager->invalidateAccessCacheForUser($user);
|
||||
});
|
||||
|
||||
$eventDispatcher->addListener(BeforeGroupDeletedEvent::class, function (BeforeGroupDeletedEvent $event) {
|
||||
$eventDispatcher->addListener(BeforeGroupDeletedEvent::class, function (BeforeGroupDeletedEvent $event): void {
|
||||
$group = $event->getGroup();
|
||||
/** @var IManager $resourceManager */
|
||||
$resourceManager = \OCP\Server::get(IManager::class);
|
||||
$resourceManager = Server::get(IManager::class);
|
||||
|
||||
foreach ($group->getUsers() as $user) {
|
||||
$resourceManager->invalidateAccessCacheForUser($user);
|
||||
|
|
|
|||
|
|
@ -7,12 +7,10 @@
|
|||
namespace OC;
|
||||
|
||||
class Color {
|
||||
public $r;
|
||||
public $g;
|
||||
public $b;
|
||||
public function __construct($r, $g, $b) {
|
||||
$this->r = $r;
|
||||
$this->g = $g;
|
||||
$this->b = $b;
|
||||
public function __construct(
|
||||
public $r,
|
||||
public $g,
|
||||
public $b,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
namespace OC\Command;
|
||||
|
||||
use OCA\Files_Trashbin\Command\Expire;
|
||||
use OCP\BackgroundJob\QueuedJob;
|
||||
use OCP\Command\ICommand;
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ class CommandJob extends QueuedJob {
|
|||
\Test\Command\SimpleCommand::class,
|
||||
\Test\Command\StateFullCommand::class,
|
||||
\Test\Command\FilesystemCommand::class,
|
||||
\OCA\Files_Trashbin\Command\Expire::class,
|
||||
Expire::class,
|
||||
\OCA\Files_Versions\Command\Expire::class,
|
||||
]]);
|
||||
if ($command instanceof ICommand) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OC\Command;
|
||||
|
||||
use OCA\Files_Trashbin\Command\Expire;
|
||||
use OCP\Command\IBus;
|
||||
use OCP\Command\ICommand;
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ class QueueBus implements IBus {
|
|||
\Test\Command\SimpleCommand::class,
|
||||
\Test\Command\StateFullCommand::class,
|
||||
\Test\Command\FilesystemCommand::class,
|
||||
\OCA\Files_Trashbin\Command\Expire::class,
|
||||
Expire::class,
|
||||
\OCA\Files_Versions\Command\Expire::class,
|
||||
]]);
|
||||
$unserialized->handle();
|
||||
|
|
|
|||
|
|
@ -1325,7 +1325,7 @@ class Manager implements ICommentsManager {
|
|||
/**
|
||||
* deletes the read markers for the specified user
|
||||
*
|
||||
* @param \OCP\IUser $user
|
||||
* @param IUser $user
|
||||
* @return bool
|
||||
* @since 9.0.0
|
||||
*/
|
||||
|
|
@ -1512,7 +1512,7 @@ class Manager implements ICommentsManager {
|
|||
/**
|
||||
* returns valid, registered entities
|
||||
*
|
||||
* @return \OCP\Comments\ICommentsEventHandler[]
|
||||
* @return ICommentsEventHandler[]
|
||||
*/
|
||||
private function getEventHandlers() {
|
||||
if (!empty($this->eventHandlers)) {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue