Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.4.25

- PDO:
. Fixed pdo_raise_impl_error() emitting warnings under ERRMODE_SILENT.
(iliaal)

- Date:
. Fixed leak on double DatePeriod::__construct() call. (ilutov)

Expand Down
13 changes: 4 additions & 9 deletions ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,16 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, pdo_error_type sqlst
char *message = NULL;
const char *msg;

if (dbh->error_mode == PDO_ERRMODE_SILENT) {
#if 0
/* BUG: if user is running in silent mode and hits an error at the driver level
* when they use the PDO methods to call up the error information, they may
* get bogus information */
return;
#endif
}

if (stmt) {
pdo_err = &stmt->error_code;
}

memcpy(*pdo_err, sqlstate, sizeof(pdo_error_type));

if (dbh->error_mode == PDO_ERRMODE_SILENT) {
return;
}

/* hash sqlstate to error messages */
msg = pdo_sqlstate_state_to_description(*pdo_err);
if (!msg) {
Expand Down
21 changes: 21 additions & 0 deletions ext/pdo_sqlite/tests/pdo_silent_impl_error.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
pdo_raise_impl_error honors ERRMODE_SILENT (no warning)
--EXTENSIONS--
pdo_sqlite
--FILE--
<?php
$pdo = new PDO('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
set_error_handler(function (int $errno, string $errstr): bool {
echo "warning: $errstr\n";
return true;
});
$result = $pdo->getAttribute(123456);
echo "result: ";
var_dump($result);
echo "errorInfo: ";
var_dump($pdo->errorInfo()[0]);
?>
--EXPECT--
result: bool(false)
errorInfo: string(5) "IM001"
Loading