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

composer cache:clear fails since upgrading DoctrineBundle 2.5.7->2.6.0 #1485

Closed
owsygavin opened this issue Mar 30, 2022 · 17 comments
Closed

Comments

@owsygavin
Copy link

I ran composer upgrade:

Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading doctrine/doctrine-bundle (2.5.7 => 2.6.0)

I got :

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  Symfony\Component\ErrorHandler\Error\UndefinedMethodError {#65817
!!    #message: "Attempted to call an undefined method named "setMiddlewares" of class "Doctrine\DBAL\Configuration"."
!!    #code: 0
!!    #file: "./var/cache/dev/ContainerMFCvxZk/App_KernelDevDebugContainer.php"
!!    #line: 1267
!!    trace: {
!!      ./var/cache/dev/ContainerMFCvxZk/App_KernelDevDebugContainer.php:1267 {
!!        ContainerMFCvxZk\App_KernelDevDebugContainer->getDoctrine_Dbal_DefaultConnectionService()
!!        › $a->setSchemaAssetsFilter(new \Doctrine\Bundle\DoctrineBundle\Dbal\SchemaAssetsFilterManager([0 => ($this->privates['doctrine.dbal.well_known_schema_asset_filter'] ?? ($this->privates['doctrine.dbal.well_known_schema_asset_filter'] = new \Doctrine\Bundle\DoctrineBundle\Dbal\BlacklistSchemaAssetFilter([0 => 'cache_items', 1 => 'sessions']))), 1 => new \Doctrine\Bundle\DoctrineBundle\Dbal\RegexSchemaAssetFilter('~^(?!(import\\.|reporting\\.|sqitch\\.|accounting\\.|history\\.|topology\\.|tiger\\.|tiger_data\\.))~')]));
!!        › $a->setMiddlewares([]);
!!        ›
!!      }
!!      ./var/cache/dev/ContainerMFCvxZk/App_KernelDevDebugContainer.php:1508 { …}
!!      ./var/cache/dev/ContainerMFCvxZk/App_KernelDevDebugContainer.php:1282 { …}
!!      ./var/cache/dev/ContainerMFCvxZk/EntityManager_9a5be93.php:246 { …}
!!      ./var/cache/dev/ContainerMFCvxZk/EntityManager_9a5be93.php:246 { …}
!!      ./vendor/symfony/doctrine-bridge/CacheWarmer/ProxyCacheWarmer.php:54 { …}
!!      ./vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:98 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:584 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:786 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:125 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
!!      ./vendor/symfony/console/Application.php:167 { …}
!!      ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:56 { …}
!!      ./vendor/autoload_runtime.php:35 { …}
!!      ./bin/console:11 { …}
!!    }
!!  }
!!  2022-03-30T09:31:06+00:00 [critical] Uncaught Error: Call to undefined method Doctrine\DBAL\Configuration::setMiddlewares()
!!
Script @auto-scripts was called via post-update-cmd

Is there something I need to configure here?

Thanks!

@andrew-demb
Copy link

Introduced with #1472

Middleware feature introduced in doctrine/dbal:3.0.0.
Probably bundle should configure middlewares only in case of installed doctrine/dbal 3+.

@owsygavin
Copy link
Author

thank you :)

@dmaicher
Copy link
Contributor

@l-vo do you have time to look into this? otherwise I will try to find some time

@dmaicher
Copy link
Contributor

@owsygavin whats your output of composer show doctrine/*?

@owsygavin
Copy link
Author

@owsygavin whats your output of composer show doctrine/*?

doctrine/annotations                1.13.2 Docblock Annotations Parser
doctrine/cache                      2.1.1  PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/collections                1.6.8  PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                     3.2.2  PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, proxies and much more.
doctrine/data-fixtures              1.5.2  Data Fixtures for all Doctrine Object Managers
doctrine/dbal                       2.13.8 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations               v0.5.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/doctrine-bundle            2.6.0  Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle   3.4.1  Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle 3.2.2  Symfony DoctrineMigrationsBundle
doctrine/event-manager              1.1.1  The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                  2.0.4  PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator               1.4.1  A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                      1.2.3  PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                 3.4.1  PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes ...
doctrine/orm                        2.11.2 Object-Relational-Mapper for PHP
doctrine/persistence                2.4.1  The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/sql-formatter              1.1.2  a PHP SQL highlighting library

@andrew-demb
Copy link

andrew-demb commented Mar 30, 2022

Introduced with #1472

Middleware feature introduced in doctrine/dbal:3.0.0. Probably bundle should configure middlewares only in case of installed doctrine/dbal 3+.

Unfortunately, my suggestion is probably wrong.
Middleware pass should not be registered in case of installed DBAL < 3.0.0 (

if (interface_exists(Middleware::class)) {
$container->addCompilerPass(new MiddlewaresPass());
}
).

@owsygavin are errors occurred after dropping the cache directory?

@blackarcanis
Copy link

@andrew-demb Same error here and yes, the cache directory is empty.

@dmaicher
Copy link
Contributor

maybe someone of you can check how come that the MiddlewaresPass is registered and executed when using dbal 2?

@dmaicher
Copy link
Contributor

I had a look and I cannot reproduce this on one of my apps using dbal 2.13.8. Cache clear works fine and the MiddlewaresPass is not registered.

Can someone provide a minimal reproducer?

@dmaicher
Copy link
Contributor

dmaicher commented Mar 30, 2022

Are you by any chance using Sentry?

It seems there is some weird stuff happening with class aliases:

https://github.com/getsentry/sentry-symfony/blob/master/src/aliases.php#L111

@blackarcanis
Copy link

Are you by any chance using Sentry?

It seems there is some weird stuff happening with class aliases:

https://github.com/getsentry/sentry-symfony/blob/master/src/aliases.php#L111

Yes, I can confirm, we are using Sentry in our project

@owsygavin
Copy link
Author

Are you by any chance using Sentry?
It seems there is some weird stuff happening with class aliases:
https://github.com/getsentry/sentry-symfony/blob/master/src/aliases.php#L111

Yes, I can confirm, we are using Sentry in our project

my project also uses sentry via sentry-symfony

@dmaicher
Copy link
Contributor

Ok so I see 2 options:

  • report this issue on sentry-symfony as they really should not alias/define a Doctrine DBAL interface...
  • we look into changing the "middleware avaiable detection" on our side here so it works with Sentry

I personally would vote for the first option as this alias magic can really cause a lot of confusion and what the f**k moments as we see here.

@owsygavin
Copy link
Author

thanks, I'll report it to them now

@simonberger
Copy link

simonberger commented Mar 30, 2022

Just to note We face this issue as well. Nice investigation here already. We are using Sentry. I'll stick to ~2.5.7 for now.

@l-vo
Copy link
Contributor

l-vo commented Mar 30, 2022

@dmaicher yes, I'll take a look at the problem

@ostrolucky
Copy link
Member

Issue not caused on our side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants