DDC-483: DiscriminatorMap misbehaves when key are Integer #605

Closed
opened 2026-01-22 12:44:04 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 30, 2010).

Jira issue originally created by user ulf.thomas:

When in a Class-Inheritance Scenario @DiscriminatorMap is set like "@DiscriminatorMap({2="Class1", 4="Class2"})" (DiscriminatorColumn is of type Integer) then EntityManager->find('Class2', 'key)->will return an object of type Class1.

I hunted down the bug to Doctrine/Common/Annotations/Parser.php (Line: 412):

if (is_string($key)) {
$array[$key] = $value[$key];
} else {
$array[] = $value[$key];
}

should be:

if (is_string($key) || is_int($key)) {
$array[$key] = $value[$key];
} else {
$array[] = $value[$key];
}

Originally created by @doctrinebot on GitHub (Mar 30, 2010). Jira issue originally created by user ulf.thomas: When in a Class-Inheritance Scenario @DiscriminatorMap is set like "@DiscriminatorMap({2="Class1", 4="Class2"})" (DiscriminatorColumn is of type Integer) then EntityManager->find('Class2', 'key)->will return an object of type Class1. I hunted down the bug to Doctrine/Common/Annotations/Parser.php (Line: 412): if (is_string($key)) { $array[$key] = $value[$key]; } else { $array[] = $value[$key]; } should be: if (is_string($key) <ins>|| is_int($key)</ins>) { $array[$key] = $value[$key]; } else { $array[] = $value[$key]; }
admin added the Bug label 2026-01-22 12:44:04 +01:00
admin closed this issue 2026-01-22 12:44:05 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 31, 2010):

Comment created by romanb:

Should be fixed now (differently than you suggested though, because that broke other functionality).

@doctrinebot commented on GitHub (Mar 31, 2010): Comment created by romanb: Should be fixed now (differently than you suggested though, because that broke other functionality).
Author
Owner

@doctrinebot commented on GitHub (Mar 31, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 31, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#605