php / php/php-src

dba_insert() for ini files can result in duplicate keys

Offen
#10,891 4 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@Girgias arbeitet bereits daran.

Seit 21.3.2023.

Bug Extension: dba Status: Verified
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.