X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FDatabase.php;h=3276e90e5294bd9cc35f4871e0156381dd227362;hb=8b7cb5d9efeab580c2592e0fbe301f7142b73a3d;hp=2c59607e9df73f940fd18f4dfb9d71fd6c6232f7;hpb=f689faca99cb9890b2b3fbe5817a4f1b7e58a5cd;p=friendica.git diff --git a/src/Database/Database.php b/src/Database/Database.php index 2c59607e9d..3276e90e52 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -23,6 +23,8 @@ namespace Friendica\Database; use Friendica\Core\Config\ValueObject\Cache; use Friendica\Core\System; +use Friendica\Database\Definition\DbaDefinition; +use Friendica\Database\Definition\ViewDefinition; use Friendica\Network\HTTPException\ServiceUnavailableException; use Friendica\Util\DateTimeFormat; use Friendica\Util\Profiler; @@ -73,20 +75,21 @@ class Database protected $in_retrial = false; protected $testmode = false; private $relation = []; + /** @var DbaDefinition */ + protected $dbaDefinition; + /** @var ViewDefinition */ + protected $viewDefinition; - public function __construct(Cache $configCache, Profiler $profiler, LoggerInterface $logger) + public function __construct(Cache $configCache, Profiler $profiler, DbaDefinition $dbaDefinition, ViewDefinition $viewDefinition, LoggerInterface $logger) { // We are storing these values for being able to perform a reconnect - $this->configCache = $configCache; - $this->profiler = $profiler; - $this->logger = $logger; + $this->configCache = $configCache; + $this->profiler = $profiler; + $this->logger = $logger; + $this->dbaDefinition = $dbaDefinition; + $this->viewDefinition = $viewDefinition; $this->connect(); - - if ($this->isConnected()) { - // Loads DB_UPDATE_VERSION constant - DBStructure::definition($configCache->get('system', 'basepath'), false); - } } /** @@ -825,6 +828,7 @@ class Database * * @return boolean Are there rows for that condition? * @throws \Exception + * @todo Please unwrap the DBStructure::existsTable() call so this method has one behavior only: checking existence on records */ public function exists(string $table, array $condition): bool { @@ -1608,10 +1612,10 @@ class Database $types = []; - $tables = DBStructure::definition('', false); + $tables = $this->dbaDefinition->getAll(); if (empty($tables[$table])) { // When a matching table wasn't found we check if it is a view - $views = View::definition('', false); + $views = $this->viewDefinition->getAll(); if (empty($views[$table])) { return $fields; }