DDC-455: E_NOTICE Undefined index when setting field to a property that is not persisted #569

Closed
opened 2026-01-22 12:42:59 +01:00 by admin · 4 comments
Owner

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

Jira issue originally created by user jakajancar:

Affects trunk.

A and B have a One-To-One mapping, with A being the owning side of the relationship. No cascade persist is set.

// Create entity A
$a = new A();
$em->persist($pt);
$em->flush();

echo "Created A {$b->getId()}\n";

// Create B and add it to A
$b = new B();
$a->setB($b);
//$em->persist($b); // oops, forgot

$em->flush();

echo "Created B {$b->getId()}\n";

Expected: either throw an exception saying that A is attempting to reference an instance of B that is not persisted, or silently ignore the field.

Actual: Cryptic notice:

E_NOTICE (8): Undefined index: 0000000069d80795000000006ebfc57d (Doctrine/ORM/UnitOfWork.php:1903)

Originally created by @doctrinebot on GitHub (Mar 21, 2010). Jira issue originally created by user jakajancar: Affects trunk. A and B have a One-To-One mapping, with A being the owning side of the relationship. No cascade persist is set. ``` // Create entity A $a = new A(); $em->persist($pt); $em->flush(); echo "Created A {$b->getId()}\n"; // Create B and add it to A $b = new B(); $a->setB($b); //$em->persist($b); // oops, forgot $em->flush(); echo "Created B {$b->getId()}\n"; ``` Expected: either throw an exception saying that A is attempting to reference an instance of B that is not persisted, or silently ignore the field. Actual: Cryptic notice: E_NOTICE (8): Undefined index: 0000000069d80795000000006ebfc57d (Doctrine/ORM/UnitOfWork.php:1903)
admin added the Bug label 2026-01-22 12:42:59 +01:00
admin closed this issue 2026-01-22 12:42:59 +01:00
Author
Owner

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

@doctrinebot commented on GitHub (Mar 21, 2010): - is referenced by [DDC-203: Detached entities are recognized as new ones](http://www.doctrine-project.org/jira/browse/DDC-203)
Author
Owner

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

Comment created by @guilhermeblanco:

The issue you have is the same as if you use result cache. The entity is not managed by EM.
Maybe an "Entity of class " . get_class($entity) . " not managed by EntityManager." exception is the best solution here.

Cheers,

@doctrinebot commented on GitHub (Mar 23, 2010): Comment created by @guilhermeblanco: The issue you have is the same as if you use result cache. The entity is not managed by EM. Maybe an "Entity of class " . get_class($entity) . " not managed by EntityManager." exception is the best solution here. Cheers,
Author
Owner

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

Comment created by @beberlei:

Given that the combination:

$hash = spl*object*hash($object);
return $this->somefoo[$hash];

is probably one of the most called constructs in the complete code I tend to disagree with a check on each and everyone of them. However i to see the tendency towards errors of this kind as annoying, but maybe we can catch them earlier in those spots where they occour most often?

@doctrinebot commented on GitHub (Mar 23, 2010): Comment created by @beberlei: Given that the combination: ``` $hash = spl*object*hash($object); return $this->somefoo[$hash]; ``` is probably one of the most called constructs in the complete code I tend to disagree with a check on each and everyone of them. However i to see the tendency towards errors of this kind as annoying, but maybe we can catch them earlier in those spots where they occour most often?
Author
Owner

@doctrinebot commented on GitHub (Jul 7, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jul 7, 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#569