Skip to content

Commit af30a6e

Browse files
Merge branch '4.1'
* 4.1: [SecurityBundle] fix test [DI] Fix bad exception on uninitialized references to non-shared services [HttpFoundation] Fix perf issue during MimeTypeGuesser intialization
2 parents 3e7c74f + 27f5f24 commit af30a6e

File tree

3 files changed

+3
-25
lines changed

3 files changed

+3
-25
lines changed

Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

14-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1514
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
1615
use Symfony\Component\DependencyInjection\ContainerInterface;
1716
use Symfony\Component\DependencyInjection\Reference;
@@ -31,9 +30,6 @@ protected function processValue($value, $isRoot = false)
3130
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $value->getInvalidBehavior() && !$this->container->has($id = (string) $value)) {
3231
throw new ServiceNotFoundException($id, $this->currentId);
3332
}
34-
if (ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $value->getInvalidBehavior() && $this->container->has($id = (string) $value) && !$this->container->findDefinition($id)->isShared()) {
35-
throw new InvalidArgumentException(sprintf('Invalid ignore-on-uninitialized reference found in service "%s": target service "%s" is not shared.', $this->currentId, $id));
36-
}
3733

3834
return $value;
3935
}

Dumper/PhpDumper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,9 @@ private function getServiceCall(string $id, Reference $reference = null): string
16661666
if ($this->container->hasDefinition($id) && ($definition = $this->container->getDefinition($id)) && !$definition->isSynthetic()) {
16671667
if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
16681668
$code = 'null';
1669+
if (!$definition->isShared()) {
1670+
return $code;
1671+
}
16691672
} elseif ($this->isTrivialInstance($definition)) {
16701673
$code = substr($this->addNewInstance($definition, '', '', $id), 8, -2);
16711674
if ($definition->isShared() && !isset($this->singleUsePrivateIds[$id])) {

Tests/Compiler/CheckExceptionOnInvalidReferenceBehaviorPassTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,6 @@ public function testProcessThrowsExceptionOnInvalidReferenceFromInlinedDefinitio
6868
$this->process($container);
6969
}
7070

71-
/**
72-
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
73-
* @expectedExceptionMessage Invalid ignore-on-uninitialized reference found in service
74-
*/
75-
public function testProcessThrowsExceptionOnNonSharedUninitializedReference()
76-
{
77-
$container = new ContainerBuilder();
78-
79-
$container
80-
->register('a', 'stdClass')
81-
->addArgument(new Reference('b', $container::IGNORE_ON_UNINITIALIZED_REFERENCE))
82-
;
83-
84-
$container
85-
->register('b', 'stdClass')
86-
->setShared(false)
87-
;
88-
89-
$this->process($container);
90-
}
91-
9271
public function testProcessDefinitionWithBindings()
9372
{
9473
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)