Skip to content

ext/dba/tests/dba_gdbm.phpt: test failure due to key ordering #14786

Closed
@orlitzky

Description

@orlitzky

Description

Original report: https://bugs.gentoo.org/935379

The diff for this failed tests contains e.g.

-key4: Another Content String
 key2: Content String 2
 key5: The last content string
-[key10]name10: Content String 10
 name9: Content String 9
+[key10]name10: Content String 10
+key4: Another Content String
 [key30]name30: Content String 30
 Total keys: 6

The corresponding test code is,

// Fetch data                                                               
$key = dba_firstkey($db_writer);
$total_keys = 0;
while ($key) {
    echo $key, ': ', dba_fetch($key, $db_writer), \PHP_EOL;
    $key = dba_nextkey($db_writer);
    $total_keys++;
}
echo 'Total keys: ', $total_keys, \PHP_EOL;

So to me it looks like the insert order is not guaranteed to be the iteration order according to dba_firstkey() and dba_nextkey(). Since there are only six keys, I guess we could sort the output (in a locale-independent way) before printing it?

PHP Version

PHP-8.2.20

Operating System

Gentoo Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions