diff options
| author | Damien Regad <dregad@mantisbt.org> | 2021-03-08 18:32:52 +0100 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2021-03-08 18:32:52 +0100 |
| commit | def710065bb2b5d351a0d13b9859cf4b1334787a (patch) | |
| tree | 74f06c19dc30f037f654eca31ce11909f145b1d9 /drivers | |
| parent | f60a161ee06a9daba2a72ea7dd3591285ace45b0 (diff) | |
| download | adodb-def710065bb2b5d351a0d13b9859cf4b1334787a.tar.gz adodb-def710065bb2b5d351a0d13b9859cf4b1334787a.tar.bz2 adodb-def710065bb2b5d351a0d13b9859cf4b1334787a.zip | |
get/setCharSet: avoid TypeError when no connection
On mysqli, PHP 8 throws an 'Uncaught TypeError: method_exists():
Argument 1 ($object_or_class) must be of type object|string, bool
given'. Checking that _connectionID is set fixes the problem.
A similar issue was found and fixed with the postgres7 driver as well.
Note that fixing the legacy mysql driver is not necessary, as the driver
has been removed in PHP 7, and the error suppression operator should do
the job on PHP 5.
Fixes #686
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/adodb-mysqli.inc.php | 8 | ||||
| -rw-r--r-- | drivers/adodb-postgres7.inc.php | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/drivers/adodb-mysqli.inc.php b/drivers/adodb-mysqli.inc.php index c2415163..9c98fb9a 100644 --- a/drivers/adodb-mysqli.inc.php +++ b/drivers/adodb-mysqli.inc.php @@ -1175,13 +1175,13 @@ class ADODB_mysqli extends ADOConnection { function getCharSet() { - //we will use ADO's builtin property charSet - if (!method_exists($this->_connectionID,'character_set_name')) + if (!$this->_connectionID || !method_exists($this->_connectionID,'character_set_name')) { return false; + } $this->charSet = @$this->_connectionID->character_set_name(); if (!$this->charSet) { - return false; + } else { return $this->charSet; } @@ -1189,7 +1189,7 @@ class ADODB_mysqli extends ADOConnection { function setCharSet($charset) { - if (!method_exists($this->_connectionID,'set_charset')) { + if (!$this->_connectionID || !method_exists($this->_connectionID,'set_charset')) { return false; } diff --git a/drivers/adodb-postgres7.inc.php b/drivers/adodb-postgres7.inc.php index 2cfe694d..38762bf3 100644 --- a/drivers/adodb-postgres7.inc.php +++ b/drivers/adodb-postgres7.inc.php @@ -280,7 +280,9 @@ class ADODB_postgres7 extends ADODB_postgres64 { */ function getCharSet() { - //we will use ADO's builtin property charSet + if (!$this->_connectionID) { + return false; + } $this->charSet = @pg_client_encoding($this->_connectionID); if (!$this->charSet) { return false; |
