Lazy loading not working for parent.

17 views
Skip to first unread message

Bruno Reis

unread,
May 1, 2015, 9:28:47 PM5/1/15
to symfony-...@googlegroups.com
When accessing the parent property of a doc, the lazy loading is not working. 

Do you please have any ideas of what can be happening? 

---
Accessing 

$this->getChildren()[0]->getTitle() works fine and returns the title
 
but

$this->getParent()->getTitle() does not work, returns a "" (blank string)
and
$this->getParentDocument()->getTitle() does not work also.

I can see that the proxy is there, but it seems that data is not being loaded. 

David Buchmann

unread,
May 2, 2015, 4:40:20 AM5/2/15
to symfony-...@googlegroups.com
this is strange. so $this->getParent() returns you the proxy object, but
the proxy fails to initialize? are you sure that a title exists for the
parent? could it be a translation issue? if i remember correctly, the
proxy does not know whether you used findTranslation or not, it will use
the configured fallback order.
> --
> You received this message because you are subscribed to the Google
> Groups "symfony-cmf-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to symfony-cmf-us...@googlegroups.com
> <mailto:symfony-cmf-us...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--
Liip AG // Agile Web Development // T +41 43 500 39 80
CH-8005 Zurich // PGP 0xA581808B // www.liip.ch

Bruno Reis

unread,
May 2, 2015, 10:15:45 AM5/2/15
to symfony-...@googlegroups.com
I even inverted the parent-child relation and was able to load all props in that situation (when the entity was the child, not the parent). 

I tried to overwrite the proxy to test the initializer, but the proxy file gets overwritten at every request. 

Is there an easy way to stop proxies being regenerated? It would help me to debug. 

To unsubscribe from this group and stop receiving emails from it, send an email to symfony-cmf-us...@googlegroups.com.

David Buchmann

unread,
May 2, 2015, 10:19:57 AM5/2/15
to symfony-...@googlegroups.com
hi bruno,

afaik the proxies are only generated when
doctrine_phpcr.odm.auto_generate_proxy_classes is set to true. try
setitng it to false. then you need to warmup the cache to get the
proxies. usually this is set to %kernel.debug%, so they are regenerated
in dev mode but not in production mode.

cheers,david

On 02.05.2015 16:15, Bruno Reis wrote:
> I even inverted the parent-child relation and was able to load all props
> in that situation (when the entity was the child, not the parent).
>
> I tried to overwrite the proxy to test the initializer, but the proxy
> file gets overwritten at every request.
>
> Is there an easy way to stop proxies being regenerated? It would help me
> to debug.
>
> 2015-05-02 5:40 GMT-03:00 David Buchmann <da...@liip.ch
> <mailto:da...@liip.ch>>:
>
> this is strange. so $this->getParent() returns you the proxy object, but
> the proxy fails to initialize? are you sure that a title exists for the
> parent? could it be a translation issue? if i remember correctly, the
> proxy does not know whether you used findTranslation or not, it will use
> the configured fallback order.
>
> On 02.05.2015 03:28, Bruno Reis wrote:
> > When accessing the parent property of a doc, the lazy loading is not
> > working.
> >
> > Do you please have any ideas of what can be happening?
> >
> > ---
> > Accessing
> >
> > $this->getChildren()[0]->getTitle() works fine and returns the title
> >
> > but
> >
> > $this->getParent()->getTitle() does not work, returns a "" (blank
> string)
> > and
> > $this->getParentDocument()->getTitle() does not work also.
> >
> > I can see that the proxy is there, but it seems that data is not being
> > loaded.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "symfony-cmf-users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to symfony-cmf-us...@googlegroups.com
> <mailto:symfony-cmf-users%2Bunsu...@googlegroups.com>
> > <mailto:symfony-cmf-us...@googlegroups.com
> <mailto:symfony-cmf-users%2Bunsu...@googlegroups.com>>.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> Liip AG // Agile Web Development // T +41 43 500 39 80
> <tel:%2B41%2043%20500%2039%2080>
> CH-8005 Zurich // PGP 0xA581808B // www.liip.ch <http://www.liip.ch>
>
> --
> You received this message because you are subscribed to the Google
> Groups "symfony-cmf-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to symfony-cmf-us...@googlegroups.com
> <mailto:symfony-cmf-users%2Bunsu...@googlegroups.com>.

Bruno Reis

unread,
May 4, 2015, 2:23:04 PM5/4/15
to symfony-...@googlegroups.com
I updated the packages with the composer and it is working now. I don't know where the bug was, but it's gone. :-)

To unsubscribe from this group and stop receiving emails from it, send an email to symfony-cmf-us...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages