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
6363 . Fix access on NULL pointer in array_merge_recursive(). (ilutov)
6464 . Fix exception handling in array_multisort(). (ilutov)
6565
66+ - SQLite3:
67+ . Fixed bug GH-11451 (Invalid associative array containing duplicate
68+ keys). (nielsdos)
69+
667008 Jun 2023, PHP 8.2.7
6771
6872- Core:
Original file line number Diff line number Diff line change @@ -1982,7 +1982,9 @@ PHP_METHOD(SQLite3Result, fetchArray)
19821982 Z_ADDREF (data );
19831983 }
19841984 }
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 );
19861988 }
19871989 }
19881990 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