sonata-project / SonataEasyExtendsBundle

[deprecated] Prototype to easily share entities across Bundle and Application
https://sonata-project.org/
MIT License
168 stars 47 forks source link

Critical error with Symfony 4 in prod environment #215

Closed lukepass closed 5 years ago

lukepass commented 5 years ago

Environment

Symfony 4 fresh install with Sonata packages.

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.48.1 3.48.1 The missing Symfony A...
sonata-project/block-bundle              3.15.0 3.15.0 Symfony SonataBlockBu...
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/core-bundle               3.17.0 3.17.0 Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.5.0  3.0.0  Symfony SonataDatagri...
sonata-project/doctrine-extensions       1.3.0  1.3.0  Doctrine2 behavioral ...
sonata-project/doctrine-orm-admin-bundle 3.9.0  3.9.0  Symfony Sonata / Inte...
sonata-project/easy-extends-bundle       2.5.0  2.5.0  Symfony SonataEasyExt...
sonata-project/exporter                  2.0.1  2.0.1  Lightweight Exporter ...
sonata-project/media-bundle              3.19.1 3.19.1 Symfony SonataMediaBu...
sonata-project/user-bundle               4.3.0  4.3.0  Symfony SonataUserBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/apache-pack          v1.0.1  v1.0.1  A pack for Apache support in Sy...
symfony/asset                v4.2.7  v4.2.8  Symfony Asset Component
symfony/browser-kit          v4.2.7  v4.2.8  Symfony BrowserKit Component
symfony/cache                v4.2.7  v4.2.8  Symfony Cache component with PS...
symfony/config               v4.2.7  v4.2.8  Symfony Config Component
symfony/console              v4.2.7  v4.2.8  Symfony Console Component
symfony/contracts            v1.0.2  v1.0.2  A set of abstractions extracted...
symfony/css-selector         v4.2.7  v4.2.8  Symfony CssSelector Component
symfony/debug                v4.2.7  v4.2.8  Symfony Debug Component
symfony/debug-bundle         v4.2.7  v4.2.8  Symfony DebugBundle
symfony/debug-pack           v1.0.7  v1.0.7  A debug pack for Symfony projects
symfony/dependency-injection v4.2.7  v4.2.8  Symfony DependencyInjection Com...
symfony/doctrine-bridge      v4.2.7  v4.2.8  Symfony Doctrine Bridge
symfony/dom-crawler          v4.2.7  v4.2.8  Symfony DomCrawler Component
symfony/dotenv               v4.2.7  v4.2.8  Registers environment variables...
symfony/event-dispatcher     v4.2.7  v4.2.8  Symfony EventDispatcher Component
symfony/expression-language  v4.2.7  v4.2.8  Symfony ExpressionLanguage Comp...
symfony/filesystem           v4.2.7  v4.2.8  Symfony Filesystem Component
symfony/finder               v4.2.7  v4.2.8  Symfony Finder Component
symfony/flex                 v1.2.3  v1.2.3  Composer plugin for Symfony
symfony/form                 v4.2.7  v4.2.8  Symfony Form Component
symfony/framework-bundle     v4.2.7  v4.2.8  Symfony FrameworkBundle
symfony/http-foundation      v4.2.7  v4.2.8  Symfony HttpFoundation Component
symfony/http-kernel          v4.2.7  v4.2.8  Symfony HttpKernel Component
symfony/inflector            v4.2.7  v4.2.8  Symfony Inflector Component
symfony/intl                 v4.2.7  v4.2.8  A PHP replacement layer for the...
symfony/maker-bundle         v1.11.6 v1.11.6 Symfony Maker helps you create ...
symfony/monolog-bridge       v4.2.7  v4.2.8  Symfony Monolog Bridge
symfony/monolog-bundle       v3.3.1  v3.3.1  Symfony MonologBundle
symfony/options-resolver     v4.2.7  v4.2.8  Symfony OptionsResolver Component
symfony/orm-pack             v1.0.6  v1.0.6  A pack for the Doctrine ORM
symfony/panther              v0.3.0  v0.3.0  A browser testing and web scrap...
symfony/phpunit-bridge       v4.2.7  v4.2.8  Symfony PHPUnit Bridge
symfony/polyfill-intl-icu    v1.11.0 v1.11.0 Symfony polyfill for intl's ICU...
symfony/polyfill-intl-idn    v1.11.0 v1.11.0 Symfony polyfill for intl's idn...
symfony/polyfill-mbstring    v1.11.0 v1.11.0 Symfony polyfill for the Mbstri...
symfony/polyfill-php72       v1.11.0 v1.11.0 Symfony polyfill backporting so...
symfony/process              v4.2.7  v4.2.8  Symfony Process Component
symfony/profiler-pack        v1.0.4  v1.0.4  A pack for the Symfony web prof...
symfony/property-access      v4.2.7  v4.2.8  Symfony PropertyAccess Component
symfony/property-info        v4.2.7  v4.2.8  Symfony Property Info Component
symfony/routing              v4.2.7  v4.2.8  Symfony Routing Component
symfony/security-acl         v3.0.2  v3.0.2  Symfony Security Component - AC...
symfony/security-bundle      v4.2.7  v4.2.8  Symfony SecurityBundle
symfony/security-core        v4.2.7  v4.2.8  Symfony Security Component - Co...
symfony/security-csrf        v4.2.7  v4.2.8  Symfony Security Component - CS...
symfony/security-guard       v4.2.7  v4.2.8  Symfony Security Component - Guard
symfony/security-http        v4.2.7  v4.2.8  Symfony Security Component - HT...
symfony/serializer           v4.2.7  v4.2.8  Symfony Serializer Component
symfony/serializer-pack      v1.0.2  v1.0.2  A pack for the Symfony serializer
symfony/stopwatch            v4.2.7  v4.2.8  Symfony Stopwatch Component
symfony/swiftmailer-bundle   v3.2.6  v3.2.6  Symfony SwiftmailerBundle
symfony/templating           v4.2.7  v4.2.8  Symfony Templating Component
symfony/test-pack            v1.0.5  v1.0.5  A pack for functional and end-t...
symfony/translation          v4.2.7  v4.2.8  Symfony Translation Component
symfony/twig-bridge          v4.2.7  v4.2.8  Symfony Twig Bridge
symfony/twig-bundle          v4.2.7  v4.2.8  Symfony TwigBundle
symfony/validator            v4.2.7  v4.2.8  Symfony Validator Component
symfony/var-dumper           v4.2.7  v4.2.8  Symfony mechanism for exploring...
symfony/var-exporter         v4.2.7  v4.2.8  A blend of var_export() + seria...
symfony/web-link             v4.2.7  v4.2.8  Symfony WebLink Component
symfony/web-profiler-bundle  v4.2.7  v4.2.8  Symfony WebProfilerBundle
symfony/web-server-bundle    v4.2.7  v4.2.8  Symfony WebServerBundle
symfony/yaml                 v4.2.7  v4.2.8  Symfony Yaml Component

