Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecation warnings after upgrading Symfony 4.3.9 to 4.4.1/5.0

I had a deprecation-free Symfony 3.4.9 installation. So I upgraded the FW to 4.1.1. Now I got 9 deprecation warnings all coming from vendor libraries:

  • Creating Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated and will be removed in Doctrine ORM 3.0.
  • The "Symfony\Component\HttpKernel\EventListener\ExceptionListener" class is deprecated since Symfony 4.4, use "ErrorListener" instead.
  • The Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\Mapping\AbstractClassMetadataFactory instead.
  • The Doctrine\Common\Persistence\Mapping\RuntimeReflectionService class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\Mapping\RuntimeReflectionService instead.
  • The Doctrine\Common\Persistence\ObjectManager class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\ObjectManager instead.
  • The Doctrine\Common\Persistence\ObjectRepository class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\ObjectRepository instead.
  • The Doctrine\Common\PropertyChangedListener class is deprecated since doctrine/persistence 1.3 and will be removed in 2.0. Use \Doctrine\Persistence\PropertyChangedListener instead.
  • The "twig.exception_controller" configuration key has been deprecated in Symfony 4.4, set it to "null" and use "framework.error_controller" configuration key instead. (x2)

Is this "normal" or there is any problems in my composer.json file ? I double checked and can't see any dependency that has any "fixed" setting.

I even deleted the full vendor folder and downloaded again as I thought there could be any "garbage" left, with same result.

My composer.json file:

{
    "type" : "project",
    "license" : "proprietary",
    "require" : {
        "php" : "^7.1.3",
        "ext-ctype" : "*",
        "ext-iconv" : "*",
        "sensio/framework-extra-bundle" : "^5.2",
        "symfony/apache-pack" : "^1.0",
        "symfony/asset" : "4.4.*",
        "symfony/console" : "4.4.*",
        "symfony/dotenv" : "4.4.*",
        "symfony/expression-language" : "4.4.*",
        "symfony/flex" : "^1.1",
        "symfony/form" : "4.4.*",
        "symfony/framework-bundle" : "4.4.*",
        "symfony/monolog-bundle" : "^3.1",
        "symfony/orm-pack" : "*",
        "symfony/process" : "4.4.*",
        "symfony/security-bundle" : "4.4.*",
        "symfony/serializer-pack" : "*",
        "symfony/swiftmailer-bundle" : "^3.1",
        "symfony/translation" : "4.4.*",
        "symfony/twig-bundle" : "4.4.*",
        "symfony/validator" : "4.4.*",
        "symfony/web-link" : "4.4.*",
        "symfony/webpack-encore-bundle" : "^1.1",
        "symfony/yaml" : "4.4.*"
    },
    "require-dev" : {
        "symfony/debug-pack" : "*",
        "symfony/maker-bundle" : "^1.0",
        "symfony/profiler-pack" : "^1.0",
        "symfony/test-pack" : "*",
        "symfony/web-server-bundle" : "4.4.*"
    },
    "config" : {
        "preferred-install" : {
            "*" : "dist"
        },
        "sort-packages" : true,
        "secure-http" : false
    },
    "autoload" : {
        "psr-4" : {
            "App\\" : "src/"
        }
    },
    "autoload-dev" : {
        "psr-4" : {
            "App\\Tests\\" : "tests/"
        },
        "classmap" : [
            "vendor/phpasn1"
        ]
    },
    "replace" : {
        "paragonie/random_compat" : "2.*",
        "symfony/polyfill-ctype" : "*",
        "symfony/polyfill-iconv" : "*",
        "symfony/polyfill-php71" : "*",
        "symfony/polyfill-php70" : "*",
        "symfony/polyfill-php56" : "*"
    },
    "conflict" : {
        "symfony/symfony" : "*"
    },
    "extra" : {
        "symfony" : {
            "allow-contrib" : false,
            "require" : "4.4.*"
        }
    }
}

EDIT

I checked installed packages with composer show and see that at least 2 of the installed packages are relevant with the deprecation list above:

(...)
doctrine/orm                        v2.7.0  Object-Relational-Mapper for PHP
doctrine/persistence                1.3.3   The Doctrine Persistence project is a set of shared...
(...)

So I checked the available versions of these packages with composer info doctrine/persistence --all and I saw that it has installed the latest non-dev version:

name     : doctrine/persistence
descrip. : The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
keywords : mapper, object, odm, orm, persistence
versions : dev-master, 2.0.x-dev, 1.3.x-dev, * 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.x-dev, 1.2.0, 1.1.x-dev, 1.1.1, v1.1.0, 1.0.x-dev, v1.0.1, v1.0.0, dev-1.3.x-merge-up-into-master_5df35c38f354a9.94042071, dev-1.3.x-merge-up-into-master_5df33dc289ea03.65167777, dev-1.3.x-merge-up-into-master_5df29d964b0aa5.96685696, dev-github-funding, dev-master-old
(...)

Same for doctrine-orm.

The GitHub site for doctrine/persistence also seems to corroborate this: https://github.com/doctrine/persistence/releases

So this leads me to think that this is really normal behavior and that in future, when these packages get updated, the deprecation messages will disappear.

Note on solution

As anyone who have read the accepted answer will notice, there are still 5 deprecation that cannot be solved just yet. I'll include an answer ASA there are a fix for this. If anyone notices this before me, please fell free to add an answer to this question. Thanks.

like image 421
Nelson Teixeira Avatar asked Dec 13 '19 17:12

Nelson Teixeira


2 Answers

Ok, I've been able to fix the following. Feel free to edit this if anyone knows how to fix any of the other ones.

1.) From Cerad in the Comments: Deprecation: Doctrine\ORM\Mapping\UnderscoreNamingStrategy without making it number aware is deprecated

9.) Twig twig.exception_controller configuration option: https://github.com/symfony/symfony/blob/4.4/UPGRADE-4.4.md#twigbundle

2.) The ExceptionListener cleared in when I fixed the above two items, bringing me down to only 5 deprecations


Finally the 5 remaining, seem to be known and will be fixed per this: Deprecated classes warnings in Symfony 5.0.1 console on Windows

like image 82
MEmerson Avatar answered Oct 15 '22 23:10

MEmerson


If you want to get rid of the Doctrine\Common\Persistence\* depreciations until everything is fixed, you can add a "conflict": { "doctrine/persistence": "1.3.*" } to your composer.json and stay with version 1.2.* of doctrine/persistence.

like image 4
Damien Debin Avatar answered Oct 15 '22 23:10

Damien Debin