Skip to content

Commit

Permalink
Simplify the database handling
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Feb 2, 2022
1 parent 8ce7971 commit 9a190b3
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 134 deletions.
8 changes: 2 additions & 6 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,14 @@ public function __construct(array $params = []) {
}

public function register(IRegistrationContext $context): void {
$context->registerService(IActivityDBConnection::class, function (ContainerInterface $c) {
$context->registerService('activityDBConnection', function (ContainerInterface $c) {
$systemConfig = $c->get(SystemConfig::class);
$factory = new \OC\DB\ConnectionFactory($systemConfig);
$type = $systemConfig->getValue('dbtype', 'sqlite');
if (!$factory->isValidType($type)) {
throw new \OC\DatabaseException('Invalid database type');
}
$connectionParams = $factory->createConnectionParams(
'activity_',
\OCA\Activity\DB\ActivityConnection::class,
\OCA\Activity\DB\ActivityOracleConnection::class
);
$connectionParams = $factory->createConnectionParams('activity_');
$connection = $factory->getConnection($type, $connectionParams);
$connection->getConfiguration()->setSQLLogger($c->get(\OCP\Diagnostics\IQueryLogger::class));
return $connection;
Expand Down
30 changes: 0 additions & 30 deletions lib/DB/ActivityConnection.php

This file was deleted.

36 changes: 0 additions & 36 deletions lib/DB/ActivityConnectionAdapter.php

This file was deleted.

30 changes: 0 additions & 30 deletions lib/DB/ActivityOracleConnection.php

This file was deleted.

28 changes: 0 additions & 28 deletions lib/DB/IActivityDBConnection.php

This file was deleted.

5 changes: 3 additions & 2 deletions lib/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ class Data {
/** @var IDBConnection */
protected $connection;

public function __construct(IManager $activityManager, IActivityDBConnection $connection) {
// FIXME must NOT typehint IDBConnection! Otherwise IDBConnection is injected instead of our own service
public function __construct(IManager $activityManager, $activityDBConnection) {
$this->activityManager = $activityManager;
$this->connection = $connection;
$this->connection = $activityDBConnection;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class MailQueueHandler {
protected $logger;

public function __construct(IDateTimeFormatter $dateFormatter,
IActivityDBConnection $connection,
// FIXME must NOT typehint IDBConnection! Otherwise IDBConnection is injected instead of our own service
$activityDBConnection,
IMailer $mailer,
IURLGenerator $urlGenerator,
IUserManager $userManager,
Expand All @@ -106,7 +107,7 @@ public function __construct(IDateTimeFormatter $dateFormatter,
IConfig $config,
ILogger $logger) {
$this->dateFormatter = $dateFormatter;
$this->connection = $connection;
$this->connection = $activityDBConnection;
$this->mailer = $mailer;
$this->urlGenerator = $urlGenerator;
$this->userManager = $userManager;
Expand Down

0 comments on commit 9a190b3

Please sign in to comment.