Skip to content

[FrameworkBundle] decorate the ValidatorBuilder's translator with LegacyTranslatorProxy #31108

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

Merged
merged 1 commit into from
Apr 17, 2019

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #31092, #31025
License MIT
Doc PR -

This allows defining a translator that implements only the new interface and use it with ValidatorBuilder.

ping @dvdknaap, @snebes since you were affected.

@nicolas-grekas nicolas-grekas force-pushed the fwb-validator-translator branch from 01b2963 to a12656e Compare April 14, 2019 18:04
Copy link

@snebes snebes left a comment

Choose a reason for hiding this comment

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

This change corrects the error I was getting. Thank you!

@fabpot fabpot merged commit a12656e into symfony:4.2 Apr 17, 2019
fabpot pushed a commit that referenced this pull request Apr 17, 2019
…or with LegacyTranslatorProxy (nicolas-grekas)

This PR was merged into the 4.2 branch.

Discussion
----------

[FrameworkBundle] decorate the ValidatorBuilder's translator with LegacyTranslatorProxy

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31092, #31025
| License       | MIT
| Doc PR        | -

This allows defining a translator that implements only the new interface and use it with ValidatorBuilder.

ping @dvdknaap, @snebes since you were affected.

Commits
-------

a12656e [FrameworkBundle] decorate the ValidatorBuilder's translator with LegacyTranslatorProxy
@fabpot fabpot mentioned this pull request Apr 17, 2019
@Gemorroj
Copy link
Contributor

    "require": {
        "php": "^7.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-apcu": "*",
        "ext-pdo_pgsql": "*",
        "ext-curl": "*",
        "ext-json": "*",
        "ext-soap": "*",
        "ext-intl": "*",
        "symfony/console": "4.2.*",
        "symfony/dotenv": "4.2.*",
        "symfony/flex": "^1.1",
        "symfony/framework-bundle": "4.2.*",
        "symfony/yaml": "4.2.*",
        "symfony/orm-pack": "*",
        "symfony/validator": "4.2.*",
        "symfony/security-bundle": "4.2.*",
        "symfony/intl": "4.2.*",
        "symfony/form": "4.2.*",
        "symfony/serializer": "4.2.*",
        "symfony/monolog-bundle": "^3.3",
        "misd/phone-number-bundle": "^2.0@dev",
        "nelmio/api-doc-bundle": "^3.4",
        "nelmio/cors-bundle": "^1.5",
        "lexik/jwt-authentication-bundle": "^2.6",
        "martin-georgiev/postgresql-for-doctrine": "^1.1",
        "fresh/doctrine-enum-bundle": "^6.2",
        "barbieswimcrew/zip-code-validator": "^1.3",

        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/twig-bundle": "4.2.*",

        "shapecode/cron-bundle": "^3.2.3",
        "pagerfanta/pagerfanta": "^2.0",
        "wsdltophp/packagegenerator": "^3.2",
        "wsdltophp/wssecurity": "^1.2"
    },
    "require-dev": {
        "symfony/maker-bundle": "^1.7",
        "symfony/debug-bundle": "4.2.*",
        "easycorp/easy-log-handler": "^1.0.5",
        "phpstan/phpstan-symfony": "^0.10",
        "phpstan/phpstan-phpunit": "^0.10",
        "friendsofphp/php-cs-fixer": "^2.13"
    },

after update

 [KO]
Script cache:clear returned with error code 255
!!  
!!  Fatal error: Interface 'Symfony\Component\Translation\TranslatorInterface' not found in S:\OSPanel\domains\saas-shipping-backend.loc\vendor\symfony\validator\Util\LegacyTranslatorProxy.php on line 21
!!  
!!  In LegacyTranslatorProxy.php line 21:
!!                                                                                                       
!!    Attempted to load interface "TranslatorInterface" from namespace "Symfony\Component\Translation".  
!!    Did you forget a "use" statement for "Symfony\Contracts\Translation\TranslatorInterface"?          
!!                                                                                                       
!!  
!!  
Script @auto-scripts was called via post-update-cmd

@Gemorroj
Copy link
Contributor

Gemorroj commented Apr 17, 2019

temporary add to requirements "symfony/translation": "4.2.*", to fix this

@leonexcc
Copy link

This breaks Contao (https://github.com/contao/contao) 4.7.4 in combination with symfony/validator (v4.2.7):

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Symfony\Component\Validator\Util\LegacyTranslatorProxy::__construct() must implement interface Symfony\Contracts\Translation\TranslatorInterface, instance of Contao\CoreBundle\Translation\Translator given,....

The Contao translator still implements the legacy interface and is blindly wrapped into the proxy. With symfony/framework-bundle v4.2.6 everything workes fine.

@nicolas-grekas
Copy link
Member Author

See #31152

@sdaoudi
Copy link

sdaoudi commented Apr 17, 2019

Thanks @nicolas-grekas

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.

10 participants