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

Appearance settings

Commit 6a4ba0e

Browse filesBrowse files
[DependencyInjection] Revert "bug symfony#48791 Fix deduplicating service instances in circular graphs"
This reverts commit 2a2b72c, reversing changes made to e7ec8a6.
1 parent 8cf82db commit 6a4ba0e
Copy full SHA for 6a4ba0e

File tree

Expand file treeCollapse file tree

3 files changed

+14
-43
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-43
lines changed

‎src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,13 @@ private function collectCircularReferences(string $sourceId, array $edges, array
447447
foreach ($edges as $edge) {
448448
$node = $edge->getDestNode();
449449
$id = $node->getId();
450-
if ($sourceId === $id || !$node->getValue() instanceof Definition || $edge->isWeak()) {
450+
if ($sourceId === $id || !$node->getValue() instanceof Definition || $edge->isLazy() || $edge->isWeak()) {
451451
continue;
452452
}
453453

454454
if (isset($path[$id])) {
455455
$loop = null;
456-
$loopByConstructor = $edge->isReferencedByConstructor() && !$edge->isLazy();
456+
$loopByConstructor = $edge->isReferencedByConstructor();
457457
$pathInLoop = [$id, []];
458458
foreach ($path as $k => $pathByConstructor) {
459459
if (null !== $loop) {
@@ -467,7 +467,7 @@ private function collectCircularReferences(string $sourceId, array $edges, array
467467
}
468468
$this->addCircularReferences($id, $loop, $loopByConstructor);
469469
} elseif (!isset($checkedNodes[$id])) {
470-
$this->collectCircularReferences($id, $node->getOutEdges(), $checkedNodes, $loops, $path, $edge->isReferencedByConstructor() && !$edge->isLazy());
470+
$this->collectCircularReferences($id, $node->getOutEdges(), $checkedNodes, $loops, $path, $edge->isReferencedByConstructor());
471471
} elseif (isset($loops[$id])) {
472472
// we already had detected loops for this edge
473473
// let's check if we have a common ancestor in one of the detected loops
@@ -488,7 +488,7 @@ private function collectCircularReferences(string $sourceId, array $edges, array
488488

489489
// we can now build the loop
490490
$loop = null;
491-
$loopByConstructor = $edge->isReferencedByConstructor() && !$edge->isLazy();
491+
$loopByConstructor = $edge->isReferencedByConstructor();
492492
foreach ($fillPath as $k => $pathByConstructor) {
493493
if (null !== $loop) {
494494
$loop[] = $k;
@@ -990,7 +990,7 @@ private function addInlineReference(string $id, Definition $definition, string $
990990
return '';
991991
}
992992

993-
$hasSelfRef = isset($this->circularReferences[$id][$targetId]) && !isset($this->definitionVariables[$definition]) && !($this->hasProxyDumper && $definition->isLazy());
993+
$hasSelfRef = isset($this->circularReferences[$id][$targetId]) && !isset($this->definitionVariables[$definition]);
994994

995995
if ($hasSelfRef && !$forConstructor && !$forConstructor = !$this->circularReferences[$id][$targetId]) {
996996
$code = $this->addInlineService($id, $definition, $definition);
@@ -1033,7 +1033,7 @@ private function addInlineService(string $id, Definition $definition, Definition
10331033

10341034
if ($isSimpleInstance = $isRootInstance = null === $inlineDef) {
10351035
foreach ($this->serviceCalls as $targetId => [$callCount, $behavior, $byConstructor]) {
1036-
if ($byConstructor && isset($this->circularReferences[$id][$targetId]) && !$this->circularReferences[$id][$targetId] && !($this->hasProxyDumper && $definition->isLazy())) {
1036+
if ($byConstructor && isset($this->circularReferences[$id][$targetId]) && !$this->circularReferences[$id][$targetId]) {
10371037
$code .= $this->addInlineReference($id, $definition, $targetId, $forConstructor);
10381038
}
10391039
}

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php
+1-7Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,7 @@ protected function getBar6Service()
491491
*/
492492
protected function getDoctrine_ListenerService()
493493
{
494-
$a = ($this->services['doctrine.entity_manager'] ?? $this->getDoctrine_EntityManagerService());
495-
496-
if (isset($this->privates['doctrine.listener'])) {
497-
return $this->privates['doctrine.listener'];
498-
}
499-
500-
return $this->privates['doctrine.listener'] = new \stdClass($a);
494+
return $this->privates['doctrine.listener'] = new \stdClass(($this->services['doctrine.entity_manager'] ?? $this->getDoctrine_EntityManagerService()));
501495
}
502496

503497
/**

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php
+7-30Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,11 @@ protected function getDoctrine_EntityListenerResolverService()
285285
*/
286286
protected function getDoctrine_EntityManagerService()
287287
{
288-
$a = ($this->services['doctrine.entity_listener_resolver'] ?? $this->getDoctrine_EntityListenerResolverService());
289-
290-
if (isset($this->services['doctrine.entity_manager'])) {
291-
return $this->services['doctrine.entity_manager'];
292-
}
293-
$b = new \stdClass();
294-
$b->resolver = $a;
295-
$b->flag = 'ok';
288+
$a = new \stdClass();
289+
$a->resolver = ($this->services['doctrine.entity_listener_resolver'] ?? $this->getDoctrine_EntityListenerResolverService());
290+
$a->flag = 'ok';
296291

297-
return $this->services['doctrine.entity_manager'] = \FactoryChecker::create($b);
292+
return $this->services['doctrine.entity_manager'] = \FactoryChecker::create($a);
298293
}
299294

300295
/**
@@ -304,13 +299,7 @@ protected function getDoctrine_EntityManagerService()
304299
*/
305300
protected function getDoctrine_ListenerService()
306301
{
307-
$a = ($this->services['doctrine.entity_manager'] ?? $this->getDoctrine_EntityManagerService());
308-
309-
if (isset($this->services['doctrine.listener'])) {
310-
return $this->services['doctrine.listener'];
311-
}
312-
313-
return $this->services['doctrine.listener'] = new \stdClass($a);
302+
return $this->services['doctrine.listener'] = new \stdClass(($this->services['doctrine.entity_manager'] ?? $this->getDoctrine_EntityManagerService()));
314303
}
315304

316305
/**
@@ -506,13 +495,7 @@ protected function getLoggerService()
506495
*/
507496
protected function getMailer_TransportService()
508497
{
509-
$a = ($this->services['mailer.transport_factory'] ?? $this->getMailer_TransportFactoryService());
510-
511-
if (isset($this->services['mailer.transport'])) {
512-
return $this->services['mailer.transport'];
513-
}
514-
515-
return $this->services['mailer.transport'] = $a->create();
498+
return $this->services['mailer.transport'] = ($this->services['mailer.transport_factory'] ?? $this->getMailer_TransportFactoryService())->create();
516499
}
517500

518501
/**
@@ -535,13 +518,7 @@ protected function getMailer_TransportFactoryService()
535518
*/
536519
protected function getMailer_TransportFactory_AmazonService()
537520
{
538-
$a = ($this->services['monolog.logger_2'] ?? $this->getMonolog_Logger2Service());
539-
540-
if (isset($this->services['mailer.transport_factory.amazon'])) {
541-
return $this->services['mailer.transport_factory.amazon'];
542-
}
543-
544-
return $this->services['mailer.transport_factory.amazon'] = new \stdClass($a);
521+
return $this->services['mailer.transport_factory.amazon'] = new \stdClass(($this->services['monolog.logger_2'] ?? $this->getMonolog_Logger2Service()));
545522
}
546523

547524
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.