Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(db): move to OCP\Server #44810

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/private/DB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
use OCP\IRequestId;
use OCP\PreConditionNotMetException;
use OCP\Profiler\IProfiler;
use OCP\Server;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
use function in_array;
Expand Down Expand Up @@ -115,11 +116,11 @@ public function __construct(
$this->tablePrefix = $params['tablePrefix'];

$this->systemConfig = \OC::$server->getSystemConfig();
$this->clock = \OCP\Server::get(ClockInterface::class);
$this->logger = \OC::$server->get(LoggerInterface::class);
$this->clock = Server::get(ClockInterface::class);
$this->logger = Server::get(LoggerInterface::class);

/** @var \OCP\Profiler\IProfiler */
$profiler = \OC::$server->get(IProfiler::class);
$profiler = Server::get(IProfiler::class);
if ($profiler->isEnabled()) {
$this->dbDataCollector = new DbDataCollector($this);
$profiler->add($this->dbDataCollector);
Expand All @@ -143,7 +144,7 @@ public function connect($connectionName = null) {
$this->lastConnectionCheck[$this->getConnectionName()] = time();

// Only trigger the event logger for the initial connect call
$eventLogger = \OC::$server->get(IEventLogger::class);
$eventLogger = Server::get(IEventLogger::class);
$eventLogger->start('connect:db', 'db connection opened');
/** @psalm-suppress InternalMethod */
$status = parent::connect();
Expand Down Expand Up @@ -365,7 +366,7 @@ protected function logQueryToFile(string $sql): void {
if ($logFile !== '' && is_writable(dirname($logFile)) && (!file_exists($logFile) || is_writable($logFile))) {
$prefix = '';
if ($this->systemConfig->getValue('query_log_file_requestid') === 'yes') {
$prefix .= \OC::$server->get(IRequestId::class)->getId() . "\t";
$prefix .= Server::get(IRequestId::class)->getId() . "\t";
}

// FIXME: Improve to log the actual target db host
Expand Down Expand Up @@ -665,7 +666,7 @@ private function getMigrator() {
$random = \OC::$server->getSecureRandom();
$platform = $this->getDatabasePlatform();
$config = \OC::$server->getConfig();
$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
$dispatcher = Server::get(\OCP\EventDispatcher\IEventDispatcher::class);
if ($platform instanceof SqlitePlatform) {
return new SQLiteMigrator($this, $config, $dispatcher);
} elseif ($platform instanceof OraclePlatform) {
Expand Down
Loading