-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DoctrineBridge][Form] Fix BC break in DoctrineType #14576
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
Conversation
malarzm
commented
May 7, 2015
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #14568 |
License | MIT |
Doc PR | n/a |
I have test this with Doctrine/Mongo and i found next error:
Removing $qbParts and its references it works
|
@arkadis I've added check if query builder is indeed one from ORM |
Now it works perfectly! Thanks! |
The allowed types for query builder should then be set on the subclass (entity) |
@Tobion in fact you're right, I will move code I have removed to Entity type |
@Tobion done, commits are squashed, travis is green |
Would it possible to add a test to prevent any regression? |
@nicolas-grekas what do you think about creating new Type for tests that won't override any options, pass some class as |
@@ -124,7 +122,7 @@ public function configureOptions(OptionsResolver $resolver) | |||
if (null === $options['choices']) { | |||
// We consider two query builders with an equal SQL string and | |||
// equal parameters to be equal | |||
$qbParts = $options['query_builder'] | |||
$qbParts = $options['query_builder'] instanceof \Doctrine\ORM\QueryBuilder | |||
? array( | |||
$options['query_builder']->getQuery()->getSQL(), | |||
$options['query_builder']->getParameters()->toArray(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic to compare the query builder is specific to the ORM, so it must go in the child class, with a way for other Doctrine implementations (in MongoDBBundle for instance) to provide their own hashing for their query builders.
and in case the query builder cannot be compared (MongoDBBundle not implementing the method yet), the cache should be avoided instead of using the wrong cache.
@stof I have changed the caching logic, can you take a look? |
* @internal This method is public to be usable as callback. It should not | ||
* be used in user code. | ||
*/ | ||
public function getQueryBuilderPartsForCachingHash($queryBuilder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected
would work isn't it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It yells that it has to be public
as that's how parent class defines it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing the parent is also possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't it break in PHP 5.3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I basically followed how it has already been done here: https://github.com/symfony/symfony/pull/14576/files#diff-0b86d71e1a20e98ac050dd33c4e79373R103
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try moving both of them to protected. It should work, and anyway tests will tell if I'm wrong on 5.3 or any other version
@nicolas-grekas https://travis-ci.org/symfony/symfony/jobs/62702058#L1706 - I'm going to throw out last commit |
* @return array|false Array with important QueryBuilder parts or false if | ||
* they can't be determined | ||
*/ | ||
protected function getQueryBuilderPartsForCachingHash($queryBuilder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, I missed the closure... public required sorry
Ok, so last Travis fail is unrelated to my changes :) |
Thank you @malarzm. |