mirror of
https://github.com/nextcloud/server.git
synced 2026-03-28 21:33:40 -04:00
fix: Remove static vars from core classes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
2c068f3683
commit
cd2d09de64
8 changed files with 22 additions and 28 deletions
|
|
@ -23,7 +23,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
class GenerateCommand extends Command implements CompletionAwareInterface {
|
||||
protected static $_templateSimple
|
||||
private const string TEMPLATE
|
||||
= '<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
|
@ -197,7 +197,7 @@ class {{classname}} extends SimpleMigrationStep {
|
|||
$schemaBody,
|
||||
date('Y')
|
||||
];
|
||||
$code = str_replace($placeHolders, $replacements, self::$_templateSimple);
|
||||
$code = str_replace($placeHolders, $replacements, self::TEMPLATE);
|
||||
$dir = $ms->getMigrationsDirectory();
|
||||
|
||||
$this->ensureMigrationDirExists($dir);
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ class AccountManager implements IAccountManager {
|
|||
}
|
||||
|
||||
protected function updateVerificationStatus(IAccount $updatedAccount, array $oldData): void {
|
||||
static $propertiesVerifiableByLookupServer = [
|
||||
$propertiesVerifiableByLookupServer = [
|
||||
self::PROPERTY_TWITTER,
|
||||
self::PROPERTY_FEDIVERSE,
|
||||
self::PROPERTY_WEBSITE,
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class PlatformRepository {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static string $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
|
||||
private const string MODIFIER_REGEX = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
|
||||
|
||||
/**
|
||||
* Normalizes a version string to be able to perform comparisons on it
|
||||
|
|
@ -154,16 +154,16 @@ class PlatformRepository {
|
|||
return 'dev-' . substr($version, 4);
|
||||
}
|
||||
// match classical versioning
|
||||
if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) {
|
||||
if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?' . self::MODIFIER_REGEX . '$}i', $version, $matches)) {
|
||||
$version = $matches[1]
|
||||
. (!empty($matches[2]) ? $matches[2] : '.0')
|
||||
. (!empty($matches[3]) ? $matches[3] : '.0')
|
||||
. (!empty($matches[4]) ? $matches[4] : '.0');
|
||||
$index = 5;
|
||||
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) { // match date-based versioning
|
||||
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::MODIFIER_REGEX . '$}i', $version, $matches)) { // match date-based versioning
|
||||
$version = preg_replace('{\D}', '-', $matches[1]);
|
||||
$index = 2;
|
||||
} elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) {
|
||||
} elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?' . self::MODIFIER_REGEX . '$}i', $version, $matches)) {
|
||||
$version = $matches[1]
|
||||
. (!empty($matches[2]) ? $matches[2] : '.0')
|
||||
. (!empty($matches[3]) ? $matches[3] : '.0')
|
||||
|
|
|
|||
|
|
@ -28,18 +28,12 @@ use Psr\Log\LoggerInterface;
|
|||
* @package OC\Files\Cache
|
||||
*/
|
||||
class Storage {
|
||||
private static ?StorageGlobal $globalCache = null;
|
||||
|
||||
private string $storageId;
|
||||
|
||||
private int $numericId;
|
||||
|
||||
public static function getGlobalCache(): StorageGlobal {
|
||||
if (is_null(self::$globalCache)) {
|
||||
self::$globalCache = new StorageGlobal(Server::get(IDBConnection::class));
|
||||
}
|
||||
|
||||
return self::$globalCache;
|
||||
return Server::get(StorageGlobal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ class SetupManager implements ISetupManager {
|
|||
private const SETUP_WITH_CHILDREN = 1;
|
||||
private const SETUP_WITHOUT_CHILDREN = 0;
|
||||
|
||||
private bool $updatingProviders = false;
|
||||
|
||||
public function __construct(
|
||||
private IEventLogger $eventLogger,
|
||||
private MountProviderCollection $mountProviderCollection,
|
||||
|
|
@ -245,11 +247,10 @@ class SetupManager implements ISetupManager {
|
|||
}
|
||||
|
||||
// prevent recursion loop from when getting mounts from providers ends up setting up the filesystem
|
||||
static $updatingProviders = false;
|
||||
if ($updatingProviders) {
|
||||
if ($this->updatingProviders) {
|
||||
return;
|
||||
}
|
||||
$updatingProviders = true;
|
||||
$this->updatingProviders = true;
|
||||
|
||||
$providers = $this->mountProviderCollection->getProviders();
|
||||
$nonAuthoritativeProviders = array_filter(
|
||||
|
|
@ -265,7 +266,7 @@ class SetupManager implements ISetupManager {
|
|||
$this->userMountCache->registerMounts($user, $mount, $providerNames);
|
||||
|
||||
$this->usersMountsUpdated[$user->getUID()] = true;
|
||||
$updatingProviders = false;
|
||||
$this->updatingProviders = false;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage,
|
|||
private ?LoggerInterface $logger = null;
|
||||
private ?IFilenameValidator $filenameValidator = null;
|
||||
|
||||
private ?CacheDependencies $cacheDependencies = null;
|
||||
|
||||
public function __construct(array $parameters) {
|
||||
}
|
||||
|
||||
|
|
@ -304,11 +306,10 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage,
|
|||
}
|
||||
|
||||
protected function getCacheDependencies(): CacheDependencies {
|
||||
static $dependencies = null;
|
||||
if (!$dependencies) {
|
||||
$dependencies = Server::get(CacheDependencies::class);
|
||||
if ($this->cacheDependencies === null) {
|
||||
$this->cacheDependencies = Server::get(CacheDependencies::class);
|
||||
}
|
||||
return $dependencies;
|
||||
return $this->cacheDependencies;
|
||||
}
|
||||
|
||||
public function getCache(string $path = '', ?IStorage $storage = null): ICache {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ use OC\Files\Config\UserMountCache;
|
|||
use OC\Files\Config\UserMountCacheListener;
|
||||
use OC\Files\Conversion\ConversionManager;
|
||||
use OC\Files\FilenameValidator;
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\Lock\LockManager;
|
||||
use OC\Files\Mount\CacheMountProvider;
|
||||
use OC\Files\Mount\LocalHomeMountProvider;
|
||||
|
|
@ -440,12 +439,11 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
});
|
||||
$this->registerAlias(IFileAccess::class, FileAccess::class);
|
||||
$this->registerService('RootFolder', function (ContainerInterface $c) {
|
||||
$manager = Filesystem::getMountManager();
|
||||
$view = new View();
|
||||
/** @var IUserSession $userSession */
|
||||
$userSession = $c->get(IUserSession::class);
|
||||
$root = new Root(
|
||||
$manager,
|
||||
$c->get(\OC\Files\Mount\Manager::class),
|
||||
$view,
|
||||
$userSession->getUser(),
|
||||
$c->get(IUserMountCache::class),
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Setup {
|
|||
$this->l10n = $l10nFactory->get('lib');
|
||||
}
|
||||
|
||||
protected static array $dbSetupClasses = [
|
||||
private const array DB_SETUP_CLASSES = [
|
||||
'mysql' => MySQL::class,
|
||||
'pgsql' => PostgreSQL::class,
|
||||
'oci' => OCI::class,
|
||||
|
|
@ -334,13 +334,13 @@ class Setup {
|
|||
$options['directory'] = \OC::$SERVERROOT . '/data';
|
||||
}
|
||||
|
||||
if (!isset(self::$dbSetupClasses[$dbType])) {
|
||||
if (!isset(self::DB_SETUP_CLASSES[$dbType])) {
|
||||
$dbType = 'sqlite';
|
||||
}
|
||||
|
||||
$dataDir = htmlspecialchars_decode($options['directory']);
|
||||
|
||||
$class = self::$dbSetupClasses[$dbType];
|
||||
$class = self::DB_SETUP_CLASSES[$dbType];
|
||||
/** @var AbstractDatabase $dbSetup */
|
||||
$dbSetup = new $class($l, $this->config, $this->logger, $this->random);
|
||||
$error = array_merge($error, $dbSetup->validate($options));
|
||||
|
|
|
|||
Loading…
Reference in a new issue