symfony: [DI] ServiceContainer build error after upgrading to 4.1.4
Symfony version(s) affected: 4.1.4
Description
After upgrading to v4.1.4 the following error shown when container tries to build.
RuntimeException Cannot dump definitions which have method calls.
Tace
RuntimeException Cannot dump definitions which have method calls. [Symfony\Component\DependencyInjection\Exception\RuntimeException] Cannot dump definitions which have method calls.Exception trace: Symfony\Component\DependencyInjection\Dumper\PhpDumper->dumpValue() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:614 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceMethodCalls() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:516 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServiceInlinedDefinitions() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:792 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addService() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:827 Symfony\Component\DependencyInjection\Dumper\PhpDumper->addServices() at /var/www/html/vendor/symfony/dependency-injection/Dumper/PhpDumper.php:194 Symfony\Component\DependencyInjection\Dumper\PhpDumper->dump() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:704 Symfony\Component\HttpKernel\Kernel->dumpContainer() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:541 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /var/www/html/vendor/symfony/http-kernel/Kernel.php:123 Symfony\Component\HttpKernel\Kernel->boot() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:65 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:145 Symfony\Component\Console\Application->run() at /var/www/html/bin/console:39
possibly BC break possibly caused by: #28060 (or maybe i missed something and used it wrong)
How to reproduce
I have a monolog handler that requires EntityManagerInterface and a doctrine EventSubscriber that needs the monolog logger with the handler. It works fine when I downgrade to symfony/dependency-injection to v4.1.3
Files that requre to reproduce:
src/Monolog/DoctrineDBHandler.php
namespace App\Monolog;
use Doctrine\ORM\EntityManagerInterface;
use Monolog\Handler\AbstractProcessingHandler;
class DoctrineDBHandler extends AbstractProcessingHandler
{
private $entityManager;
public function __construct(EntityManagerInterface $em)
{
parent::__construct();
$this->entityManager = $em;
}
protected function write(array $record): void
{
// write log to db
}
}
src/EventSubscriber/DoctrineLogSubscriber.php
namespace App\EventSubscriber;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Monolog\Logger;
class DoctrineLogSubscriber implements EventSubscriber
{
private $logger;
public function __construct(Logger $logger)
{
$this->logger = $logger;
}
public function getSubscribedEvents(): array
{
return ['postPersist'];
}
public function postPersist(LifecycleEventArgs $args): void
{
$this->logger->addInfo('create');
}
}
config/services.yaml
parameters:
locale: 'en'
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
App\DoctrineLogSubscriber:
arguments: ['@monolog.logger.demo']
tags:
- { name: doctrine.event_subscriber }
config/packages/dev/monolog.yaml
...
monolog:
channels: ['demo']
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
demo:
channels: ['demo']
level: INFO
type: service
id: App\Monolog\DoctrineDBHandler
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 23 (11 by maintainers)
Commits related to this issue
- fix: Temporarily downgrade DI to 4.1.3 because of symfony/symfony#28296 — committed to unite-cms/unite-cms by franzwilding 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/shopsys by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/shopsys by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/shopsys by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/shopsys by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/framework by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/product-feed-zbozi by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/product-feed-google by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/product-feed-heureka by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/product-feed-heureka-delivery by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/http-smoke-testing by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/form-types-bundle by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/migrations by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/project-base by vitek-rostislav 6 years ago
- bug #28366 [DI] Fix dumping some complex service graphs (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [DI] Fix dumping some complex service graphs | Q ... — committed to symfony/symfony by nicolas-grekas 6 years ago
- fix: Temporarily downgrade DI to 4.1.3 because of symfony/symfony#28296 — committed to unite-cms/standard by franzwilding 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/product-feed-heureka-delivery by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/form-types-bundle by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/migrations by vitek-rostislav 6 years ago
- Symfony >=3.4.15 marked as conflicting in composer.json due to https://github.com/symfony/symfony/issues/28296 that causes application build to fail — committed to shopsys/product-feed-zbozi by vitek-rostislav 6 years ago
We have this problem in 3.4.15, I’ll check if I can work out a small reproduction too.
I can confirm that requiring symfony/proxy-manager-bridge fixes the issue.
Thanks to the reproducer, I managed to reduce the reproducer to a config like:
Indirectly related to proxy-manager indeed. On it now…
It looks like
composer require symfony/proxy-manager-bridge
fixes the issue.Hello. It’s here: https://github.com/mmarton/symfony-di-error-poc
It fixes my original problem. I’m just not sure, that adding a new dependency is the right way to fix a bug introduced in a patch release.
This is solved but not tagged.
Can confirm, that a simple
composer require symfony/dependency-injection:4.1.3
solves the problem for the moment.