Skip to content

Commit 0f428ae

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
2 parents a528571 + df52903 commit 0f428ae

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

ext/pdo/pdo_stmt.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1551,8 +1551,10 @@ PHP_METHOD(PDOStatement, errorInfo)
15511551
array_init(return_value);
15521552
add_next_index_string(return_value, stmt->error_code);
15531553

1554-
if (stmt->dbh->methods->fetch_err) {
1555-
stmt->dbh->methods->fetch_err(stmt->dbh, stmt, return_value);
1554+
if (strncmp(stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) {
1555+
if (stmt->dbh->methods->fetch_err) {
1556+
stmt->dbh->methods->fetch_err(stmt->dbh, stmt, return_value);
1557+
}
15561558
}
15571559

15581560
error_count = zend_hash_num_elements(Z_ARRVAL_P(return_value));

ext/pdo/tests/gh8626.phpt

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--TEST--
2+
GH-8626: PDOStatement->execute() failed, then execute successfully, errorInfo() information is incorrect
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo')) die('skip');
6+
$dir = getenv('REDIR_TEST_DIR');
7+
if (false == $dir) die('skip no driver');
8+
require_once $dir . 'pdo_test.inc';
9+
PDOTest::skip();
10+
?>
11+
--FILE--
12+
<?php
13+
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
14+
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15+
16+
$db = PDOTest::factory();
17+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
18+
19+
$db->exec('DROP TABLE test');
20+
$db->exec('CREATE TABLE test (x int NOT NULL)');
21+
22+
$stmt = $db->prepare('INSERT INTO test VALUES(?)');
23+
24+
// fail
25+
var_dump($stmt->execute([null]), $stmt->errorCode());
26+
$errorInfo = $stmt->errorInfo();
27+
if (isset($errorInfo[3])) {
28+
unset($errorInfo[3]); // odbc
29+
}
30+
var_dump($errorInfo);
31+
32+
$stmt->closeCursor(); // sqlite
33+
34+
// success
35+
var_dump($stmt->execute([1]), $stmt->errorCode());
36+
$errorInfo = $stmt->errorInfo();
37+
if (isset($errorInfo[3])) {
38+
unset($errorInfo[3]); // odbc
39+
}
40+
var_dump($errorInfo);
41+
?>
42+
===DONE===
43+
--EXPECTF--
44+
bool(false)
45+
string(%d) "%s"
46+
array(3) {
47+
[0]=>
48+
string(%d) "%s"
49+
[1]=>
50+
int(%d)
51+
[2]=>
52+
string(%d) "%s%w%S"
53+
}
54+
bool(true)
55+
string(5) "00000"
56+
array(3) {
57+
[0]=>
58+
string(5) "00000"
59+
[1]=>
60+
NULL
61+
[2]=>
62+
NULL
63+
}
64+
===DONE===

ext/pdo_pgsql/tests/bug62593.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ $expect = 'No errors found';
5454

5555
foreach ($errors as $error)
5656
{
57-
if (strpos('Invalid text representation', $error[2]) !== false)
57+
if (null !== $error[2] && strpos('Invalid text representation', $error[2]) !== false)
5858
{
5959
$expect = 'Invalid boolean found';
6060
}

0 commit comments

Comments
 (0)