From b881dea297a93496fbd6d1d8a3c2fbe277c9231c Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sun, 16 Apr 2023 15:29:54 +0200 Subject: [PATCH] Fix deprecated warning in ADODB_postgres64::qStr() pg_escape_string() will trigger a deprecation warning in PHP 8.1+ when there is no connection specified. This can occur when using setSessionVariables() in the load balancer, so we fall back to emulated escaping in this case. Fixes #956 --- drivers/adodb-postgres64.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php index fa8e5fba7..23a219589 100644 --- a/drivers/adodb-postgres64.inc.php +++ b/drivers/adodb-postgres64.inc.php @@ -258,7 +258,9 @@ function qStr($s, $magic_quotes=false) if ($this->_connectionID) { return "'" . pg_escape_string($this->_connectionID, $s) . "'"; } else { - return "'" . pg_escape_string($s) . "'"; + // Fall back to emulated escaping when there is no database connection. + // Avoids errors when using setSessionVariables() in the load balancer. + return parent::qStr( $s ); } }