DDC-3115: UnitOfWok can't access proxies protected property #3866

Open
opened 2026-01-22 14:29:28 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (May 4, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user machete:

Running the code on different environments for a while now, I have never had any problems. Recently I installed the code onto a different server and I've been experiencing the following issue:

Fatal error: Cannot access protected property DoctrineORMModule\Proxy*CG*\Page\Entity\PageRevision::$date in src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 2596

I am absolutely clueless, why this happens. It seems to be affecting only specific data rows, as you might reproduce here: http://de.serlo.org/pages

The field is defined as followed:

    /****
     * @ORM\Column(type="datetime", options={"default"="CURRENT_TIMESTAMP"})
     */
    protected $date;

However, the exact same database snapshot works fine here: http://ptr.serlo.org/pages

Attached you will find a screenshot of the datarows. The yellow ones mark each one working and one not working row.

I have no idea what the problem is here.

Originally created by @doctrinebot on GitHub (May 4, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user machete: Running the code on different environments for a while now, I have never had any problems. Recently I installed the code onto a different server and I've been experiencing the following issue: > Fatal error: Cannot access protected property DoctrineORMModule\Proxy*_CG_*\Page\Entity\PageRevision::$date in src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 2596 I am absolutely clueless, why this happens. It seems to be affecting only specific data rows, as you might reproduce here: http://de.serlo.org/pages The field is defined as followed: ``` /**** * @ORM\Column(type="datetime", options={"default"="CURRENT_TIMESTAMP"}) */ protected $date; ``` However, the exact same database snapshot works fine here: http://ptr.serlo.org/pages Attached you will find a screenshot of the datarows. The yellow ones mark each one working and one not working row. I have no idea what the problem is here.
admin added the Bug label 2026-01-22 14:29:28 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 4, 2014):

Comment created by @ocramius:

Discussed this on IRC - very tricky, seems like one of the servers has the reflection property not set to "accessible"

@doctrinebot commented on GitHub (May 4, 2014): Comment created by @ocramius: Discussed this on IRC - very tricky, seems like one of the servers has the reflection property not set to "accessible"
Author
Owner

@doctrinebot commented on GitHub (May 4, 2014):

Comment created by machete:

Adding $class->reflFields[$field]->setAccessible(true) before line 2596 resolved this issue. Even after removing it, everything worked fine.

note to self:

[18:23] @ocramius machete_: can you find out where that particular property is instantiated?
[18:23] @ocramius should be in ClassMetadataInfo::wakeUpReflection() or such
[18:25] @ocramius if you find that again, consider looking at locations in the code where new ReflectionClass() is instantiated

@doctrinebot commented on GitHub (May 4, 2014): Comment created by machete: Adding `$class->reflFields[$field]->setAccessible(true)` before line 2596 resolved this issue. Even after removing it, everything worked fine. **note to self**: > [18:23] @ocramius machete_: can you find out where that particular property is instantiated? > [18:23] @ocramius should be in `ClassMetadataInfo::wakeUpReflection()` or such > [18:25] @ocramius if you find that again, consider looking at locations in the code where `new ReflectionClass()` is instantiated
Author
Owner

@leondeng commented on GitHub (Aug 24, 2016):

orm 2.5.4, experienced same error:

Fatal error: Cannot access protected property MCT\LRS\Proxy__CG__\MCT\LRS\Entity\Student::$Imports in /home/htsg/dev/workspace/mct-lrs/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 2773

Worse that Adding $class->reflFields[$field]->setAccessible(true) before line 2773 not working.
it did work when changed that line to $entity[$field] = $pColl;, and only because my entity implements \ArrayAccess.

@leondeng commented on GitHub (Aug 24, 2016): orm 2.5.4, experienced same error: > Fatal error: Cannot access protected property MCT\LRS\Proxy__CG__\MCT\LRS\Entity\Student::$Imports in /home/htsg/dev/workspace/mct-lrs/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php on line 2773 Worse that Adding `$class->reflFields[$field]->setAccessible(true)` before line 2773 not working. it did work when changed that line to `$entity[$field] = $pColl;`, and only because my entity implements \ArrayAccess.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3866