DDC-1432: $em->remove($entity) on entity that uses @Id + @ManyToOne generates fatal at UnitOfWork #1794

Closed
opened 2026-01-22 13:26:14 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 18, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user hypno:

$em->remove($entity) on entity that uses @Id + @ManyToOne generates fatal at UnitOfWork

/****
 * @Entity
 */
class UserData {

    /****
     * @Id
     * @ManyToOne(targetEntity="User")
     */
    protected $user;

    /****
     * @Id
     * @ManyToOne(targetEntity="Article")
     */
    protected $article;

    ......

}

$em->remove($userData);

PHP Catchable fatal error: Object of class User could not be converted to string in /path/to/Doctrine/ORM/UnitOfWork.php on line 2166

Probably because it tries to use UserData primary key properties directly and not detecting that its actually an association.

Originally created by @doctrinebot on GitHub (Oct 18, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user hypno: $em->remove($entity) on entity that uses @Id + @ManyToOne generates fatal at UnitOfWork ``` /**** * @Entity */ class UserData { /**** * @Id * @ManyToOne(targetEntity="User") */ protected $user; /**** * @Id * @ManyToOne(targetEntity="Article") */ protected $article; ...... } $em->remove($userData); ``` PHP Catchable fatal error: Object of class User could not be converted to string in /path/to/Doctrine/ORM/UnitOfWork.php on line 2166 Probably because it tries to use UserData primary key properties directly and not detecting that its actually an association.
admin added the Bug label 2026-01-22 13:26:14 +01:00
admin closed this issue 2026-01-22 13:26:14 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 18, 2011):

Comment created by @beberlei:

Line 2166 in version 2.1.2 is a docblock comment.

Can you specifiy this more and potentially add the stacktrace when this warning occurs (xdebug)?

@doctrinebot commented on GitHub (Nov 18, 2011): Comment created by @beberlei: Line 2166 in version 2.1.2 is a docblock comment. Can you specifiy this more and potentially add the stacktrace when this warning occurs (xdebug)?
Author
Owner

@doctrinebot commented on GitHub (Mar 14, 2012):

Comment created by @beberlei:

No feedback given.

@doctrinebot commented on GitHub (Mar 14, 2012): Comment created by @beberlei: No feedback given.
Author
Owner

@doctrinebot commented on GitHub (Mar 14, 2012):

Issue was closed with resolution "Incomplete"

@doctrinebot commented on GitHub (Mar 14, 2012): Issue was closed with resolution "Incomplete"
Author
Owner

@doctrinebot commented on GitHub (Jun 21, 2012):

Comment created by bill'o:

just got the same issue with a composite key on an association table, the line is 2242 in UnitOfWork.php

@doctrinebot commented on GitHub (Jun 21, 2012): Comment created by bill'o: just got the same issue with a composite key on an association table, the line is 2242 in UnitOfWork.php
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1794