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

Fix loading references if mapped by uuid and not by id. #36

Merged

Conversation

joschi127
Copy link
Contributor

DocumentManager::getReference() does not work correctly if called with an uuid instead of an id,
so if we have an uuid here, we have to fetch the node first (which unfortunately is not optimal
from a performance point of view) to get the correct id of the document.
(DocumentManager::getReference() seems to work first - but it will initialize the id field with the
uuid and this will cause errors later, e.g. when accessing other referenced documents of the loaded
document - it is simply not possible to use it correctly with an uuid)

Am I right?

Is there a correct way to get a proxy class for a document when you only know the uuid and not the id? Unfortunately I could not find a way to do it. (I am using jackalope-doctrine-dbal)

Let's check and discuss if there is a better solution. :-)

DocumentManager::getReference() does not work correctly if called with an uuid instead of an id,
so if we have an uuid here, we have to fetch the node first (which unfortunately is not optimal
from a performance point of view) to get the correct id of the document.
(DocumentManager::getReference() seems to work first - but it will initialize the id field with the
uuid and this will cause errors later, e.g. when accessing other referenced documents of the loaded
document - it is simply not possible to use it correctly with an uuid)
@joschi127
Copy link
Contributor Author

@ElectricMaxxx This is related to doctrine/phpcr-odm#493 am I right?

@ElectricMaxxx
Copy link
Owner

ElectricMaxxx commented Sep 29, 2015 via email

@ElectricMaxxx
Copy link
Owner

@joschi127 I used to use the branch of the PR mentioned above and there it works to reference a node by its uuid, but didn't find the time wrap that one up and clean it.

So what would be better? Clean up the PR in the phpcr-odm or merge this one here?

@joschi127
Copy link
Contributor Author

@ElectricMaxxx Well at least one of them should be merged because otherwise things are broken ;-)

If it would be possible to clean up the PR in phpcr-odm and get it merged, it would be the preferred solution from my point of view, because this PR here works fine, but it causes an additional DB query which already happens when the proxy is created, so we kind of loose the advantages of the proxy to lazy load the referenced document and not do a DB query as long as the referenced document is not being used.

Do you think you can find some time to look at the phpcr-odm PR again? Can I help seomehow, for example by testing it?

@joschi127
Copy link
Contributor Author

@ElectricMaxxx hmm... what do you think? Maybe this one should be merged, so at least things are not broken?

@ElectricMaxxx
Copy link
Owner

ElectricMaxxx commented Feb 6, 2016 via email

@ElectricMaxxx
Copy link
Owner

looks fine to me. Thanks.

I think i need to start writing tests for the UoW in here :-(

ElectricMaxxx added a commit that referenced this pull request Feb 6, 2016
Fix loading references if mapped by uuid and not by id.
@ElectricMaxxx ElectricMaxxx merged commit b41ff53 into ElectricMaxxx:master Feb 6, 2016
@joschi127
Copy link
Contributor Author

Thanks :-)

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.

2 participants