From 39f0c31b6fa5a12ee346797cd75cd65c5780850d Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Fri, 12 May 2023 17:52:55 +0200 Subject: [PATCH] Fail connection if mysqlnd is not available Since 5.22.0, the mysqli driver relies on the mysqli_stmt_get_result() function, which is only available in the MySQL Native Driver, to execute queries. An attempt to connect on a system using libmysqlclient should fail with an error message, to avoid problems down the line. Fixes #967 --- drivers/adodb-mysqli.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/adodb-mysqli.inc.php b/drivers/adodb-mysqli.inc.php index 07b294caf..5271db178 100644 --- a/drivers/adodb-mysqli.inc.php +++ b/drivers/adodb-mysqli.inc.php @@ -167,6 +167,14 @@ function _connect($argHostname = null, if(!extension_loaded("mysqli")) { return null; } + // Check for a function that only exists in mysqlnd + if (!function_exists('mysqli_stmt_get_result')) { + // @TODO This will be treated as if the mysqli extension were not available + // This could be misleading, so we output an additional error message. + // We should probably throw a specific exception instead. + $this->outp("MySQL Native Driver (msqlnd) required"); + return null; + } $this->_connectionID = @mysqli_init(); if (is_null($this->_connectionID)) {