summaryrefslogtreecommitdiff
path: root/drivers/adodb-odbtp.inc.php
diff options
context:
space:
mode:
authorjrfnl <jrfnl@users.noreply.github.com>2018-03-30 00:21:18 +0200
committerDamien Regad <dregad@mantisbt.org>2018-03-30 11:06:27 +0200
commitfe52d38092f768e95fb67438527beda276ec6ae3 (patch)
tree377129e1faa1f004443112cd26978f88770c6d47 /drivers/adodb-odbtp.inc.php
parentc8b9db587e37ecf74ffdeba2690d6092fe36de67 (diff)
downloadadodb-fe52d38092f768e95fb67438527beda276ec6ae3.tar.gz
adodb-fe52d38092f768e95fb67438527beda276ec6ae3.tar.bz2
adodb-fe52d38092f768e95fb67438527beda276ec6ae3.zip
Replace usages of deprecated `$php_errormsg`
The PHP native `$php_errormsg` variable has been deprecated as of PHP 7.2. The recommended replacement is `error_get_last()`. A number of the driver classes used `$php_errormsg` to track if a DB action caused an error. As the `error_get_last()` function returns an array and comparing the message therefore is slightly more involved, two new methods have been introduced into the abstract parent class `ADOConnection` to handle the message comparison. The `resetLastError()` method retrieves the initial (old) error message and resets it to enable checking whether a new error has occurred, even when the new error is the same as the previous one. The new `getChangedErrorMsg()` method compares the old error message with the current one to determine whether a new message has occurred, and if so, returns the message. Refs: * http://php.net/manual/en/migration72.deprecated.php#migration72.deprecated.track_errors-and-php_errormsg * http://php.net/manual/en/reserved.variables.phperrormsg.php * http://php.net/manual/en/function.error-get-last.php Additional notes: * In the `ADODB_ads::UpdateBlob()` method, the original (old) message was not being retrieved which could result in an unrelated error being recorded. This has been fixed. * In the `ADODB_db2::_connect()` and `ADODB_db2::_pconnect()` methods, the `$php_errormsg` was being reset, but subsequently not checked for changes, so as the variable in effect was not being used, I've removed the related code. * In the `ADODB_sybase::ErrorMsg()` method, the `$php_errormsg` was being checked, but no functions which could potential cause errors are being called. As `$php_errormsg` is only available in the scope an error occurred in, this meant that `$php_errormsg` would always be empty, so I've removed the related code. Fixes #409
Diffstat (limited to 'drivers/adodb-odbtp.inc.php')
-rw-r--r--drivers/adodb-odbtp.inc.php5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/adodb-odbtp.inc.php b/drivers/adodb-odbtp.inc.php
index 0420d02c..9a834707 100644
--- a/drivers/adodb-odbtp.inc.php
+++ b/drivers/adodb-odbtp.inc.php
@@ -609,7 +609,7 @@ class ADODB_odbtp extends ADOConnection{
function _query($sql,$inputarr=false)
{
- error_clear_last();
+ $last_php_error = $this->resetLastError();
$this->_errorMsg = false;
$this->_errorCode = false;
@@ -619,8 +619,7 @@ class ADODB_odbtp extends ADOConnection{
} else {
$stmtid = @odbtp_prepare($sql,$this->_connectionID);
if ($stmtid == false) {
- $err = error_get_last();
- $this->_errorMsg = $err ? $err['message'] : '';
+ $this->_errorMsg = $this->getChangedErrorMsg($last_php_error);
return false;
}
}