Skip to content

Commit

Permalink
Adjust the logic to exit the construct early if we don't have a conne…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
jdarwood007 committed Nov 25, 2023
1 parent c6e2a4f commit 4bd7b43
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Sources/Db/APIs/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -1984,20 +1984,24 @@ protected function __construct(array $options = [])
$this->prefixReservedTables();
}

if (empty($this->connection) && !$non_fatal) {
$this->get_version();
$this->supports_pcre = version_compare($this->version, strpos($this->version, 'MariaDB') !== false ? '10.0.5' : '8.0.4', '>=');
}

// For backward compatibility.
if (!is_object(self::$db_connection)) {
self::$db_connection = $this->connection;
}

// At this point, if we don't have a connection, nothing else can be done.
if (empty($this->connection)) {
return;
}

$this->get_version();
$this->supports_pcre = version_compare($this->version, strpos($this->version, 'MariaDB') !== false ? '10.0.5' : '8.0.4', '>=');

// Ensure database has UTF-8 as its default input charset.
$this->query(
'',
'SET NAMES {string:db_character_set}',
'
SET NAMES {string:db_character_set}',
[
'db_character_set' => $this->character_set,
],
Expand Down
5 changes: 5 additions & 0 deletions Sources/Db/APIs/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,11 @@ protected function __construct(array $options = [])
self::$db_connection = $this->connection;
}

// At this point, if we don't have a connection, nothing else can be done.
if (empty($this->connection)) {
return;
}

// Ensure database has UTF-8 as its default input charset.
$this->query(
'',
Expand Down

0 comments on commit 4bd7b43

Please sign in to comment.