[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Wed, 18 Nov 2026 15:05:19 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143829@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-11-18T10:01:39-05:00 Commit: https://github.com/php/php-src/commit/6111f73f1b115a60db49efd9b91a7e09d53414d6 Raw diff: https://github.com/php/php-src/commit/6111f73f1b115a60db49efd9b91a7e09d53414d6.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: 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 b74d9704a06d..fd35f61b2acf 100644 --- a/NEWS +++ b/NEWS @@ -100,6 +100,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 8b2519ce90aa..b780a49250cc 100644 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -268,9 +268,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 (#143829) next »