Allowing proxies to be passed to ORM public API #315

merged 6 commits into from May 4, 2012


None yet

3 participants


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 is awesome. And yes, we should optimize performance of ClassUtils::getClass(), can you open a PR for this?

Can you also remove the setMetadataFor(...) in ProxyFactory? That is not necessary anymore, or is it?

@Ocramius Ocramius referenced this pull request in doctrine/common Mar 31, 2012

Classutil performance #130

@Ocramius Ocramius added a commit to Ocramius/common that referenced this pull request Mar 31, 2012
@Ocramius Ocramius Using Proxy interface instead of string comparison to detect the real…
… class name of an object

This also introduces small performance improvements that are needed for doctrine/doctrine2#315
beberlei commented Apr 7, 2012

Please rebase

Ocramius added some commits Mar 30, 2012
@Ocramius Ocramius Using Doctrine\Common\Util\ClassUtil for class_name resolutionThis av…
…oids 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
@Ocramius Ocramius Adding additional missing calls to classutils instead of get_class c4a2eae
@Ocramius Ocramius Adding test to verify validity of changes (fails without them) 37279d0
@Ocramius Ocramius Removing registration of proxy ClassMetadata by the proxyFactory
Ensuring that functionality is kept by checking for the real class name in the ClassMetadataFactory
@Ocramius Ocramius Adding tests for additional usages of the proxy classname in ORM publ…
…ic API

Like Proxy classnames in DQL, EM#getRepository, EM#getReference
@Ocramius Ocramius Removing usage of ClassUtil where not strictly needed
Optimizing the ClassMetadataFactory API instead and using ClassMetadata to check actual class names as da962f2e and c27b4de0 introduced too much overhead
Ocramius commented Apr 7, 2012

@beberlei done

asm89 commented May 4, 2012

@Ocramius As far as I can see this is ready to merge. Can you confirm? :)

Ocramius commented May 4, 2012

@asm89 indeed! Do it whenever you want :) Let me know if you need a rebase...

@beberlei beberlei merged commit e09a9c7 into doctrine:master May 4, 2012
@Ocramius Ocramius added a commit to Ocramius/common that referenced this pull request Jun 9, 2012
@Ocramius Ocramius Syncing changes of doctrine/doctrine2#315 in common
This change allows usage of proxy class names when requesting class metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment