Skip to content

Commit 404b387

Browse files
committed
Refactor OC\Server::getSystemConfig
1 parent 613cd16 commit 404b387

File tree

23 files changed

+62
-35
lines changed

23 files changed

+62
-35
lines changed

core/ajax/update.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use OC\Repair\Events\RepairStartEvent;
4545
use OC\Repair\Events\RepairStepEvent;
4646
use OC\Repair\Events\RepairWarningEvent;
47+
use OC\SystemConfig;
4748
use OCP\L10N\IFactory;
4849

4950
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
@@ -100,7 +101,7 @@ public function handleRepairFeedback(Event $event): void {
100101
}
101102

102103
if (\OCP\Util::needUpgrade()) {
103-
$config = \OC::$server->getSystemConfig();
104+
$config = \OC::$server->get(SystemConfig::class);
104105
if ($config->getValue('upgrade.disable-web', false)) {
105106
$eventSource->send('failure', $l->t('Please use the command line updater because updating via browser is disabled in your config.php.'));
106107
$eventSource->close();

core/register_command.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@
4848
* along with this program. If not, see <http://www.gnu.org/licenses/>
4949
*
5050
*/
51+
52+
use OC\SystemConfig;
5153
use Psr\Log\LoggerInterface;
5254

5355
$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
5456
$application->add(new OC\Core\Command\Status(\OC::$server->get(\OCP\IConfig::class), \OC::$server->get(\OCP\Defaults::class)));
55-
$application->add(new OC\Core\Command\Check(\OC::$server->getSystemConfig()));
57+
$application->add(new OC\Core\Command\Check(\OC::$server->get(SystemConfig::class)));
5658
$application->add(new OC\Core\Command\L10n\CreateJs());
5759
$application->add(new \OC\Core\Command\Integrity\SignApp(
5860
\OC::$server->getIntegrityCodeChecker(),
@@ -98,15 +100,15 @@
98100
$application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig()));
99101
$application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig()));
100102
$application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig()));
101-
$application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig()));
102-
$application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig()));
103-
$application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig()));
104-
$application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig()));
103+
$application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->get(SystemConfig::class), \OC::$server->getAppConfig()));
104+
$application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->get(SystemConfig::class)));
105+
$application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->get(SystemConfig::class)));
106+
$application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->get(SystemConfig::class)));
105107

106108
$application->add(\OC::$server->get(OC\Core\Command\Info\File::class));
107109
$application->add(\OC::$server->get(OC\Core\Command\Info\Space::class));
108110

109-
$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
111+
$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->get(SystemConfig::class))));
110112
$application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->get(LoggerInterface::class)));
111113
$application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->get(\OC\DB\Connection::class)));
112114
$application->add(\OCP\Server::get(\OC\Core\Command\Db\AddMissingColumns::class));

cron.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@
3939
*/
4040
require_once __DIR__ . '/lib/versioncheck.php';
4141

