Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem discriminatorValue with 0 #2712

Open
parada85 opened this issue Jan 9, 2025 · 2 comments
Open

problem discriminatorValue with 0 #2712

parada85 opened this issue Jan 9, 2025 · 2 comments
Labels
Milestone

Comments

@parada85
Copy link

parada85 commented Jan 9, 2025

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,
    ];

@malarzm
Copy link
Member

malarzm commented Jan 9, 2025

Most likely it should :) Feel free to give it a go and see what breaks!

@malarzm malarzm added the Bug label Jan 9, 2025
@malarzm malarzm added this to the 2.9.2 milestone Jan 9, 2025
@parada85
Copy link
Author

parada85 commented Jan 9, 2025

I've already tried it and it works perfectly!:D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants