File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ PHP NEWS
63
63
. Fix access on NULL pointer in array_merge_recursive(). (ilutov)
64
64
. Fix exception handling in array_multisort(). (ilutov)
65
65
66
+ - SQLite3:
67
+ . Fixed bug GH-11451 (Invalid associative array containing duplicate
68
+ keys). (nielsdos)
69
+
66
70
08 Jun 2023, PHP 8.2.7
67
71
68
72
- Core:
Original file line number Diff line number Diff line change @@ -1982,7 +1982,9 @@ PHP_METHOD(SQLite3Result, fetchArray)
1982
1982
Z_ADDREF (data );
1983
1983
}
1984
1984
}
1985
- zend_symtable_add_new (Z_ARR_P (return_value ), result_obj -> column_names [i ], & data );
1985
+ /* Note: we can't use the "add_new" variant here instead of "update" because
1986
+ * when the same column name is encountered, the last result should be taken. */
1987
+ zend_symtable_update (Z_ARR_P (return_value ), result_obj -> column_names [i ], & data );
1986
1988
}
1987
1989
}
1988
1990
break ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-11451 (Invalid associative array containing duplicate keys)
3
+ --EXTENSIONS--
4
+ sqlite3
5
+ --FILE--
6
+ <?php
7
+ var_dump ((new SQLite3 (':memory: ' ))
8
+ ->query ('SELECT 1 AS key, 2 AS key ' )
9
+ ->fetchArray (SQLITE3_ASSOC ));
10
+
11
+ var_dump ((new SQLite3 (':memory: ' ))
12
+ ->query ('SELECT 0 AS dummy, 1 AS key, 2 AS key ' )
13
+ ->fetchArray (SQLITE3_ASSOC ));
14
+ ?>
15
+ --EXPECT--
16
+ array(1) {
17
+ ["key"]=>
18
+ int(2)
19
+ }
20
+ array(2) {
21
+ ["dummy"]=>
22
+ int(0)
23
+ ["key"]=>
24
+ int(2)
25
+ }
You can’t perform that action at this time.
0 commit comments