[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Ilia Alshanetsky | Date: | Wed, 18 Nov 2026 15:05:24 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143831@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-11-18T10:01:52-05:00
Commit: https://github.com/php/php-src/commit/e6a82f6ff33177fc82b897ae06ff8101f0d343f0
Raw diff: https://github.com/php/php-src/commit/e6a82f6ff33177fc82b897ae06ff8101f0d343f0.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
ext/pdo_mysql: Fix crash re-executing a statement after a failed execute
Changed paths:
A ext/pdo_mysql/tests/pdo_mysql_stmt_execute_retry_after_failure.phpt
M NEWS
M ext/pdo_mysql/mysql_statement.c
Diff:
diff --git a/NEWS b/NEWS
index 7dc75833bd9a..797a82e51a06 100644
--- a/NEWS
+++ b/NEWS
@@ -125,6 +125,10 @@ PHP NEWS
. Fixed \C being allowed in patterns enabling UTF mode with (*UTF) instead
of the u modifier. (Jorg Sowa)
+- PDO_MYSQL:
+ . Fixed a crash when executing a prepared statement again after a failed
+ execute() with libmysqlclient. (Ilia Alshanetsky)
+
- POSIX:
. Fixed bug GH-25530 (posix_get_last_error() returns an error from a
previous request). (Artem Ukrainskiy)
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index f6b182fcb9ad..e5a6c008ff08 100644
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -266,9 +266,6 @@ static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */
/* (re)bind the parameters */
if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) {
- if (S->params) {
- memset(S->params, 0, S->num_params * sizeof(MYSQL_BIND));
- }
pdo_mysql_error_stmt(stmt);
if (mysql_stmt_errno(S->stmt) == 2057) {
/* CR_NEW_STMT_METADATA makes the statement unusable */
diff --git a/ext/pdo_mysql/tests/pdo_mysql_stmt_execute_retry_after_failure.phpt
b/ext/pdo_mysql/tests/pdo_mysql_stmt_execute_retry_after_failure.phpt
new file mode 100644
index 000000000000..c1d8efb1762d
--- /dev/null
+++ b/ext/pdo_mysql/tests/pdo_mysql_stmt_execute_retry_after_failure.phpt
@@ -0,0 +1,61 @@
+--TEST--
+PDO MySQL native prepared statement can retry after execute failure
+--EXTENSIONS--
+pdo_mysql
+--SKIPIF--
+<?php
+require_once __DIR__ . '/inc/mysql_pdo_test.inc';
+MySQLPDOTest::skip();
+?>
+--FILE--
+<?php
+require_once __DIR__ . '/inc/mysql_pdo_test.inc';
+
+$db = MySQLPDOTest::factory();
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+$db->exec('CREATE TABLE pdo_mysql_stmt_execute_retry (id INT PRIMARY KEY, value INT NOT
NULL)');
+
+$stmt = $db->prepare('INSERT INTO pdo_mysql_stmt_execute_retry (id, value) VALUES (1,
?)');
+$value = null;
+$stmt->bindParam(1, $value, PDO::PARAM_INT);
+
+try {
+ $stmt->execute();
+} catch (PDOException $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+$value = 2;
+var_dump($stmt->execute());
+
+$stmt = $db->prepare('INSERT INTO pdo_mysql_stmt_execute_retry (id, value) VALUES (?,
?)');
+$stmt->bindValue(1, 2, PDO::PARAM_INT);
+$value = null;
+$stmt->bindParam(2, $value, PDO::PARAM_STR);
+
+try {
+ $stmt->execute();
+} catch (PDOException $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+$value = '3';
+var_dump($stmt->execute());
+foreach ($db->query('SELECT id, value FROM pdo_mysql_stmt_execute_retry ORDER BY id')
as $row) {
+ echo $row['id'], ': ', $row['value'], PHP_EOL;
+}
+?>
+--CLEAN--
+<?php
+require_once __DIR__ . '/inc/mysql_pdo_test.inc';
+$db = MySQLPDOTest::factory();
+$db->exec('DROP TABLE IF EXISTS pdo_mysql_stmt_execute_retry');
+?>
+--EXPECT--
+PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'value' cannot
be null
+bool(true)
+PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'value' cannot
be null
+bool(true)
+1: 2
+2: 3