Skip to content

Invalid associative array containing duplicate keys #11451

Closed

Description

@t-voet

Description

The following code:

<?php
var_dump((new SQLite3(':memory:'))
	->query('SELECT 1 AS key,2 AS key')
	->fetchArray(SQLITE3_ASSOC));

Resulted in this output, for PHP 8.2.*:

array(2) {
  ["key"]=>
  int(1)
  ["key"]=>
  int(2)
}

But I expected this output instead, like PHP 8.1.20 and earlier:

array(1) {
  ["key"]=>
  int(2)
}

These duplicate keys are propagated by json_encode(), serialize(), ... resulting in invalid JSON, for example.

PHP Version

PHP 8.2.7

Operating System

FreeBSD 13.1-RELEASE-p6

Activity

  1. ndossche commented on Jun 14, 2023

    @ndossche
    Member

    Thanks for the report.
    Fails with this assertion: php: zend_hash.c:773: _zend_hash_add_or_update_i: Assertion (flag & (1<<3)) == 0' failed.` I'll check it out.
    EDIT: regressed in 1487dd0

  2. added a commit that references this issue on Jun 14, 2023
    f83168b
  3. added a commit that references this issue on Jun 15, 2023
    29a96e0
  4. added a commit that references this issue on Jun 15, 2023
    035105b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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