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

Php notice for query builder / dbref query preparation: Undefined index: $db #1635

Closed
Nilz11 opened this issue Aug 28, 2017 · 7 comments
Closed
Milestone

Comments

@Nilz11
Copy link
Contributor

Nilz11 commented Aug 28, 2017

If no target document is set and storeAs is set to "dbRef" the query builder will throw a PHP notice:

Undefined index: $db

when doing an equals with something like this, where $user is a document

->field('user')->equals($user)

Issue is that there is a bug in document persister prepareDbRefElement method:

if ($mapping['storeAs'] === ClassMetadataInfo::REFERENCE_STORE_AS_ID) {

should be

if ($mapping['storeAs'] !== ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF_WITH_DB) {

@malarzm
Copy link
Member

malarzm commented Aug 28, 2017

@Nilz11 thanks for submitting the issue! One question though, what is the value of $mapping['storeAs']? I believe that at this point it can be either ClassMetadataInfo::REFERENCE_STORE_AS_ID or ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF_WITH_DB so both conditions should mean the same.

@Nilz11
Copy link
Contributor Author

Nilz11 commented Aug 28, 2017

What about ClassMetadataInfo::REFERENCE_STORE_AS_DB_REF?

@malarzm
Copy link
Member

malarzm commented Aug 28, 2017

Sorry, not sure what about that?

@Nilz11
Copy link
Contributor Author

Nilz11 commented Aug 29, 2017

storeAs can be one of this three values. ID case works fine, db-ref-with-db works fine but db-ref not.

Why do you say that the store-as value can not be db-ref in this method?

@malarzm malarzm added this to the 1.1.7 milestone Aug 29, 2017
@malarzm
Copy link
Member

malarzm commented Aug 29, 2017

I'm sorry, you are correct, for some reason I thought about generating DBRef object, not preparing it.

@Nilz11
Copy link
Contributor Author

Nilz11 commented Aug 29, 2017

Can add a test when I have time later

alcaeus added a commit that referenced this issue Sep 28, 2017
alcaeus added a commit to alcaeus/mongodb-odm that referenced this issue Oct 1, 2017
* 1.1.x:
  Relax version constraint for doctrine/instantiator
  Fixes dbref doctrine#1635
@alcaeus
Copy link
Member

alcaeus commented Oct 1, 2017

Closing since #1636 was merged.

@alcaeus alcaeus closed this as completed Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants