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

[Form] Fix DocumentType #193

Closed
wants to merge 1 commit into from
Closed

[Form] Fix DocumentType #193

wants to merge 1 commit into from

Conversation

dbu
Copy link
Member

@dbu dbu commented Mar 28, 2015

while working on symfony-cmf/blog-bundle#59 and hunting down the last test failure, i found that the phpcr_document form type did not work but throw exceptions.

i also noticed that there is no test for this form type, neither functional nor unit.

$loader = function (Options $options) use ($type) {
$qb = $options['query_builder'] ?: $options['em']->createQueryBuilder()->fromDocument($options['class'], 'a');

return $type->getLoader($options['em'], $qb, $options['class']);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is essentially what every version of symfony since 2.3 is doing, so should not be needed to overwrite this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, i solved that mistery. @guilhermeblanco fixed this 10 day ago! symfony/symfony@529d99c - that commit is not yet in a 2.3 release.

should we still do this to work with older versions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it will get into 2.3? if we do not duplicate the method which versions of Symfony2 will not be supported? if we do keep this method, we should add a note about when we can remove the method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is now in 2.3.27 - but either we would need to up our minimal requirement to that symfony version (and also somehow avoid 2.6 < 2.6.6) or we could see if we can do a version check at this point and explode if the version is not new enough. or only overwrite if we are on a too old version of symfony. not sure what is best and the most elegant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho increasing the min version or setting conflicts are the way to go. less code to maintain for us.

@dbu dbu force-pushed the fix-phpcr_document-formtype branch 2 times, most recently from 08bcad6 to 1035776 Compare April 6, 2015 11:53
@@ -40,7 +40,8 @@
"burgov/key-value-form-bundle": "to edit assoc multivalue properties. require version 1.0.*"
},
"conflict": {
"phpcr/phpcr-shell": "<1.0.0-beta1"
"phpcr/phpcr-shell": "<1.0.0-beta1",
"symfony/framework-bundle": ">=2.6.0,<2.6.6"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the correct way to specify we conflict with 2.6 versions < 2.6.6 but 2.3.27 is ok?

what about 2.4 and 2.5? should we start to conflict with those?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did 2.4 and 2.5 get the fix? I assume not?

in this case maybe just do the following in the require: ~2.3.27,~2.6

@dbu
Copy link
Member Author

dbu commented Apr 6, 2015

updated. what should we do about the query builder? just hope it does not matter for now and go with the direct find?

@dbu dbu force-pushed the fix-phpcr_document-formtype branch 2 times, most recently from 28a69b1 to ab5032f Compare April 7, 2015 07:29
@dbu dbu changed the title [WIP] fix the phpcr_document form type Require symfony versions that fixed the bug in the form type DoctrineType Apr 7, 2015
@dbu dbu force-pushed the fix-phpcr_document-formtype branch from ab5032f to 5373efc Compare April 7, 2015 08:33
@@ -18,7 +18,7 @@
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3",
"symfony/framework-bundle": "~2.3",
"symfony/framework-bundle": "~2.3.27 || ~2.6.6 || ~2.7",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we drop compatibility with 2.4 and 2.5 as they are not fixed.
i also updated the .travis.yml to not attempt to build those versions.

btw, , means AND, || means OR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok cool

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why do we need 2.3.27+ / 2.6.6+ ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah .. because of the fixes to the DoctrineType I guess

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsmith77
Copy link
Member

lsmith77 commented Apr 9, 2015

the build failure looks strange .. otherwise +1 to merge

@dbu dbu force-pushed the fix-phpcr_document-formtype branch from 5373efc to 073c728 Compare April 9, 2015 16:55
@dbu
Copy link
Member Author

dbu commented Apr 9, 2015

i now allow 2.7 to fail - has nothing to do with this pull request - i just started adding 2.7.

i now added a functional test - however, that test does not fail even with older versions of symfony. it seems, so i am not sure i got things right.

@dbu dbu force-pushed the fix-phpcr_document-formtype branch from 073c728 to 0dc969b Compare April 10, 2015 17:01
@dbu
Copy link
Member Author

dbu commented Apr 10, 2015

hm, and even when 2.6.6 is used, the blog thing still fails: https://travis-ci.org/symfony-cmf/BlogBundle/jobs/56075966

will need to investigate some more to figure out what we do differently there than in the test here.

@lsmith77
Copy link
Member

lsmith77 commented May 1, 2015

so merge this?

@dbu
Copy link
Member Author

dbu commented May 1, 2015

i never managed to make my tests fail. however, the BlogBundle still always fails, even with a recent enough version. there must be something i miss.

lets wait with merging until i figured out what is happening, maybe we do not need the restrictions on symfony versions as they are proposed here.

@psyray
Copy link

psyray commented May 17, 2015

@duanesteel find a solution for our Sylius ContentBundle problem and it seems this involve the getEntitiesByIds method in the PhpcrOdmQueryBuilderLoader class (Form/ChoiceList/PhpcrOdmQueryBuilderLoader.php)
Look at his post

Is this a proper fix or a workaround ?

@dbu dbu force-pushed the fix-phpcr_document-formtype branch from 0dc969b to 5373efc Compare May 18, 2015 06:23
@dbu
Copy link
Member Author

dbu commented May 20, 2015

ok, i dug through this and its not exactly nice.

symfony older than 2.6.6 did not build a loader when no query_builder option was supplied but ended up calling $entities = $this->em->getRepository($this->class)->findAll(); in the EntityChoiceList. so things worked fine when all options where are loaded. since 2.6.6, a default query builder is created and the loader instantiated, triggering the issue all the time.

the other issue is EntityChoiceList::getChoicesForValues that tried to do a query $this->em->getRepository($this->class)->findBy(array($this->idField => $values)); when there is no loader and it has not already loaded objects. but this does not work with phpcr-odm. this is also fixed in 2.6.6

i looked into workarounds for the older symfony versions, but the way the choiceList is built in DoctrineType is extremely inconvenient to customize.

so i think we need to bump the minimal version to 2.6.6

@dbu dbu force-pushed the fix-phpcr_document-formtype branch from 5373efc to a3ca595 Compare May 20, 2015 08:01
@dbu
Copy link
Member Author

dbu commented May 20, 2015

ok, i think i got it right now. including actually respecting the query builder if there is one provided.

@psyray may i ask you to check one more time if this works as expected now?

@psyray
Copy link

psyray commented May 20, 2015

The fix-phpcr_document-formtype branch ?

@dbu
Copy link
Member Author

dbu commented May 20, 2015

@psyray yep, this branch. i changed what is in this fix to respect the query builder if its supplied.

@dbu dbu changed the title Require symfony versions that fixed the bug in the form type DoctrineType [Form] Fix DocumentType May 20, 2015
@psyray
Copy link

psyray commented May 20, 2015

Seems to work in Sylius with Symfony 2.3.27

@lsmith77
Copy link
Member

we still have build failures. 5.3 needs more memory and there is some regression with 2.7

@dbu dbu force-pushed the fix-phpcr_document-formtype branch 2 times, most recently from 2786126 to 832dc84 Compare May 20, 2015 15:26
@dbu
Copy link
Member Author

dbu commented May 20, 2015

yeah 2.7 seems to render a less nice html for forms. i made the test assumptions more flexible.

for the lowest deps, i try to remove the memory limit. problem is that composer on 5.3 consumes a lot more memory than on other platforms so when there are many options of versions to compare it explodes. if it does not work, we could try 5.3 instead of 5.3.3 or stop building on 5.3

@lsmith77 do you think this can be released as bugfix release once merged?

env: SYMFONY_VERSION=2.7.* SYMFONY_DEPRECATIONS_HELPER=weak

before_install:
- composer self-update || true
- echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be conditional, does not work for the hhvm build

@lsmith77 lsmith77 force-pushed the fix-phpcr_document-formtype branch from 832dc84 to 7782dda Compare May 20, 2015 16:32
@lsmith77
Copy link
Member

@psyray can you test #201 ? this is on top of the 1.2 branch so that we could tag it as 1.2.4 as master isn't ready yet to be released.

@psyray
Copy link

psyray commented May 20, 2015

The fix_form_type branch, with the #201 commit inside, is tested in latest Sylius master version on Symfony 2.3.27.
Everything is fine 👍

Tested in my own project too which is in 2.6.6 👍

@lsmith77 lsmith77 closed this May 21, 2015
@lsmith77 lsmith77 removed the review label May 21, 2015
@lsmith77 lsmith77 deleted the fix-phpcr_document-formtype branch May 22, 2015 10:14
@lsmith77
Copy link
Member

@psyray
Copy link

psyray commented May 22, 2015

great, thanks for the job 👍

@jeffsacco
Copy link

I am new to this who thing. I updated my composer.json on doctrine/phpcr-odm to 1.2.4 as shown in the screenshot and then ran composer update and got this error. I am sure I am doing something wrong here. Could someone walk me through the process to get this update? Many thanks in advance.
screen shot 2015-05-23 at 9 06 14 am
screen shot 2015-05-23 at 9 06 00 am

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

Successfully merging this pull request may close these issues.

5 participants