[PR #315] [MERGED] Allowing proxies to be passed to ORM public API #8015

Open
opened 2026-01-22 15:57:59 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/315
Author: @Ocramius
Created: 3/31/2012
Status: Merged
Merged: 5/4/2012
Merged by: @beberlei

Base: masterHead: getclass-on-proxies-refactoring


📝 Commits (6)

  • cbe4987 Using Doctrine\Common\Util\ClassUtil for class_name resolutionThis avoids exceptions when passing a Proxy instance to the public API of the EntityManager, ClassMetadataFactory or UnitOfWork when the Proxy itself isn't generated by the EntityManager itself, while discovering the correct ClassMetadata instance for the proxy
  • c4a2eae Adding additional missing calls to classutils instead of get_class
  • 37279d0 Adding test to verify validity of changes (fails without them)
  • d1e868a Removing registration of proxy ClassMetadata by the proxyFactory
  • 85ea27d Adding tests for additional usages of the proxy classname in ORM public API
  • cb7a77c Removing usage of ClassUtil where not strictly needed

📊 Changes

6 files changed (+178 additions, -45 deletions)

View changed files

📝 lib/Doctrine/ORM/AbstractQuery.php (+2 -2)
📝 lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php (+32 -28)
📝 lib/Doctrine/ORM/Persisters/BasicEntityPersister.php (+3 -2)
📝 lib/Doctrine/ORM/Proxy/ProxyFactory.php (+0 -4)
📝 lib/Doctrine/ORM/UnitOfWork.php (+8 -9)
tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php (+133 -0)

📄 Description

Basically, following happens:

$proxy = some_unserialization();
$em->persist($proxy); // exception because the class name is not recognized

This change forces loading of metadata even with proxy class names passed to the ClassMetadataFactory API.

I need some feedback on the test cases. All three tests fail without the patch, while Build Status with it applied.

What is a bit tricky is the status of the proxies.

Cases where $__initialized__ = false; && $_identifier = array(); and others fail because of notices and weird issues that are very difficult to hunt down. That is because of the strange nature of proxies obviously. I just wanted to know if this should be somehow fixed in here.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/315 **Author:** [@Ocramius](https://github.com/Ocramius) **Created:** 3/31/2012 **Status:** ✅ Merged **Merged:** 5/4/2012 **Merged by:** [@beberlei](https://github.com/beberlei) **Base:** `master` ← **Head:** `getclass-on-proxies-refactoring` --- ### 📝 Commits (6) - [`cbe4987`](https://github.com/doctrine/orm/commit/cbe4987e18e0be1f5c31ee3106a50325b673f3df) Using Doctrine\Common\Util\ClassUtil for class_name resolutionThis avoids exceptions when passing a Proxy instance to the public API of the EntityManager, ClassMetadataFactory or UnitOfWork when the Proxy itself isn't generated by the EntityManager itself, while discovering the correct ClassMetadata instance for the proxy - [`c4a2eae`](https://github.com/doctrine/orm/commit/c4a2eaea49dcf9dd654e90364362959882b904fa) Adding additional missing calls to classutils instead of get_class - [`37279d0`](https://github.com/doctrine/orm/commit/37279d075311ffd2783e3f11d141df9cccd7d206) Adding test to verify validity of changes (fails without them) - [`d1e868a`](https://github.com/doctrine/orm/commit/d1e868a32ae8e61d8cfd70afb0d5750ada489a0e) Removing registration of proxy ClassMetadata by the proxyFactory - [`85ea27d`](https://github.com/doctrine/orm/commit/85ea27dba2d7531531e5adeb51463e1d489ac6c8) Adding tests for additional usages of the proxy classname in ORM public API - [`cb7a77c`](https://github.com/doctrine/orm/commit/cb7a77cc038b986adb15ee561a8c2c5661499490) Removing usage of ClassUtil where not strictly needed ### 📊 Changes **6 files changed** (+178 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/AbstractQuery.php` (+2 -2) 📝 `lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php` (+32 -28) 📝 `lib/Doctrine/ORM/Persisters/BasicEntityPersister.php` (+3 -2) 📝 `lib/Doctrine/ORM/Proxy/ProxyFactory.php` (+0 -4) 📝 `lib/Doctrine/ORM/UnitOfWork.php` (+8 -9) ➕ `tests/Doctrine/Tests/ORM/Functional/ProxiesLikeEntitiesTest.php` (+133 -0) </details> ### 📄 Description Basically, following happens: ``` php $proxy = some_unserialization(); $em->persist($proxy); // exception because the class name is not recognized ``` This change forces loading of metadata even with proxy class names passed to the `ClassMetadataFactory` API. I need some feedback on the test cases. All three tests fail without the patch, while [![Build Status](https://secure.travis-ci.org/Ocramius/doctrine2.png?branch=getclass-on-proxies-refactoring)](http://travis-ci.org/Ocramius/doctrine2) with it applied. What is a bit tricky is the status of the proxies. Cases where `$__initialized__ = false;` && `$_identifier = array();` and others fail because of notices and weird issues that are very difficult to hunt down. That is because of the strange nature of proxies obviously. I just wanted to know if this should be somehow fixed in here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 15:57:59 +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#8015