File tree Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -1617,8 +1617,10 @@ PHP_METHOD(PDOStatement, errorInfo)
1617
1617
array_init (return_value );
1618
1618
add_next_index_string (return_value , stmt -> error_code );
1619
1619
1620
- if (stmt -> dbh -> methods -> fetch_err ) {
1621
- stmt -> dbh -> methods -> fetch_err (stmt -> dbh , stmt , return_value );
1620
+ if (strncmp (stmt -> error_code , PDO_ERR_NONE , sizeof (PDO_ERR_NONE ))) {
1621
+ if (stmt -> dbh -> methods -> fetch_err ) {
1622
+ stmt -> dbh -> methods -> fetch_err (stmt -> dbh , stmt , return_value );
1623
+ }
1622
1624
}
1623
1625
1624
1626
error_count = zend_hash_num_elements (Z_ARRVAL_P (return_value ));
Original file line number Diff line number Diff line change
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) " );
21
+
22
+ $ stmt = $ db ->prepare ('INSERT INTO test VALUES(?) ' );
23
+
24
+ // fail
25
+ var_dump ($ stmt ->execute ([PHP_INT_MIN ]), $ stmt ->errorCode (), $ stmt ->errorInfo ());
26
+
27
+ // success
28
+ var_dump ($ stmt ->execute ([1 ]), $ stmt ->errorCode (), $ stmt ->errorInfo ());
29
+ ?>
30
+ ===DONE===
31
+ --EXPECTF--
32
+ bool(false)
33
+ string(%d) "%s"
34
+ array(3) {
35
+ [0]=>
36
+ string(%d) "%s"
37
+ [1]=>
38
+ int(%d)
39
+ [2]=>
40
+ string(%d) "%s"
41
+ }
42
+ bool(true)
43
+ string(5) "00000"
44
+ array(3) {
45
+ [0]=>
46
+ string(5) "00000"
47
+ [1]=>
48
+ NULL
49
+ [2]=>
50
+ NULL
51
+ }
52
+ ===DONE===
You can’t perform that action at this time.
0 commit comments