Skip to content

Commit

Permalink
Refactor OC\Server::getConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com>
  • Loading branch information
summersab committed Aug 30, 2023
1 parent 613cd16 commit c011987
Show file tree
Hide file tree
Showing 60 changed files with 216 additions and 145 deletions.
3 changes: 2 additions & 1 deletion build/integration/features/bootstrap/RemoteContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*
*/
use Behat\Behat\Context\Context;
use OC\AllConfig;
use PHPUnit\Framework\Assert;

require __DIR__ . '/../../vendor/autoload.php';
Expand Down Expand Up @@ -80,7 +81,7 @@ public function selectRemoteInstance($remoteServer) {
*/
public function theRemoteVersionShouldBe($version) {
if ($version === '__current_version__') {
$version = \OC::$server->getConfig()->getSystemValue('version', '0.0.0.0');
$version = \OC::$server->get(AllConfig::class)->getSystemValue('version', '0.0.0.0');
}

Assert::assertEquals($version, $this->remoteInstance->getVersion());
Expand Down
3 changes: 2 additions & 1 deletion console.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/
require_once __DIR__ . '/lib/versioncheck.php';

use OC\AllConfig;
use OC\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
Expand Down Expand Up @@ -90,7 +91,7 @@ function exceptionHandler($exception) {
}

$application = new Application(
\OC::$server->getConfig(),
\OC::$server->get(AllConfig::class),
\OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class),
\OC::$server->getRequest(),
\OC::$server->get(\Psr\Log\LoggerInterface::class),
Expand Down
3 changes: 2 additions & 1 deletion core/ajax/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCP\IEventSourceFactory;
use OCP\IL10N;
use OCP\ILogger;
use OC\AllConfig;
use OC\DB\MigratorExecuteSqlEvent;
use OC\Repair\Events\RepairAdvanceEvent;
use OC\Repair\Events\RepairErrorEvent;
Expand Down Expand Up @@ -112,7 +113,7 @@ public function handleRepairFeedback(Event $event): void {
\OC_User::setIncognitoMode(true);

$logger = \OC::$server->get(\Psr\Log\LoggerInterface::class);
$config = \OC::$server->getConfig();
$config = \OC::$server->get(AllConfig::class);
$updater = new \OC\Updater(
$config,
\OC::$server->getIntegrityCodeChecker(),
Expand Down
60 changes: 31 additions & 29 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
use Psr\Log\LoggerInterface;

use OC\AllConfig;
use Psr\Log\LoggerInterface;

$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
$application->add(new OC\Core\Command\Status(\OC::$server->get(\OCP\IConfig::class), \OC::$server->get(\OCP\Defaults::class)));
Expand All @@ -71,7 +73,7 @@
));


if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
if (\OC::$server->get(AllConfig::class)->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager()));
$application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\App\Install());
Expand All @@ -86,18 +88,18 @@
$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Disable::class));
$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\State::class));

$application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Background\Cron(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Background\WebCron(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Background\Ajax(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Background\Job(\OC::$server->getJobList(), \OC::$server->getLogger()));
$application->add(new OC\Core\Command\Background\ListCommand(\OC::$server->getJobList()));

$application->add(\OC::$server->query(\OC\Core\Command\Broadcast\Test::class));

$application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Config\Import(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig()));
$application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig()));
$application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig()));
Expand All @@ -106,48 +108,48 @@
$application->add(\OC::$server->get(OC\Core\Command\Info\File::class));
$application->add(\OC::$server->get(OC\Core\Command\Info\Space::class));

$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
$application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->get(LoggerInterface::class)));
$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->get(AllConfig::class), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
$application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->get(AllConfig::class), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->get(LoggerInterface::class)));
$application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->get(\OC\DB\Connection::class)));
$application->add(\OCP\Server::get(\OC\Core\Command\Db\AddMissingColumns::class));
$application->add(\OCP\Server::get(\OC\Core\Command\Db\AddMissingIndices::class));
$application->add(\OCP\Server::get(\OC\Core\Command\Db\AddMissingPrimaryKeys::class));

if (\OC::$server->getConfig()->getSystemValueBool('debug', false)) {
if (\OC::$server->get(AllConfig::class)->getSystemValueBool('debug', false)) {
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->get(\OC\DB\Connection::class)));
$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->get(\OC\DB\Connection::class)));
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getAppManager()));
$application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->get(AllConfig::class)));
}

$application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager()));
$application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->get(AllConfig::class), \OC::$server->getEncryptionManager()));
$application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager()));
$application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper()));
$application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->get(AllConfig::class), new \Symfony\Component\Console\Helper\QuestionHelper()));
$application->add(new OC\Core\Command\Encryption\DecryptAll(
\OC::$server->getEncryptionManager(),
\OC::$server->getAppManager(),
\OC::$server->getConfig(),
\OC::$server->get(AllConfig::class),
new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()),
new \Symfony\Component\Console\Helper\QuestionHelper())
);