PHP version

$ php -v
PHP 7.2.17-1+ubuntu16.04.1+deb.sury.org+3 (cli) (built: Apr 10 2019 10:50:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.17-1+ubuntu16.04.1+deb.sury.org+3, Copyright (c) 1999-2018, by Zend Technologies

Subject

Hello, please see my other issue here:

https://github.com/sonata-project/SonataUserBundle/issues/1091

I am experiencing a very strange problem with this error:

[2019-05-02 17:16:10] request.INFO: Matched route "admin_app_user_list". {"route":"admin_app_user_list","route_parameters":{"_route":"admin_app_user_list","_controller":"Sonata\\AdminBundle\\Controller\\CRUDController::listAction","_sonata_admin":"sonata.user.admin.user","_sonata_name":"admin_app_user_list"},"request_uri":"http://mysite.com/admin/app/user/list","method":"GET"} []
[2019-05-02 17:16:10] security.DEBUG: Read existing security token from the session. {"key":"_security_user","token_class":"Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken"} []
[2019-05-02 17:16:10] php.INFO: User Deprecated: The Sonata\Doctrine\Types\JsonType class is deprecated since 1.x in favor of Doctrine\DBAL\Types\JsonType, and will be removed in 2.0. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The Sonata\\Doctrine\\Types\\JsonType class is deprecated since 1.x in favor of Doctrine\\DBAL\\Types\\JsonType, and will be removed in 2.0. at /var/www/html/mysite/releases/2/vendor/sonata-project/doctrine-extensions/src/Types/JsonType.php:22)"} []
[2019-05-02 17:16:10] php.INFO: User Deprecated: Checking for the AdvancedUserInterface in "Symfony\Component\Security\Core\Authentication\Token\AbstractToken::hasUserChanged()" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\Component\Security\Core\User\EquatableInterface to check if the user has been changed, {"exception":"[object] (ErrorException(code: 0): User Deprecated: Checking for the AdvancedUserInterface in \"Symfony\\Component\\Security\\Core\\Authentication\\Token\\AbstractToken::hasUserChanged()\" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\\Component\\Security\\Core\\User\\EquatableInterface to check if the user has been changed, at /var/www/html/mysite/releases/2/vendor/symfony/security-core/Authentication/Token/AbstractToken.php:265)"} []
[2019-05-02 17:16:10] php.INFO: User Deprecated: Checking for the AdvancedUserInterface in "Symfony\Component\Security\Core\Authentication\Token\AbstractToken::hasUserChanged()" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\Component\Security\Core\User\EquatableInterface to check if the user has been changed, {"exception":"[object] (ErrorException(code: 0): User Deprecated: Checking for the AdvancedUserInterface in \"Symfony\\Component\\Security\\Core\\Authentication\\Token\\AbstractToken::hasUserChanged()\" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the Symfony\\Component\\Security\\Core\\User\\EquatableInterface to check if the user has been changed, at /var/www/html/mysite/releases/2/vendor/symfony/security-core/Authentication/Token/AbstractToken.php:265)"} []
[2019-05-02 17:16:10] security.DEBUG: User was reloaded from a user provider. {"provider":"FOS\\UserBundle\\Security\\UserProvider","username":"admin"} []
[2019-05-02 17:16:10] php.INFO: User Deprecated: The "sonata.core.model.adapter.chain" service is deprecated in favor of service "sonata.doctrine.model.adapter.chain" since 3.12.0 and will be removed in 4.0. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"sonata.core.model.adapter.chain\" service is deprecated in favor of service \"sonata.doctrine.model.adapter.chain\" since 3.12.0 and will be removed in 4.0. at /var/www/html/mysite/releases/2/var/cache/prod/ContainerWxyaFXU/getSonata_Core_Model_Adapter_ChainService.php:9)"} []
[2019-05-02 17:16:10] php.INFO: User Deprecated: The Sonata\CoreBundle\Model\Adapter\AdapterChain class is deprecated since version 3.12.0 and will be removed in 4.0. Use Sonata\Doctrine\Adapter\AdapterChain instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The Sonata\\CoreBundle\\Model\\Adapter\\AdapterChain class is deprecated since version 3.12.0 and will be removed in 4.0. Use Sonata\\Doctrine\\Adapter\\AdapterChain instead. at /var/www/html/mysite/releases/2/vendor/sonata-project/core-bundle/src/CoreBundle/Model/Adapter/AdapterChain.php:20)"} []
[2019-05-02 17:16:10] php.INFO: User Deprecated: The "sonata.core.model.adapter.doctrine_orm" service is deprecated in favor of service "sonata.doctrine.adapter.doctrine_orm" since 3.12.0 and will be removed in 4.0. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"sonata.core.model.adapter.doctrine_orm\" service is deprecated in favor of service \"sonata.doctrine.adapter.doctrine_orm\" since 3.12.0 and will be removed in 4.0. at /var/www/html/mysite/releases/2/var/cache/prod/ContainerWxyaFXU/getSonata_Core_Model_Adapter_DoctrineOrmService.php:9)"} []
[2019-05-02 17:16:10] php.INFO: User Deprecated: The Sonata\CoreBundle\Model\Adapter\DoctrineORMAdapter class is deprecated since version 3.12.0 and will be removed in 4.0. Use Sonata\Doctrine\Adapter\ORM\DoctrineORMAdapter instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The Sonata\\CoreBundle\\Model\\Adapter\\DoctrineORMAdapter class is deprecated since version 3.12.0 and will be removed in 4.0. Use Sonata\\Doctrine\\Adapter\\ORM\\DoctrineORMAdapter instead. at /var/www/html/mysite/releases/2/vendor/sonata-project/core-bundle/src/CoreBundle/Model/Adapter/DoctrineORMAdapter.php:20)"} []
[2019-05-02 17:16:10] request.CRITICAL: Uncaught PHP Exception Sonata\DoctrineORMAdminBundle\Model\MissingPropertyMetadataException: "No metadata found for property `App\Entity\User::$groups`. Please make sure your Doctrine mapping is properly configured." at /var/www/html/mysite/releases/2/vendor/sonata-project/doctrine-orm-admin-bundle/src/Guesser/FilterTypeGuesser.php line 68 {"exception":"[object] (Sonata\\DoctrineORMAdminBundle\\Model\\MissingPropertyMetadataException(code: 0): No metadata found for property `App\\Entity\\User::$groups`. Please make sure your Doctrine mapping is properly configured. at /var/www/html/mysite/releases/2/vendor/sonata-project/doctrine-orm-admin-bundle/src/Guesser/FilterTypeGuesser.php:68)"} []
[2019-05-02 17:16:10] security.DEBUG: Stored the security token in the session. {"key":"_security_user"} []

