mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.0'
* PHP-8.0: Fixed bug #81037 PDO discards error message text from prepared statement Closes GH-6978.
This commit is contained in:
commit
dbfc9f99d1
3 changed files with 42 additions and 2 deletions
3
NEWS
3
NEWS
|
@ -92,7 +92,8 @@ PHP NEWS
|
|||
fetching a BLOB). (Nikita)
|
||||
|
||||
. PDO MySQL:
|
||||
. Fixed bug#80908 (PDO::lastInsertId() return wrong). (matt)
|
||||
. Fixed bug #80908 (PDO::lastInsertId() return wrong). (matt)
|
||||
. Fixed bug #81037 PDO discards error message text from prepared statement. (Kamil Tekiela)
|
||||
|
||||
. PDO ODBC:
|
||||
. Implement PDO_ATTR_SERVER_VERSION and PDO_ATTR_SERVER_INFO for
|
||||
|
|
|
@ -94,7 +94,11 @@ int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int lin
|
|||
dbh->is_persistent);
|
||||
|
||||
} else {
|
||||
einfo->errmsg = pestrdup(mysql_error(H->server), dbh->is_persistent);
|
||||
if (S && S->stmt) {
|
||||
einfo->errmsg = pestrdup(mysql_stmt_error(S->stmt), dbh->is_persistent);
|
||||
} else {
|
||||
einfo->errmsg = pestrdup(mysql_error(H->server), dbh->is_persistent);
|
||||
}
|
||||
}
|
||||
} else { /* no error */
|
||||
strcpy(*pdo_err, PDO_ERR_NONE);
|
||||
|
|
35
ext/pdo_mysql/tests/bug81037.phpt
Normal file
35
ext/pdo_mysql/tests/bug81037.phpt
Normal file
|
@ -0,0 +1,35 @@
|
|||
--TEST--
|
||||
Bug #81037 PDO discards error message text from prepared statement
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
MySQLPDOTest::createTestTable($pdo);
|
||||
|
||||
$sql = "SELECT id FROM test WHERE label = :par";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
try {
|
||||
$stmt->execute();
|
||||
} catch (PDOException $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
?>
|
||||
--EXPECT--
|
||||
SQLSTATE[HY000]: General error: 2031 No data supplied for parameters in prepared statement
|
Loading…
Add table
Add a link
Reference in a new issue