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

FormPass is deprecated in Symfony 3.4 #4700

Closed
javiereguiluz opened this issue Oct 19, 2017 · 21 comments
Closed

FormPass is deprecated in Symfony 3.4 #4700

javiereguiluz opened this issue Oct 19, 2017 · 21 comments

Comments

@javiereguiluz
Copy link
Contributor

Seen while upgrading a Symfony app to 3.4:

The "Sonata\CoreBundle\DependencyInjection\Compiler\FormFactoryCompilerPass" class extends 
"Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass" that is deprecated
since version 3.3, to be removed in 4.0. Use FormPass in the Form component instead.
@nidble
Copy link

nidble commented Oct 21, 2017

Hi all,

seems to be no anyone worked on this, can I take this issue? :-)

@greg0ire
Copy link
Contributor

Absolutely! Go for it!

@greg0ire
Copy link
Contributor

Things to determine :

  1. what does this compiler pass do exactly?
  2. do we really still need it, or could it be deprecated and removed?

@OskarStark
Copy link
Member

any news @nidble ?

@ossinkine
Copy link
Contributor

Is it related to sonata-project/SonataCoreBundle#403?

@nidble
Copy link

nidble commented Oct 28, 2017

Sorry if I am being late! But I had a strong working week. :( I can involve on this issue from monday...

@nidble
Copy link

nidble commented Oct 30, 2017

@greg0ire @OskarStark,

  1. currently the compiler pass of SonataBundle works following this schema (vendor/sonata-project/core-bundle/Resources/config/core.xml):
         <service id="sonata.core.form.extension.dependency" class="Sonata\CoreBundle\Form\Extension\DependencyInjectionExtension">
            <argument type="service" id="service_container"/>
            <argument type="collection"/>
            <argument type="collection"/>
            <argument type="collection"/>
            <argument type="collection"/>
            <argument type="collection"/>
            <argument type="collection"/>
        </service>

while symfony core apply a different injection (vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml):

        <service id="form.extension" class="Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension">
            <argument /><!-- All services with tag "form.type" are stored in a service locator by FormPass -->
            <argument type="collection" /><!-- All services with tag "form.type_extension" are stored here by FormPass -->
            <argument type="iterator" /><!-- All services with tag "form.type_guesser" are stored here by FormPass -->
            <argument>null</argument><!-- @deprecated argument in 3.3, to be removed in 4.0 -->
        </service>
  1. The different signature of class DependencyInjectionExtension, suggests, from my personal point of view, to refactorize and to align it with the new behavior. Fixing this class and extending new FormPass class could be the solution for the deprecation warning.

@greg0ire
Copy link
Contributor

@nidble do you understand what the point of this compiler pass is? Because I don't.
I think its purpose might be to still be able to create forms based on the service id rather than the FQCN, but I could be mistaken. It was introduced in sonata-project/SonataCoreBundle@0bd414f, along with a command I never tried.

@greg0ire
Copy link
Contributor

I tried the command on one of my projects, here is what I get:

Getting form types:
              form: Symfony\Component\Form\Extension\Core\Type\FormType
              birthday: Symfony\Component\Form\Extension\Core\Type\BirthdayType
              checkbox: Symfony\Component\Form\Extension\Core\Type\CheckboxType
              choice: Symfony\Component\Form\Extension\Core\Type\ChoiceType
              collection: Symfony\Component\Form\Extension\Core\Type\CollectionType
              country: Symfony\Component\Form\Extension\Core\Type\CountryType
              date: Symfony\Component\Form\Extension\Core\Type\DateType
              datetime: Symfony\Component\Form\Extension\Core\Type\DateTimeType
              email: Symfony\Component\Form\Extension\Core\Type\EmailType
              file: Symfony\Component\Form\Extension\Core\Type\FileType
              hidden: Symfony\Component\Form\Extension\Core\Type\HiddenType
              integer: Symfony\Component\Form\Extension\Core\Type\IntegerType
              language: Symfony\Component\Form\Extension\Core\Type\LanguageType
              locale: Symfony\Component\Form\Extension\Core\Type\LocaleType
              money: Symfony\Component\Form\Extension\Core\Type\MoneyType
              number: Symfony\Component\Form\Extension\Core\Type\NumberType
              password: Symfony\Component\Form\Extension\Core\Type\PasswordType
              percent: Symfony\Component\Form\Extension\Core\Type\PercentType
              radio: Symfony\Component\Form\Extension\Core\Type\RadioType
              range: Symfony\Component\Form\Extension\Core\Type\RangeType
              repeated: Symfony\Component\Form\Extension\Core\Type\RepeatedType
              search: Symfony\Component\Form\Extension\Core\Type\SearchType
              textarea: Symfony\Component\Form\Extension\Core\Type\TextareaType
              text: Symfony\Component\Form\Extension\Core\Type\TextType
              time: Symfony\Component\Form\Extension\Core\Type\TimeType
              timezone: Symfony\Component\Form\Extension\Core\Type\TimezoneType
              url: Symfony\Component\Form\Extension\Core\Type\UrlType
              button: Symfony\Component\Form\Extension\Core\Type\ButtonType
              submit: Symfony\Component\Form\Extension\Core\Type\SubmitType
              reset: Symfony\Component\Form\Extension\Core\Type\ResetType
              currency: Symfony\Component\Form\Extension\Core\Type\CurrencyType
              entity: Symfony\Bridge\Doctrine\Form\Type\EntityType
              sonata_type_immutable_array: Sonata\CoreBundle\Form\Type\ImmutableArrayType
              sonata_type_boolean: Sonata\CoreBundle\Form\Type\BooleanType
              sonata_type_collection: Sonata\CoreBundle\Form\Type\CollectionType
              sonata_type_translatable_choice: Sonata\CoreBundle\Form\Type\TranslatableChoiceType
              sonata_type_date_range: Sonata\CoreBundle\Form\Type\DateRangeType
              sonata_type_datetime_range: Sonata\CoreBundle\Form\Type\DateTimeRangeType
              sonata_type_date_picker: Sonata\CoreBundle\Form\Type\DatePickerType
              sonata_type_datetime_picker: Sonata\CoreBundle\Form\Type\DateTimePickerType
              sonata_type_date_range_picker: Sonata\CoreBundle\Form\Type\DateRangePickerType
              sonata_type_datetime_range_picker: Sonata\CoreBundle\Form\Type\DateTimeRangePickerType
              sonata_type_equal: Sonata\CoreBundle\Form\Type\EqualType
              sonata_type_color_selector: Sonata\CoreBundle\Form\Type\ColorSelectorType
              sonata_block_service_choice: Sonata\BlockBundle\Form\Type\ServiceListType
              sonata_type_container_template_choice: Sonata\BlockBundle\Form\Type\ContainerTemplateType
              sonata_type_admin: Sonata\AdminBundle\Form\Type\AdminType
              sonata_type_model: Sonata\AdminBundle\Form\Type\ModelType
              sonata_type_model_list: Sonata\AdminBundle\Form\Type\ModelListType
              sonata_type_model_reference: Sonata\AdminBundle\Form\Type\ModelReferenceType
              sonata_type_model_hidden: Sonata\AdminBundle\Form\Type\ModelHiddenType
              sonata_type_model_autocomplete: Sonata\AdminBundle\Form\Type\ModelAutocompleteType
              sonata_type_native_collection: Sonata\AdminBundle\Form\Type\CollectionType
              sonata_type_choice_field_mask: Sonata\AdminBundle\Form\Type\ChoiceFieldMaskType
              sonata_type_filter_number: Sonata\AdminBundle\Form\Type\Filter\NumberType
              sonata_type_filter_choice: Sonata\AdminBundle\Form\Type\Filter\ChoiceType
              sonata_type_filter_default: Sonata\AdminBundle\Form\Type\Filter\DefaultType
              sonata_type_filter_date: Sonata\AdminBundle\Form\Type\Filter\DateType
              sonata_type_filter_date_range: Sonata\AdminBundle\Form\Type\Filter\DateRangeType
              sonata_type_filter_datetime: Sonata\AdminBundle\Form\Type\Filter\DateTimeType
              sonata_type_filter_datetime_range: Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType
              fos_user_username: FOS\UserBundle\Form\Type\UsernameFormType
              fos_user_profile: FOS\UserBundle\Form\Type\ProfileFormType
              fos_user_registration: FOS\UserBundle\Form\Type\RegistrationFormType
              fos_user_change_password: FOS\UserBundle\Form\Type\ChangePasswordFormType
              fos_user_resetting: Cine\UserBundle\Form\Reset

I think all this should be deprecated.

@nidble
Copy link

nidble commented Oct 31, 2017

Just a side note,

@greg0ire: the command which you refer, SonataListFormMappingCommand implements isEnabled that restrict its execution for specific Symfony Kernel versions.

Maybe, If major version of Symony will be excluded, this layer can be removed. Am I right? :-)