This problem happens only in prod environment when APP_ENV=prod. If I set it to dev all is working fine.

Steps to reproduce

Set EasyExtendsBundle bundle for dev only:

    Sonata\EasyExtendsBundle\SonataEasyExtendsBundle::class => ['dev' => true, 'test' => true],

Expected results

The admin list of users is working fine.

Actual results

The above error is produced.

Solution

Set EasyExtendsBundle bundle for prod:

    Sonata\EasyExtendsBundle\SonataEasyExtendsBundle::class => ['all' => true],

All works fine.

samuelfranzini commented 5 years ago

Hello,

Also the same concern on our side in Symfony 4.3.1.

By switching from dev to all, it works immediately better ..

I allowed myself to update the documentation and make a merge request so that other users do not have this problem .. The documentation is wrong unfortunately :(

Thank you Sincerely.

lukepass commented 5 years ago

Hello,

Also the same concern on our side in Symfony 4.3.1.

By switching from dev to all, it works immediately better ..

I allowed myself to update the documentation and make a merge request so that other users do not have this problem .. The documentation is wrong unfortunately :(

Thank you Sincerely.

Do you know why it works only when using 'all' and not in dev?

samuelfranzini commented 5 years ago

Hello, Also the same concern on our side in Symfony 4.3.1. By switching from dev to all, it works immediately better .. I allowed myself to update the documentation and make a merge request so that other users do not have this problem .. The documentation is wrong unfortunately :( Thank you Sincerely.

Do you know why it works only when using 'all' and not in dev?

It's related to Symfony and how to load packages directly.

In this case, it is only lit when the offer has been made.

By passing to all, all environments will be loaded. It's an error in their documentation at Sonata's.

More information : https://symfony.com/doc/master/bundles.html