mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
fix: Remove static vars from applications
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
1398c598cf
commit
2c068f3683
3 changed files with 14 additions and 12 deletions
|
|
@ -17,7 +17,7 @@ use OCP\Security\IHasher;
|
|||
use OCP\Security\ISecureRandom;
|
||||
|
||||
class BackupCodeStorage {
|
||||
private static $CODE_LENGTH = 16;
|
||||
private const CODE_LENGTH = 16;
|
||||
|
||||
public function __construct(
|
||||
private BackupCodeMapper $mapper,
|
||||
|
|
@ -40,7 +40,7 @@ class BackupCodeStorage {
|
|||
|
||||
$uid = $user->getUID();
|
||||
foreach (range(1, min([$number, 20])) as $i) {
|
||||
$code = $this->random->generate(self::$CODE_LENGTH, ISecureRandom::CHAR_HUMAN_READABLE);
|
||||
$code = $this->random->generate(self::CODE_LENGTH, ISecureRandom::CHAR_HUMAN_READABLE);
|
||||
|
||||
$dbCode = new BackupCode();
|
||||
$dbCode->setUserId($uid);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ declare(strict_types=1);
|
|||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\WorkflowEngine\Command;
|
||||
|
||||
use OCA\WorkflowEngine\Helper\ScopeContext;
|
||||
|
|
@ -43,11 +44,11 @@ class Index extends Command {
|
|||
}
|
||||
|
||||
protected function mappedScope(string $scope): int {
|
||||
static $scopes = [
|
||||
return match($scope) {
|
||||
'admin' => IManager::SCOPE_ADMIN,
|
||||
'user' => IManager::SCOPE_USER,
|
||||
];
|
||||
return $scopes[$scope] ?? -1;
|
||||
default => -1,
|
||||
};
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ class Manager implements IManager {
|
|||
/** @var CappedMemoryCache<int[]> */
|
||||
protected CappedMemoryCache $operationsByScope;
|
||||
|
||||
/** @var array<class-string<IOperation>, ScopeContext[]> $scopesByOperation */
|
||||
private array $scopesByOperation = [];
|
||||
|
||||
public function __construct(
|
||||
protected readonly IDBConnection $connection,
|
||||
protected readonly ContainerInterface $container,
|
||||
|
|
@ -128,10 +131,8 @@ class Manager implements IManager {
|
|||
* @return ScopeContext[]
|
||||
*/
|
||||
public function getAllConfiguredScopesForOperation(string $operationClass): array {
|
||||
/** @var array<class-string<IOperation>, ScopeContext[]> $scopesByOperation */
|
||||
static $scopesByOperation = [];
|
||||
if (isset($scopesByOperation[$operationClass])) {
|
||||
return $scopesByOperation[$operationClass];
|
||||
if (isset($this->scopesByOperation[$operationClass])) {
|
||||
return $this->scopesByOperation[$operationClass];
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -152,7 +153,7 @@ class Manager implements IManager {
|
|||
$query->setParameters(['operationClass' => $operationClass]);
|
||||
$result = $query->executeQuery();
|
||||
|
||||
$scopesByOperation[$operationClass] = [];
|
||||
$this->scopesByOperation[$operationClass] = [];
|
||||
while ($row = $result->fetchAssociative()) {
|
||||
$scope = new ScopeContext($row['type'], $row['value']);
|
||||
|
||||
|
|
@ -160,10 +161,10 @@ class Manager implements IManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
$scopesByOperation[$operationClass][$scope->getHash()] = $scope;
|
||||
$this->scopesByOperation[$operationClass][$scope->getHash()] = $scope;
|
||||
}
|
||||
|
||||
return $scopesByOperation[$operationClass];
|
||||
return $this->scopesByOperation[$operationClass];
|
||||
}
|
||||
|
||||
public function getAllOperations(ScopeContext $scopeContext): array {
|
||||
|
|
|
|||
Loading…
Reference in a new issue