Merge pull request #23787 from nextcloud/backport/23783/stable20
[stable20] Fetch the logger and system config once for all query builder instances
This commit is contained in:
commit
f2a0ba4b55
|
@ -42,21 +42,25 @@ use Doctrine\DBAL\Exception\ConstraintViolationException;
|
||||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use OC\DB\QueryBuilder\QueryBuilder;
|
use OC\DB\QueryBuilder\QueryBuilder;
|
||||||
|
use OC\SystemConfig;
|
||||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
use OCP\ILogger;
|
||||||
use OCP\PreConditionNotMetException;
|
use OCP\PreConditionNotMetException;
|
||||||
|
|
||||||
class Connection extends ReconnectWrapper implements IDBConnection {
|
class Connection extends ReconnectWrapper implements IDBConnection {
|
||||||
/**
|
/** @var string */
|
||||||
* @var string $tablePrefix
|
|
||||||
*/
|
|
||||||
protected $tablePrefix;
|
protected $tablePrefix;
|
||||||
|
|
||||||
/**
|
/** @var \OC\DB\Adapter $adapter */
|
||||||
* @var \OC\DB\Adapter $adapter
|
|
||||||
*/
|
|
||||||
protected $adapter;
|
protected $adapter;
|
||||||
|
|
||||||
|
/** @var SystemConfig */
|
||||||
|
private $systemConfig;
|
||||||
|
|
||||||
|
/** @var ILogger */
|
||||||
|
private $logger;
|
||||||
|
|
||||||
protected $lockedTable = null;
|
protected $lockedTable = null;
|
||||||
|
|
||||||
public function connect() {
|
public function connect() {
|
||||||
|
@ -76,8 +80,8 @@ class Connection extends ReconnectWrapper implements IDBConnection {
|
||||||
public function getQueryBuilder() {
|
public function getQueryBuilder() {
|
||||||
return new QueryBuilder(
|
return new QueryBuilder(
|
||||||
$this,
|
$this,
|
||||||
\OC::$server->getSystemConfig(),
|
$this->systemConfig,
|
||||||
\OC::$server->getLogger()
|
$this->logger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +153,9 @@ class Connection extends ReconnectWrapper implements IDBConnection {
|
||||||
parent::__construct($params, $driver, $config, $eventManager);
|
parent::__construct($params, $driver, $config, $eventManager);
|
||||||
$this->adapter = new $params['adapter']($this);
|
$this->adapter = new $params['adapter']($this);
|
||||||
$this->tablePrefix = $params['tablePrefix'];
|
$this->tablePrefix = $params['tablePrefix'];
|
||||||
|
|
||||||
|
$this->systemConfig = \OC::$server->getSystemConfig();
|
||||||
|
$this->logger = \OC::$server->getLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue