summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPaweł Kudzia <30438339+pakud@users.noreply.github.com>2024-04-28 21:29:42 +0200
committerDamien Regad <dregad@mantisbt.org>2024-04-30 13:48:57 +0200
commitc8bdf383a960037424cee3b68193499c5418ea7d (patch)
tree8e758d061b1d1701740578e8e5df94954ea915e8 /drivers
parenta6bd3e28910ca545bdddb083faba2742d803474a (diff)
downloadadodb-c8bdf383a960037424cee3b68193499c5418ea7d.tar.gz
adodb-c8bdf383a960037424cee3b68193499c5418ea7d.tar.bz2
adodb-c8bdf383a960037424cee3b68193499c5418ea7d.zip
MySQL: allow forcing emulated prepared statements
ADOdb 5.22.0 introduced use of bound variables and prepared statements, which broke compatibility with Manticore Search and ClickHouse. Adding $doNotUseBoundVariables property, allowing to revert to emulated prepared statements, used in ADODb until v5.21. Fixes #1028, PR #1029 Co-authored-by: Damien Regad <dregad@mantisbt.org> Reworded and formatted PHPDoc block, fixed coding guidelines.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/adodb-mysqli.inc.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/adodb-mysqli.inc.php b/drivers/adodb-mysqli.inc.php
index 95c0c8f9..1c2b71ea 100644
--- a/drivers/adodb-mysqli.inc.php
+++ b/drivers/adodb-mysqli.inc.php
@@ -75,6 +75,25 @@ class ADODB_mysqli extends ADOConnection {
var $ssl_capath = null;
var $ssl_cipher = null;
+ /**
+ * Forcing emulated prepared statements.
+ *
+ * When set to true, ADODb will not execute queries using MySQLi native
+ * bound variables, and will instead use the built-in string interpolation
+ * and argument quoting from the parent class {@see ADOConnection::Execute()}.
+ *
+ * This is needed for some database engines that use mysql wire-protocol but
+ * do not support prepared statements, like
+ * {@see https://manticoresearch.com/ Manticore Search} or
+ * {@see https://clickhouse.com/ ClickHouse}.
+ *
+ * WARNING: This is a potential security risk, and strongly discouraged for code
+ * handling untrusted input {@see https://github.com/ADOdb/ADOdb/issues/1028#issuecomment-2081586024}.
+ *
+ * @var bool $doNotUseBoundVariables
+ */
+ var $doNotUseBoundVariables = false;
+
/** @var mysqli Identifier for the native database connection */
var $_connectionID = false;
@@ -1105,6 +1124,10 @@ class ADODB_mysqli extends ADOConnection {
public function execute($sql, $inputarr = false)
{
+ if ($this->doNotUseBoundVariables) {
+ return parent::execute($sql, $inputarr);
+ }
+
if ($this->fnExecute) {
$fn = $this->fnExecute;
$ret = $fn($this, $sql, $inputarr);