[php-src] Issue #10891: dba_insert() for ini files can result in duplicate keys
| From: | nielsdos | Date: | Mon, 20 Mar 2023 21:33:51 +0000 |
| Subject: | [php-src] Issue #10891: dba_insert() for ini files can result in duplicate keys | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243946@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10891
Author: nielsdos
### Description
The following code:
```php
<?php
@unlink("test.ini");
touch("test.ini");
$db = dba_open("test.ini", "wl", "inifile");
var_dump($db);
var_dump(dba_fetch("nonexisting", $db));
var_dump(dba_insert("nonexisting", "newvalue", $db));
var_dump(dba_insert("nonexisting", "newvalue", $db));
dba_close($db);
```
Resulted in this output:
```
resource(7) of type (dba)
bool(false)
bool(true)
bool(true)
```
But I expected this output instead:
```
resource(7) of type (dba)
bool(false)
bool(true)
bool(false)
```
And additionally: not an extra same-key entry in my ini file.
Because according to the docs at https://www.php.net/manual/en/function.dba-insert.php:
> If this key already exist in the database, this function will fail.
### PHP Version
PHP 8.1+
### Operating System
Linux 6.2.x