[php-src] master: Merge branch 'PHP-8.6'

From: Date: Wed, 18 Nov 2026 15:05:24 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143832@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-11-18T10:01:55-05:00 Commit: https://github.com/php/php-src/commit/fc4f12281b0047e02c6ef7d506b22c857109b270 Raw diff: https://github.com/php/php-src/commit/fc4f12281b0047e02c6ef7d506b22c857109b270.diff Merge branch 'PHP-8.6' * PHP-8.6: 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 ext/pdo_mysql/mysql_statement.c Diff: 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

« previous php.cvs (#143832) next »