$application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Log\File(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Log\Manage(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Log\File(\OC::$server->get(AllConfig::class)));

$view = new \OC\Files\View();
$util = new \OC\Encryption\Util(
$view,
\OC::$server->getUserManager(),
\OC::$server->getGroupManager(),
\OC::$server->getConfig()
\OC::$server->get(AllConfig::class)
);
$application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot(
$view,
\OC::$server->getUserManager(),
\OC::$server->getConfig(),
\OC::$server->get(AllConfig::class),
$util,
new \Symfony\Component\Console\Helper\QuestionHelper()
)
Expand All @@ -156,23 +158,23 @@
$application->add(new OC\Core\Command\Encryption\MigrateKeyStorage(
$view,
\OC::$server->getUserManager(),
\OC::$server->getConfig(),
\OC::$server->get(AllConfig::class),
$util,
\OC::$server->getCrypto()
)
);

$application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory()));
$application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->get(AllConfig::class), new \OC\AppFramework\Utility\TimeFactory()));
$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader()));
$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
$application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\Maintenance\UpdateHtaccess());
$application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory()));

$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->query(\OC\Installer::class)));
$application->add(new OC\Core\Command\Upgrade(\OC::$server->get(AllConfig::class), \OC::$server->get(LoggerInterface::class), \OC::$server->query(\OC\Installer::class)));
$application->add(new OC\Core\Command\Maintenance\Repair(
new \OC\Repair([], \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)),
\OC::$server->getConfig(),
\OC::$server->get(AllConfig::class),
\OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class),
\OC::$server->getAppManager()
));
Expand All @@ -189,7 +191,7 @@
$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager(), \OC::$server->getAppManager()));
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->get(AllConfig::class)));
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\AddAppPassword(\OC::$server->get(\OCP\IUserManager::class), \OC::$server->get(\OC\Authentication\Token\IProvider::class), \OC::$server->get(\OCP\Security\ISecureRandom::class), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class)));
Expand Down
4 changes: 3 additions & 1 deletion cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
*/
require_once __DIR__ . '/lib/versioncheck.php';

use OC\AllConfig;

