DDC-1732: Unserialized non-initialized proxy classes should throw an exception when a method is called #2178

Open
opened 2026-01-22 13:43:24 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 28, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user benjamin:

When we serialize entities in a session, we often have pointers to uninitialized proxies.
These proxies have $_entityPersister == null.

The problem is that if you happen to call by mistake a method on such a proxy, you're not aware that this is an uninitialized proxy, and the business methods are called, with null values for every property.

I think the proxy should throw an exception in that case.
Attached, a patch with the proposed modification.

Originally created by @doctrinebot on GitHub (Mar 28, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user benjamin: When we serialize entities in a session, we often have pointers to uninitialized proxies. These proxies have $_entityPersister == null. The problem is that if you happen to call by mistake a method on such a proxy, you're not aware that this is an uninitialized proxy, and the business methods are called, with null values for every property. I think the proxy should throw an exception in that case. Attached, a patch with the proposed modification.
admin added the Improvement label 2026-01-22 13:43:24 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/a7e685bcdb14ef1ce066

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/a7e685bcdb14ef1ce066 - [11173_ProxyFactory.php.patch](https://gist.github.com/a7e685bcdb14ef1ce066#file-11173_ProxyFactory-php-patch)
Author
Owner

@malukenho commented on GitHub (Jan 5, 2017):

@Ocramius I think it can be closed as invalid

@malukenho commented on GitHub (Jan 5, 2017): @Ocramius I think it can be closed as invalid
Author
Owner

@Ocramius commented on GitHub (Jan 5, 2017):

@malukenho this is probably still valid, and would need patching, or at least testing.

@Ocramius commented on GitHub (Jan 5, 2017): @malukenho this is probably still valid, and would need patching, or at least testing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2178