@greg0ire
Copy link
Contributor

Yes, but that is a big if. I think your proposal still holds. Can you please make a PR, so that we see a bit more code?

@nidble
Copy link

nidble commented Nov 2, 2017

@greg0ire after further investigate on compile pass process, instead to change service definition I opted to apply small a refactoring to the classes involved in this process. I can make a PR but this will affect on SonataCoreBundle...

@greg0ire
Copy link
Contributor

greg0ire commented Nov 2, 2017

Please make the PR, it will be easier to understand what you are talking about.

@nidble
Copy link

nidble commented Nov 2, 2017

Yep, done! sonata-project/SonataCoreBundle#456

@greg0ire
Copy link
Contributor

greg0ire commented Nov 5, 2017

Anyone experiencing this, please try the following piece of configuration:

sonata_core:
    form:
        mapping:
            enabled: false

And use FQCNs wherever you can

@ossinkine
Copy link
Contributor

@greg0ire This workaround does not work. Problematic compiler pass is created when the bundle builds the container https://github.com/sonata-project/SonataCoreBundle/blob/3.x/src/SonataCoreBundle.php#L30 but not on config processing.

@greg0ire
Copy link
Contributor

Strange. Can you try removing that line, see what happens?

@greg0ire
Copy link
Contributor

@ossinkine I just created a PR to fix this.

@ossinkine
Copy link
Contributor

@greg0ire Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass class existance checking does not fix the issue, because class still exists in Symfony 3.4, but it's just deprecated. So deprecation message still appears.

@ossinkine
Copy link
Contributor

Maybe should be checking for Symfony\Component\Form\DependencyInjection\FormPass class does not exist?

@greg0ire
Copy link
Contributor

greg0ire commented Dec 5, 2017

@ossinkine I added another check very very recently, but it does not work perfectly it seems

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

No branches or pull requests

7 participants