Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

compensate for lazy-loaded associations using proxy classes. #708

Merged
1 commit merged into from

2 participants

@craigh
Owner

So, when an Entity is loaded and you try to convert it to an array, it can be a problem if you have associations in that Entity. It will cause errors like

[29-Jan-2013 19:13:55] PHP Fatal error:  Call to undefined method DoctrineProxy\__CG__\Dizkus_Entity_Topic::get_entityPersister() in /Applications/MAMP/htdocs/core.git/src/lib/Zikula/EntityAccess.php on line 76

because the properties of the Proxy are attempted to be converted in the Array. This is impossible since there are no getters for the proxy properties.

This PR attempts to correct that. The double check (if instanceof and if name) may be overkill. Probably just if (name) would work, but just being thorough :smile:

Q A
Bug fix? kinda
New feature? kinda
BC breaks? [no]
Deprecations? [no]
Tests pass? n/a
Fixed tickets n/a
License MIT
Doc PR n/a
@ghost

@Guite - any comments?

@Guite
Owner

no

@ghost ghost merged commit c5e5420 into from
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/lib/Zikula/EntityAccess.php
View
5 src/lib/Zikula/EntityAccess.php
@@ -68,6 +68,11 @@ public function toArray()
$r = $r->getParentClass();
foreach ($properties as $property) {
+ if ($this instanceof \Doctrine\ORM\Proxy\Proxy) {
+ if (($property->name == '_entityPersister') || ($property->name == '_identifier') || ($property->name == '__isInitialized__')) {
+ continue;
+ }
+ }
if ($property->name == 'reflection') {
continue;
}
Something went wrong with that request. Please try again.