42+
use OC\SystemConfig;
43+
4244
try {
4345
require_once __DIR__ . '/lib/base.php';
4446

4547
if (\OCP\Util::needUpgrade()) {
4648
\OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']);
4749
exit;
4850
}
49-
if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
51+
if ((bool) \OC::$server->get(SystemConfig::class)->getValue('maintenance', false)) {
5052
\OC::$server->getLogger()->debug('We are in maintenance mode, skipping cron', ['app' => 'cron']);
5153
exit;
5254
}

lib/private/Console/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
use OC\MemoryInfo;
3434
use OC\NeedsUpdateException;
35+
use OC\SystemConfig;
3536
use OC_App;
3637
use OCP\App\IAppManager;
3738
use OCP\Console\ConsoleEvent;
@@ -157,7 +158,7 @@ public function loadCommands(
157158
}
158159

159160
if ($input->getFirstArgument() !== 'check') {
160-
$errors = \OC_Util::checkServer(\OC::$server->getSystemConfig());
161+
$errors = \OC_Util::checkServer(\OC::$server->get(SystemConfig::class));
161162
if (!empty($errors)) {
162163
foreach ($errors as $error) {
163164
$output->writeln((string)$error['error']);

lib/private/DB/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function __construct(
103103
$this->adapter = new $params['adapter']($this);
104104
$this->tablePrefix = $params['tablePrefix'];
105105

106-
$this->systemConfig = \OC::$server->getSystemConfig();
106+
$this->systemConfig = \OC::$server->get(SystemConfig::class);
107107
$this->logger = \OC::$server->get(LoggerInterface::class);
108108

109109
/** @var \OCP\Profiler\IProfiler */

lib/private/Files/Cache/Cache.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use OC\Files\Search\SearchComparison;
4545
use OC\Files\Search\SearchQuery;
4646
use OC\Files\Storage\Wrapper\Encryption;
47+
use OC\SystemConfig;
4748
use OCP\DB\QueryBuilder\IQueryBuilder;
4849
use OCP\EventDispatcher\IEventDispatcher;
4950
use OCP\Files\Cache\CacheEntryInsertedEvent;
@@ -131,7 +132,7 @@ public function __construct(IStorage $storage) {
131132
protected function getQueryBuilder() {
132133
return new CacheQueryBuilder(
133134
$this->connection,
134-
\OC::$server->getSystemConfig(),
135+
\OC::$server->get(SystemConfig::class),
135136
\OC::$server->get(LoggerInterface::class)
136137
);
137138
}

lib/private/Files/Storage/Common.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
use OC\Files\Filesystem;
5151
use OC\Files\Storage\Wrapper\Jail;
5252
use OC\Files\Storage\Wrapper\Wrapper;
53+
use OC\SystemConfig;
5354
use OCP\Files\EmptyFileNameException;
5455
use OCP\Files\FileNameTooLongException;
5556
use OCP\Files\ForbiddenException;
@@ -381,7 +382,7 @@ public function getPropagator($storage = null) {
381382
$storage = $this;
382383
}
383384
if (!isset($storage->propagator)) {
384-
$config = \OC::$server->getSystemConfig();
385+
$config = \OC::$server->get(SystemConfig::class);
385386
$storage->propagator = new Propagator($storage, \OC::$server->getDatabaseConnection(), ['appdata_' . $config->getValue('instanceid')]);
386387
}
387388
return $storage->propagator;

lib/private/Log.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
use OCP\Support\CrashReport\IRegistry;
4949
use OC\AppFramework\Bootstrap\Coordinator;
5050
use OC\Log\ExceptionSerializer;
51+
use OC\SystemConfig;
5152
use Throwable;
5253
use function array_merge;
5354
use function strtr;
@@ -83,7 +84,7 @@ public function __construct(
8384
) {
8485
// FIXME: Add this for backwards compatibility, should be fixed at some point probably
8586
if ($config === null) {
86-
$config = \OC::$server->getSystemConfig();
87+
$config = \OC::$server->get(SystemConfig::class);
8788
}
8889

8990
$this->config = $config;

lib/private/Log/Rotate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
namespace OC\Log;
2626

27+
use OC\SystemConfig;
2728
use OCP\Log\RotationTrait;
2829

2930
/**
@@ -36,7 +37,7 @@ class Rotate extends \OCP\BackgroundJob\Job {
3637
use RotationTrait;
3738

3839
public function run($dummy) {
39-
$systemConfig = \OC::$server->getSystemConfig();
40+
$systemConfig = \OC::$server->get(SystemConfig::class);
4041
$this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
4142

4243
$this->maxSize = \OC::$server->getConfig()->getSystemValueInt('log_rotate_size', 100 * 1024 * 1024);

lib/private/Memcache/Memcached.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*/
3232
namespace OC\Memcache;
3333

34+
use OC\SystemConfig;
3435
use OCP\HintException;
3536
use OCP\IMemcache;
3637

@@ -84,9 +85,9 @@ public function __construct($prefix = '') {
8485
throw new HintException("Expected 'memcached_options' config to be an array, got $options");
8586
}
8687

87-
$servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
88+
$servers = \OC::$server->get(SystemConfig::class)->getValue('memcached_servers');
8889
if (!$servers) {
89-
$server = \OC::$server->getSystemConfig()->getValue('memcached_server');
90+
$server = \OC::$server->get(SystemConfig::class)->getValue('memcached_server');
9091
if ($server) {
9192
$servers = [$server];
9293
} else {

0 commit comments

Comments
 (0)