DDC-1984: ORM tries to fetch an already deleted versioned entity and fails with spl_object_hash error #2505

Open
opened 2026-01-22 13:55:22 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Aug 15, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user jaco:

This is a nasty bug, it doesn't always happen, and i can't seem to reproduce it consistently.

It sometimes happens when trying to fetch a versioned entity which doesn't exist anymore in the database.

Setup:
PHP 5.4.5
PostgreSQL 9.1
Doctrine 2.2.2 with array cache, XML mapping driver

Entity config: BaseEntity mapped as mapped-superclass, User entity extending the base entity:

Mapping file:
{quote}

    <field name="updatedOn" type="datetime" column="updated_on" />
    <field name="version" version="true" type="integer" column="version" />

    <many-to-one field="updatedBy" target-entity="User">
        <join-column name="updated*by" referenced-column-name="user*id" />
    </many-to-one>

</mapped-superclass>   

{quote}

User entity:

{quote}



<field name="userName" type="string" column="username" length="20" />
<field name="passwordHash" type="string" column="password_hash" length="40" />
<field name="fullName" type="string" column="fullname" length="45" />
<field name="isAdmin" type="boolean" column="is_admin" />
<field name="isActive" type="boolean" column="is_active" />    
{quote}

Relevant part of stack trace:

{quote}
PHP Error [2]

spl_object_hash() expects parameter 1 to be object, null given (/var/www/html/repository/Doctrine/ORM/UnitOfWork.php:1318)
#0 unknown(0): CWebApplication->handleError()
#1 /var/www/html/repository/Doctrine/ORM/UnitOfWork.php(1318): spl_object_hash()
#2 /var/www/html/repository/Doctrine/ORM/UnitOfWork.php(2141): Doctrine\ORM\UnitOfWork->getEntityState()
#3 /var/www/html/repository/Doctrine/ORM/EntityRepository.php(145): Doctrine\ORM\UnitOfWork->lock()
#4 /var/www/html/repository/Doctrine/ORM/EntityManager.php(371): Doctrine\ORM\EntityRepository->find()
#5 /var/www/html/repository/Specula/Dao/BaseDao.php(103): Doctrine\ORM\EntityManager->find()
#6 /var/www/html/repository/Specula/Dao/UserDao.php(33): Specula\Dao\UserDao->findEntityById()
#7 /var/www/html/repository/Specula/Managers/UserManager.php(91): Specula\Dao\UserDao->findById()
#8 /var/www/html/repository/Doctrine/ORM/EntityManager.php(220): Specula\Managers\UserManager->Specula\Managers{closure}()
#9 /var/www/html/repository/Specula/Managers/UserManager.php(93): Doctrine\ORM\EntityManager->transactional()

{quote}

Deleting the proxy, restarting webserver, restarting database server doesn't help. i'm using the array cache and apc is disabled.

If you need more information let me know i'm currently experiencing this bug so i can provide more information.

Best regards,

Jaco

Originally created by @doctrinebot on GitHub (Aug 15, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user jaco: This is a nasty bug, it doesn't always happen, and i can't seem to reproduce it consistently. It sometimes happens when trying to fetch a versioned entity which doesn't exist anymore in the database. Setup: PHP 5.4.5 PostgreSQL 9.1 Doctrine 2.2.2 with array cache, XML mapping driver Entity config: BaseEntity mapped as mapped-superclass, User entity extending the base entity: Mapping file: {quote} <mapped-superclass name="Specula\Entities\BaseEntity"> ``` <field name="updatedOn" type="datetime" column="updated_on" /> <field name="version" version="true" type="integer" column="version" /> <many-to-one field="updatedBy" target-entity="User"> <join-column name="updated*by" referenced-column-name="user*id" /> </many-to-one> </mapped-superclass> ``` {quote} User entity: {quote} <entity name="Specula\Entities\User" table="users"> <id name="id" type="integer" column="user_id"> <generator strategy="AUTO" /> </id> ``` <field name="userName" type="string" column="username" length="20" /> <field name="passwordHash" type="string" column="password_hash" length="40" /> <field name="fullName" type="string" column="fullname" length="45" /> <field name="isAdmin" type="boolean" column="is_admin" /> <field name="isActive" type="boolean" column="is_active" /> ``` </entity> {quote} Relevant part of stack trace: {quote} PHP Error [2] spl_object_hash() expects parameter 1 to be object, null given (/var/www/html/repository/Doctrine/ORM/UnitOfWork.php:1318) #0 unknown(0): CWebApplication->handleError() #1 /var/www/html/repository/Doctrine/ORM/UnitOfWork.php(1318): spl_object_hash() #2 /var/www/html/repository/Doctrine/ORM/UnitOfWork.php(2141): Doctrine\ORM\UnitOfWork->getEntityState() #3 /var/www/html/repository/Doctrine/ORM/EntityRepository.php(145): Doctrine\ORM\UnitOfWork->lock() #4 /var/www/html/repository/Doctrine/ORM/EntityManager.php(371): Doctrine\ORM\EntityRepository->find() #5 /var/www/html/repository/Specula/Dao/BaseDao.php(103): Doctrine\ORM\EntityManager->find() #6 /var/www/html/repository/Specula/Dao/UserDao.php(33): Specula\Dao\UserDao->findEntityById() #7 /var/www/html/repository/Specula/Managers/UserManager.php(91): Specula\Dao\UserDao->findById() #8 /var/www/html/repository/Doctrine/ORM/EntityManager.php(220): Specula\Managers\UserManager->Specula\Managers{closure}() #9 /var/www/html/repository/Specula/Managers/UserManager.php(93): Doctrine\ORM\EntityManager->transactional() {quote} Deleting the proxy, restarting webserver, restarting database server doesn't help. i'm using the array cache and apc is disabled. If you need more information let me know i'm currently experiencing this bug so i can provide more information. Best regards, Jaco
admin added the Bug label 2026-01-22 13:55:22 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2505