-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Doctrine-bridge with PHP 7.2.20 implements non-existant interface FormTypeGuesserInterface #32396
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
Comments
Maybe the same as #32395? |
It occurs after the same change in PHP 7.2.20, but the cause is different here (different package). |
Looks like the same issue to me (if you meant 7.2.20 instead of 7.2.0 in the issue description.) |
Correct. And it's 7.2.20 indeed... typo ;-) |
Let's close this issue then. |
The src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php implements the FormTypeGuesserInterface and that interface is only defined in the symfony/form component. By implementing that interface that code depends on it not only for test but also in production use. We discovered it because we have an api which doesn't require symfony form who blew up with the update to php 7.2.20. The release of php 7.2.20 fixed a bug that was allowing the implementation of interface that are not available.
We reopened that issue because it's not exactly about the same problem although it's related. I have also opened a PR that fix the dependency requirement. |
It is the same problem. 😃 |
@derrabus not really because the problem described there and the proof of concept show a change of behavior when you use the functionality of the bundle with your own code and that your own code reference an unknown interface. This issue is fixed by fixing the composer.json the other one is fixed by either changing the code to produce the same behavior as before or changing the doc if it's not possible. |
It's not a mistake. It's an optional dependency. |
@teohhanhui optional dependency doesn't mean anything. The code use it thus it's not optional. The proof is that now php blow up because it's not optional. You can't validate that the code is correct if you implement an interface that you don't have. |
Except If you look at the discussion in the PHP bug:
Which means But looks like they fixed it in a bad way. |
@teohhanhui if the class if available in the package, someone use it. If you want to keep the package without the dependency of the form component you can delete that class or remove the implements and both are major BC breaks. |
Yes, it's a minimal reproducer to isolate the problem. If you have a look at @wimg's stack trace, you will find that the method call that I isolated in my reproducer ( |
@derrabus The root cause of the problem is that there is code is your package that depends on an interface that is not available. There is no way this can ever make sense. Either way you move that part of the code in another package that depends on that interface or that interface is a dependency of this package and no amount of catching exception can change that. |
@mikeSimonson You keep saying the same things, yet ignoring all attempts by @teohhanhui and myself to explain the situation to you. I doubt that this is discussion getting us anywhere, I'm sorry. |
Closing as duplicate of #32395 |
FYI: This error appears too when autowiring tries to wire an Implementation of an interface that has no implementations. |
api-platform users (im on mac using brew 7.3.7) - I had to add this to my composer.json file and all works after an update
|
@OGProgrammer very bad way to fix this issue should be another. |
Same problem. I use php-fpm:7.2.20-alpine |
@doozookn rollback and wait for php fix or newer version. #32395 (comment) |
what @mikeSimonson said is right, this is not a PHP problem. this is a problem of class implementation. "Except DoctrineOrmTypeGuesser is not actually used. Triggering autoload is not the same as actually using the class." @nicolas-grekas , please re-open this case, this is a Symfony's problem, not PHP. |
To me this is a duplicate of #32395 and everything is explained there (while in the middle of "me too" comments...) Please upgrade to PHP 7.2.21 and report back if you still experience the issue. This is the criteria to decide if I'm wrong or not. |
Symfony version(s) affected: 4.2.8
Description
doctrine-bridge uses symfony-form in require-dev.
However, during cache:clear in non-dev mode it does load Form/DoctrineOrmTypeGuesser.php which implements FormTypeGuesserInterface.
The interface FormTypeGuesserInterface can not be found if symfony/form is not installed.
PHP <7.2.0 allowed for such scenario (see https://bugs.php.net/bug.php?id=76980). Starting at PHP 7.2.0 a fatal error is thrown.
How to reproduce
Possible Solution
Move symfony/form from require-dev to require
Additional context
Output :
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!!
!! // Clearing the cache for the prod environment with debug
!! // false
!!
!! PHP Fatal error: During class fetch: Uncaught ReflectionException: Class Symfony\Component\Form\FormTypeGuesserInterface not found in /opt/releases/20190626075527/api/vendor/symfony/doctrine-bridge/Form/DoctrineOrmTypeGuesser.php:25
!! Stack trace:
!! #0 /opt/releases/20190626075527/api/vendor/composer/ClassLoader.php(444): include('/opt/releases/2...')
!! Untitled #1 /opt/releases/20190626075527/api/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/opt/releases/2...')
!! Renaming "Entities" to "Entity" #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Symfony\Bridge\...')
!! Untitled #3 [internal function]: spl_autoload_call('Symfony\Bridge\...')
!! Same change for mapping files #4 /opt/releases/20190626075527/api/vendor/symfony/config/Resource/ClassExistenceResource.php(76): class_exists('Symfony\Bridge\...')
!! Using ORM and MongoDB both in the same bundle. #5 /opt/releases/20190626075527/api/vendor/symfony/dependency-injection/ContainerBuilder.php(353): Symfony\Component\Config\Resource\ClassExistenceResource->isFresh(0)
!! [Form] Outstanding patches for Choice/Collection fields #6 /opt/releases/20190626075527/api/vendor/symfony/dependency-injection/Compiler/AutowirePass.php(338): Sy in /opt/releases/20190626075527/api/vendor/symfony/doctrine-bridge/Form/DoctrineOrmTypeGuesser.php on line 25
!! 14:00:50 CRITICAL [php] Fatal Error: During class fetch: Uncaught ReflectionException: Class Symfony\Component\Form\FormTypeGuesserInterface not found in /opt/releases/20190626075527/api/vendor/symfony/doctrine-bridge/Form/DoctrineOrmTypeGuesser.php:25
!! Stack trace:
!! #0 /opt/releases/20190626075527/api/vendor/composer/ClassLoader.php(444): include('/opt/releases/2...')
!! Untitled #1 /opt/releases/20190626075527/api/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/opt/releases/2...')
!! Renaming "Entities" to "Entity" #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Symfony\Bridge\...')
!! Untitled #3 [internal function]: spl_autoload_call('Symfony\Bridge\...')
!! Same change for mapping files #4 /opt/releases/20190626075527/api/vendor/symfony/config/Resource/ClassExistenceResource.php(76): class_exists('Symfony\Bridge\...')
!! Using ORM and MongoDB both in the same bundle. #5 /opt/releases/20190626075527/api/vendor/symfony/dependency-injection/ContainerBuilder.php(353): Symfony\Component\Config\Resource\ClassExistenceResource->isFresh(0)
!! [Form] Outstanding patches for Choice/Collection fields #6 /opt/releases/20190626075527/api/vendor/symfony/dependency-injection/Compiler/AutowirePass.php(338): Sy ["exception" => Symfony\Component\Debug\Exception\FatalErrorException { â¦}]
!!
!! In DoctrineOrmTypeGuesser.php line 25:
!!
!! Error: During class fetch: Uncaught ReflectionException: Class Symfony\Comp
!! onent\Form\FormTypeGuesserInterface not found in /opt/releases/201906260755
!! 27/api/vendor/symfony/doctrine-bridge/Form/DoctrineOrmTypeGuesser.php:25
!! Stack trace:
!! #0 /opt/releases/20190626075527/api/vendor/composer/ClassLoader.php(444): i
!! nclude('/opt/releases/2...')
!! Untitled #1 /opt/releases/20190626075527/api/vendor/composer/ClassLoader.php(322): C
!! omposer\Autoload\includeFile('/opt/releases/2...')
!! Renaming "Entities" to "Entity" #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Symfony\
!! Bridge\...')
!! Untitled #3 [internal function]: spl_autoload_call('Symfony\Bridge\...')
!! Same change for mapping files #4 /opt/releases/20190626075527/api/vendor/symfony/config/Resource/ClassExi
!! stenceResource.php(76): class_exists('Symfony\Bridge\...')
!! Using ORM and MongoDB both in the same bundle. #5 /opt/releases/20190626075527/api/vendor/symfony/dependency-injection/Con
!! tainerBuilder.php(353): Symfony\Component\Config\Resource\ClassExistenceRes
!! ource->isFresh(0)
!! [Form] Outstanding patches for Choice/Collection fields #6 /opt/releases/20190626075527/api/vendor/symfony/dependency-injection/Com
!! piler/AutowirePass.php(338): Sy
!!
!!
!! cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--test-mode TEST-MODE] [--]
!!
!!
Script @auto-scripts was called via post-install-cmd
The text was updated successfully, but these errors were encountered: