mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix GH-11451: Invalid associative array containing duplicate keys
This commit is contained in:
commit
035105b252
@ -1985,7 +1985,9 @@ PHP_METHOD(SQLite3Result, fetchArray)
|
||||
Z_ADDREF(data);
|
||||
}
|
||||
}
|
||||
zend_symtable_add_new(Z_ARR_P(return_value), result_obj->column_names[i], &data);
|
||||
/* Note: we can't use the "add_new" variant here instead of "update" because
|
||||
* when the same column name is encountered, the last result should be taken. */
|
||||
zend_symtable_update(Z_ARR_P(return_value), result_obj->column_names[i], &data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
25
ext/sqlite3/tests/gh11451.phpt
Normal file
25
ext/sqlite3/tests/gh11451.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
GH-11451 (Invalid associative array containing duplicate keys)
|
||||
--EXTENSIONS--
|
||||
sqlite3
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump((new SQLite3(':memory:'))
|
||||
->query('SELECT 1 AS key, 2 AS key')
|
||||
->fetchArray(SQLITE3_ASSOC));
|
||||
|
||||
var_dump((new SQLite3(':memory:'))
|
||||
->query('SELECT 0 AS dummy, 1 AS key, 2 AS key')
|
||||
->fetchArray(SQLITE3_ASSOC));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
["key"]=>
|
||||
int(2)
|
||||
}
|
||||
array(2) {
|
||||
["dummy"]=>
|
||||
int(0)
|
||||
["key"]=>
|
||||
int(2)
|
||||
}
|
Loading…
Reference in New Issue
Block a user