Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DependencyInjection] Fix ignore invalid_reference behavior param for the some services#57561

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vtsykun wants to merge1 commit intosymfony:5.4
base:5.4
Choose a base branch
Loading
fromvtsykun:fix/di-dumper

Conversation

vtsykun
Copy link
Contributor

QA
Branch?5.4
Bug fix?yes
New feature?-
Deprecations?-
IssuesFix#57560
LicenseMIT

This bug has more than 5 years old, but it make possible to reproduce after introducing a new console command profiler.

PHP DI dumper may ignore invalid reference behavior in the some cases. See example.

$container->services()        ->set('data_collector.config', ConfigDataCollector::class)            ->call('setKernel', [service('kernel')->ignoreOnInvalid()])            ->tag('data_collector', ['template' =>'@WebProfiler/Collector/config.html.twig','id' =>'config','priority' => -255])

As you can seeignoreOnInvalid option is dropped on this line

$container->get('kernel')
protectedstaticfunction get_Container_Private_ProfilerService($container)    {$a =new \Symfony\Bridge\Monolog\Logger('profiler');$a->pushProcessor(($container->privates['oro_logger.processor.log_message'] ??=new \Monolog\Processor\PsrLogMessageProcessor()));$a->pushProcessor(($container->privates['oro_message_queue.log.processor.add_consumer_state'] ??self::getOroMessageQueue_Log_Processor_AddConsumerStateService($container)));$a->pushHandler(($container->privates['monolog.handler.main'] ??self::getMonolog_Handler_MainService($container)));$a->pushHandler(($container->privates['oro_message_queue.log.handler.console'] ??self::getOroMessageQueue_Log_Handler_ConsoleService($container)));        ($container->privates['debug.debug_logger_configurator'] ??self::getDebug_DebugLoggerConfiguratorService($container))->pushDebugLogger($a);$container->services['.container.private.profiler'] =$instance =new \Oro\Bundle\PlatformBundle\Profiler\ConfigurableProfiler(new \Oro\Bundle\PlatformBundle\Profiler\RepeatableFileProfilerStorage(('file:'.$container->targetDir.''.'/profiler')),$a,true);$b = ($container->services['kernel'] ??$container->get('kernel'));$c = ($container->services['.virtual_request_stack'] ??self::get_VirtualRequestStackService($container));$d =new \Symfony\Component\HttpClient\DataCollector\HttpClientDataCollector();$d->registerClient('http_client', ($container->privates['.debug.http_client'] ??self::get_Debug_HttpClientService($container)));$d->registerClient('hwi_oauth.http_client', ($container->privates['.debug.hwi_oauth.http_client'] ??self::get_Debug_HwiOauth_HttpClientService($container)));$e =new \Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector(($container->services['doctrine'] ??self::getDoctrineService($container)),true,NULL);$f = ($container->privates['doctrine.dbal.logger.profiling.default'] ??=new \Doctrine\DBAL\Logging\DebugStack());$g = ($container->privates['doctrine.dbal.logger.profiling.sql_validator'] ??=new \Doctrine\DBAL\Logging\DebugStack());$h = ($container->privates['doctrine.dbal.logger.profiling.system'] ??=new \Doctrine\DBAL\Logging\DebugStack());$e->addLogger('default',$f);$e->addLogger('sql_validator',$g);$e->addLogger('system',$h);$i =new \Oro\Bundle\EntityBundle\DataCollector\DuplicateQueriesDataCollector();$i->addLogger('default',$f);$i->addLogger('sql_validator',$g);$i->addLogger('system',$h);$j =new \Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector();if ($container->has('kernel')) {$j->setKernel($b);        }

@carsonbotcarsonbot added this to the5.4 milestoneJun 27, 2024
@carsonbotcarsonbot changed the title[Di] Fix ignore invalid_reference behavior param for the some services[DependencyInjection] Fix ignore invalid_reference behavior param for the some servicesJun 27, 2024
@@ -1009,7 +1009,7 @@ private function addInlineReference(string $id, Definition $definition, string $
$name = $this->getNextVariableName();
$this->referenceVariables[$targetId] = new Variable($name);

$reference = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE>= $behavior ? new Reference($targetId, $behavior) : null;
$reference = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE!== $behavior ? new Reference($targetId, $behavior) : null;
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhaps, there was just a typo here and the author meant$behavior >= ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE.

The bug was hidden for a long time because it can only be reproduced for "synthetic" services likekernel and in specific cases. But the other services replaced by null on optimization step before

@nicolas-grekas
Copy link
Member

So, this line:
$b = ($container->services['kernel'] ?? $container->get('kernel'));
should be actually
$b = ($container->services['kernel'] ?? $container->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE));

That's what you mean?

I think this comparison in PhpDumper is on purpose but it's quite possible that we forgot about synthetic services.
Can you please add a test case?

@nicolas-grekas
Copy link
Member

@vtsykun did you check my comment? WDYT?

@vtsykun
Copy link
ContributorAuthor

So, this line$b = ($container->services['kernel'] ?? $container->get('kernel')); should be actually$b = ($container->services['kernel'] ?? $container->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE));

Yes, exactly.

Ok I'll create a test case

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

4 participants
@vtsykun@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp