Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _related property so Phalcon avoids to make a lazy loading #754

Closed
wants to merge 1 commit into from

Conversation

Surt
Copy link
Contributor

@Surt Surt commented Apr 6, 2017

I need to know in phlacon model if the relationship is loaded. Actually it's impossible witthout something like this phalcon/cphalcon#12772 because calling the property launchs the lazy loading.

Then, I need the eagerload library to fill that protected property in the model (impossible by any means, so we need to push changes to phalcon: a new method or more arguments in getRelated or something so we can fill the _related array with the eager loaded results from the Loader class);

References: stibiumz/phalcon.eager-loading#12

Hello!

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the Contributing Guidelines?
  • I have checked that another pull request for this purpose does not exist.
  • I wrote some tests for this PR.

Small description of change:

Thanks

When using relationships lazy loading along with magic "getPropertyName" methods the relationships are lazy loaded without having the eager load in consideration. This patch fix it.

References: stibiumz/phalcon.eager-loading#12
@Surt
Copy link
Contributor Author

Surt commented Apr 6, 2017

This will not work. _relatedis a protected property. Any clue on how to do it?

@Jurigag
Copy link
Contributor

Jurigag commented Apr 6, 2017

Edit it to work in EagerLoadingTrait?

@Surt
Copy link
Contributor Author

Surt commented Apr 6, 2017

@Jurigag the trait is using Loader. And thats where we need to put it, since we can Load::from a bunch of models (wich does not use the trait)

@sergeyklay
Copy link
Contributor

The 3.1.x branch is not longer supported. Could you please submit PR to the 3.2.x branch?

@Surt
Copy link
Contributor Author

Surt commented Apr 19, 2017

@sergeyklay the pull does not work. I would love to discuss it here, or I can close this and create an issue if you prefer.

As I see it, all this is avoidable with just a change. Just change the "array" returned on the eager loading for an object. Maybe an ArrayObject.
All the lazyloading stuff on phalcon just checks is the alias property contains an object.
https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/model.zep#L4331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants