DataQuery::connectToDatabase(), throw wenn called with empty configuration rather than producing obscure PHP errors.
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
*
|
*
|
||||||
* @copyright 2021 Marcin Łojewski <dev@mlojewski.me>
|
* @copyright 2021 Marcin Łojewski <dev@mlojewski.me>
|
||||||
* @author Marcin Łojewski <dev@mlojewski.me>
|
* @author Marcin Łojewski <dev@mlojewski.me>
|
||||||
|
* @copyright 2025 Claus-Justus Heine
|
||||||
|
* @author Claus-Justus Heine <himself@claus-justus-heine.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -21,6 +23,8 @@
|
|||||||
|
|
||||||
namespace OCA\UserSQL\Query;
|
namespace OCA\UserSQL\Query;
|
||||||
|
|
||||||
|
use UnexpectedValueException;
|
||||||
|
|
||||||
use Doctrine\DBAL\Driver\Statement;
|
use Doctrine\DBAL\Driver\Statement;
|
||||||
use Doctrine\DBAL\Exception as DBALException;
|
use Doctrine\DBAL\Exception as DBALException;
|
||||||
use OC\DB\Connection;
|
use OC\DB\Connection;
|
||||||
@@ -151,6 +155,10 @@ class DataQuery
|
|||||||
"driverOptions" => array()
|
"driverOptions" => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (empty($this->properties[DB::DRIVER])) {
|
||||||
|
throw new UnexpectedValueException('Attempt to connect without configuration.');
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->properties[DB::DRIVER] == 'mysql') {
|
if ($this->properties[DB::DRIVER] == 'mysql') {
|
||||||
if ($this->properties[DB::SSL_CA]) {
|
if ($this->properties[DB::SSL_CA]) {
|
||||||
$parameters["driverOptions"][\PDO::MYSQL_ATTR_SSL_CA] = \OC::$SERVERROOT . '/' . $this->properties[DB::SSL_CA];
|
$parameters["driverOptions"][\PDO::MYSQL_ATTR_SSL_CA] = \OC::$SERVERROOT . '/' . $this->properties[DB::SSL_CA];
|
||||||
|
|||||||
Reference in New Issue
Block a user