Skip to content

dba_insert() for ini files can result in duplicate keys #10891

Open
@nielsdos

Description

@nielsdos

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions