[php-src] master: Merge branch 'PHP-8.5'
| From: | Ilia Alshanetsky | Date: | Tue, 22 Sep 2026 01:56:09 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141361@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-21T21:52:29-04:00
Commit: https://github.com/php/php-src/commit/231526bd19e2c930e412a90c8331319444a32969
Raw diff: https://github.com/php/php-src/commit/231526bd19e2c930e412a90c8331319444a32969.diff
Merge branch 'PHP-8.5'
* PHP-8.5:
ext/pdo: Do not register a bindColumn() binding for an unknown column
Changed paths:
A ext/pdo/tests/pdo_bindcolumn_unknown_column.phpt
M NEWS
M ext/pdo/pdo_stmt.c
Diff:
diff --git a/NEWS b/NEWS
index 0ddd4712ed33..c91c7ce877af 100644
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,8 @@ PHP NEWS
- PDO:
. Fixed PDOStatement::getColumnMeta() reading out of bounds for an invalid
column index. (Ilia Alshanetsky)
+ . Fixed PDOStatement::bindColumn() registering a binding for a column name
+ that is not in the result set. (Ilia Alshanetsky)
- PGSQL:
. Fixed pg_lo_write() rejecting data containing null bytes. (Ilia Alshanetsky)
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index a7a41168757f..0eb6645608e7 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -305,6 +305,7 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_
spprintf(&tmp, 0, "Did not find column name '%s' in the defined columns; it
will not be bound", ZSTR_VAL(param->name));
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", tmp);
efree(tmp);
+ return false;
}
}
diff --git a/ext/pdo/tests/pdo_bindcolumn_unknown_column.phpt
b/ext/pdo/tests/pdo_bindcolumn_unknown_column.phpt
new file mode 100644
index 000000000000..44e85ec07c31
--- /dev/null
+++ b/ext/pdo/tests/pdo_bindcolumn_unknown_column.phpt
@@ -0,0 +1,41 @@
+--TEST--
+PDO: bindColumn() must fail for a column name that is not in the result set
+--EXTENSIONS--
+pdo
+--SKIPIF--
+<?php
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ .
'/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+
+$db = PDOTest::factory();
+$db->exec('CREATE TABLE pdo_bindcolumn_unknown_column (name varchar(255))');
+
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
+$stmt = $db->query('SELECT name FROM pdo_bindcolumn_unknown_column');
+var_dump(@$stmt->bindColumn('nosuchcolumn', $var));
+
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+try {
+ $stmt->bindColumn('nosuchcolumn', $var);
+} catch (PDOException $e) {
+ echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+}
+?>
+--CLEAN--
+<?php
+if (getenv('PDOTEST_DSN') === 'sqlite::memory:') return;
+
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory();
+$db->exec('DROP TABLE pdo_bindcolumn_unknown_column');
+?>
+--EXPECT--
+bool(false)
+PDOException: SQLSTATE[HY000]: General error: Did not find column name 'nosuchcolumn' in
the defined columns; it will not be bound