try {
require_once __DIR__ . '/lib/base.php';

Expand All @@ -63,7 +65,7 @@
\OC::$server->setSession($session);

$logger = \OC::$server->getLogger();
$config = \OC::$server->getConfig();
$config = \OC::$server->get(AllConfig::class);
$tempManager = \OC::$server->getTempManager();

// Don't do anything if Nextcloud has not been installed
Expand Down
3 changes: 2 additions & 1 deletion lib/private/DB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
use OCP\PreConditionNotMetException;
use OCP\Profiler\IProfiler;
use OC\DB\QueryBuilder\QueryBuilder;
use OC\AllConfig;
use OC\SystemConfig;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -594,7 +595,7 @@ private function getMigrator() {
// TODO properly inject those dependencies
$random = \OC::$server->getSecureRandom();
$platform = $this->getDatabasePlatform();
$config = \OC::$server->getConfig();
$config = \OC::$server->get(AllConfig::class);
$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
if ($platform instanceof SqlitePlatform) {
return new SQLiteMigrator($this, $config, $dispatcher);
Expand Down
3 changes: 2 additions & 1 deletion lib/private/DB/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Types;
use OC\AllConfig;
use OC\App\InfoParser;
use OC\IntegrityCheck\Helpers\AppLocator;
use OC\Migration\SimpleOutput;
Expand Down Expand Up @@ -116,7 +117,7 @@ private function createMigrationTable() {
return false;
}

if ($this->connection->tableExists('migrations') && \OC::$server->getConfig()->getAppValue('core', 'vendor', '') !== 'owncloud') {
if ($this->connection->tableExists('migrations') && \OC::$server->get(AllConfig::class)->getAppValue('core', 'vendor', '') !== 'owncloud') {
$this->migrationTableCreated = true;
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Encryption/EncryptionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
namespace OC\Encryption;

use OC\AllConfig;
use OC\Files\Filesystem;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
Expand Down Expand Up @@ -86,7 +87,7 @@ public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount) {
new View(),
\OC::$server->getUserManager(),
\OC::$server->getGroupManager(),
\OC::$server->getConfig()
\OC::$server->get(AllConfig::class)
);
$update = new Update(
new View(),
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Encryption/HookManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
namespace OC\Encryption;

use OC\AllConfig;
use OC\Files\Filesystem;
use OC\Files\View;
use OC\Files\SetupManager;
Expand Down Expand Up @@ -76,7 +77,7 @@ private static function getUpdate(?string $owner = null): Update {
new View(),
\OC::$server->getUserManager(),
\OC::$server->getGroupManager(),
\OC::$server->getConfig()),
\OC::$server->get(AllConfig::class)),
Filesystem::getMountManager(),
\OC::$server->getEncryptionManager(),
\OC::$server->getEncryptionFilesHelper(),
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Cache/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use OCP\Files\Storage\IReliableEtagStorage;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use OC\AllConfig;
use OC\Files\Storage\Wrapper\Jail;
use OC\Hooks\BasicEmitter;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -95,7 +96,7 @@ public function __construct(\OC\Files\Storage\Storage $storage) {
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
$this->cacheActive = !\OC::$server->getConfig()->getSystemValueBool('filesystem_cache_readonly', false);
$this->cacheActive = !\OC::$server->get(AllConfig::class)->getSystemValueBool('filesystem_cache_readonly', false);
$this->lockingProvider = \OC::$server->getLockingProvider();
$this->connection = \OC::$server->get(IDBConnection::class);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
namespace OC\Files;

use OCP\Cache\CappedMemoryCache;
use OC\AllConfig;
use OC\Files\Mount\MountPoint;
use OC\User\NoUserException;
use OCP\EventDispatcher\IEventDispatcher;
Expand Down Expand Up @@ -465,7 +466,7 @@ public static function isFileBlacklisted($filename) {
$filename = self::normalizePath($filename);

if (self::$blacklist === null) {
self::$blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', ['.htaccess']);
self::$blacklist = \OC::$server->get(AllConfig::class)->getSystemValue('blacklisted_files', ['.htaccess']);
}

$filename = strtolower(basename($filename));
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/
namespace OC\Files\Node;

use OC\AllConfig;
use OC\Files\Cache\QuerySearchHelper;
use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
Expand Down Expand Up @@ -314,7 +315,7 @@ public function getById($id) {
}

protected function getAppDataDirectoryName(): string {
$instanceId = \OC::$server->getConfig()->getSystemValueString('instanceid');
$instanceId = \OC::$server->get(AllConfig::class)->getSystemValueString('instanceid');
return 'appdata_' . $instanceId;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
*/
namespace OC\Files\Storage;

use OC\AllConfig;
use OC\Files\Cache\Cache;
use OC\Files\Cache\Propagator;
use OC\Files\Cache\Scanner;
Expand Down Expand Up @@ -364,7 +365,7 @@ public function getWatcher($path = '', $storage = null) {
}
if (!isset($this->watcher)) {
$this->watcher = new Watcher($storage);
$globalPolicy = \OC::$server->getConfig()->getSystemValue('filesystem_check_changes', Watcher::CHECK_NEVER);
$globalPolicy = \OC::$server->get(AllConfig::class)->getSystemValue('filesystem_check_changes', Watcher::CHECK_NEVER);
$this->watcher->setPolicy((int)$this->getMountOption('filesystem_check_changes', $globalPolicy));
}
return $this->watcher;
Expand Down Expand Up @@ -840,7 +841,7 @@ public function changeLock($path, $type, ILockingProvider $provider) {

private function getLockLogger(): ?LoggerInterface {
if (is_null($this->shouldLogLocks)) {
$this->shouldLogLocks = \OC::$server->getConfig()->getSystemValueBool('filelocking.debug', false);
$this->shouldLogLocks = \OC::$server->get(AllConfig::class)->getSystemValueBool('filelocking.debug', false);
$this->logger = $this->shouldLogLocks ? \OC::$server->get(LoggerInterface::class) : null;
}
return $this->logger;
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Storage/DAV.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Exception;
use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\IteratorDirectory;
use OC\AllConfig;
use OC\Files\Filesystem;
use OC\MemCache\ArrayCache;
use OCP\AppFramework\Http;
Expand Down Expand Up @@ -172,7 +173,7 @@ protected function init() {
$settings['authType'] = $this->authType;
}

$proxy = \OC::$server->getConfig()->getSystemValueString('proxy', '');
$proxy = \OC::$server->get(AllConfig::class)->getSystemValueString('proxy', '');
if ($proxy !== '') {
$settings['proxy'] = $proxy;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Storage/Wrapper/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
namespace OC\Files\Storage\Wrapper;

use OC\AllConfig;
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageAuthException;
use OCP\Files\StorageNotAvailableException;
Expand All @@ -43,7 +44,7 @@ class Availability extends Wrapper {
protected $config;

public function __construct($parameters) {
$this->config = $parameters['config'] ?? \OC::$server->getConfig();
$this->config = $parameters['config'] ?? \OC::$server->get(AllConfig::class);
parent::__construct($parameters);
}

Expand Down
Loading

0 comments on commit c011987

Please sign in to comment.