File tree 4 files changed +72
-3
lines changed
4 files changed +72
-3
lines changed Original file line number Diff line number Diff line change 7
7
. Fixed bug #78139 (timezone_open accepts invalid timezone string argument).
8
8
(Derick)
9
9
10
+ - PDO ODBC:
11
+ . Fixed errorInfo() result on successful PDOStatement->execute(). (Yurunsoft)
12
+
10
13
09 Jun 2022, PHP 8.0.20
11
14
12
15
- CLI:
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 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===
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ $expect = 'No errors found';
51
51
52
52
foreach ($ errors as $ error )
53
53
{
54
- if (strpos ('Invalid text representation ' , $ error [2 ]) !== false )
54
+ if (null !== $ error [ 2 ] && strpos ('Invalid text representation ' , $ error [2 ]) !== false )
55
55
{
56
56
$ expect = 'Invalid boolean found ' ;
57
57
}
You can’t perform that action at this time.
0 commit comments