dba_insert() for ini files can result in duplicate keys
Open
@Girgias is already working on this.
Since Mar 21, 2023.
Bug
Extension: dba
Status: Verified
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.