Skip to content

problem discriminatorValue with 0 #2712

@parada85

Description

@parada85

Bug Report

Q A
BC Break no
Version 2.10.0

Summary

Problem when having a "discriminatorValue" with value 0

Current behavior

When the query is being composed, it checks this condition in DocumentPersister.php:1473

  if (! $key) {
      continue;
  }

However, this means that having a discriminatorValue with a value of 0 is not allowed. Shouldn't it be something like $key !== false instead?

How to reproduce

Perform any document search when child classes have a discriminator with a value of 0.

    const CONTENT_TYPE_NWS = 0;
    const CONTENT_TYPE_IMA = 1;
    const MAPPING = [
        self::CONTENT_TYPE_NWS => ContentNews::class,
        self::CONTENT_TYPE_IMA => ContentImage::class,
    ];

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions