Skip to content

Commit 5d4f4ff

Browse files
Merge branch '3.1'
* 3.1: [Routing] Add missing options in docblock [VarDumper] Fix dumping continuations [PropertyInfo] Fix an error in PropertyInfoCacheExtractor [HttpFoundation] fixed Request::getContent() reusage bug [Form] Skip CSRF validation on form when POST max size is exceeded Use try-finally where it possible [DependencyInjection] ContainerBuilder: Remove obsolete definitions Enhance the phpDoc return types so IDEs can handle the configuration tree. fixes Remove 3.0 from branch suggestions for fixes in PR template [Process] Strengthen Windows pipe files opening (again...) [Cache] Handle unserialize() failures gracefully Fix #19531 [Form] DateType fails parsing when midnight is not a valid time
2 parents d53a91b + a6eca66 commit 5d4f4ff

File tree

2 files changed

+11
-35
lines changed

2 files changed

+11
-35
lines changed

Compiler/AutowirePass.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,15 @@ public function process(ContainerBuilder $container)
4545
$this->completeDefinition($id, $definition);
4646
}
4747
}
48-
} catch (\Exception $e) {
49-
} catch (\Throwable $e) {
50-
}
51-
52-
spl_autoload_unregister($throwingAutoloader);
53-
54-
// Free memory and remove circular reference to container
55-
$this->container = null;
56-
$this->reflectionClasses = array();
57-
$this->definedTypes = array();
58-
$this->types = null;
59-
$this->ambiguousServiceTypes = array();
60-
61-
if (isset($e)) {
62-
throw $e;
48+
} finally {
49+
spl_autoload_unregister($throwingAutoloader);
50+
51+
// Free memory and remove circular reference to container
52+
$this->container = null;
53+
$this->reflectionClasses = array();
54+
$this->definedTypes = array();
55+
$this->types = null;
56+
$this->ambiguousServiceTypes = array();
6357
}
6458
}
6559

ContainerBuilder.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
5050
*/
5151
private $definitions = array();
5252

53-
/**
54-
* @var Definition[]
55-
*/
56-
private $obsoleteDefinitions = array();
57-
5853
/**
5954
* @var Alias[]
6055
*/
@@ -356,21 +351,8 @@ public function set($id, $service)
356351
{
357352
$id = strtolower($id);
358353

359-
if ($this->isFrozen()) {
360-
// setting a synthetic service on a frozen container is alright
361-
if (
362-
(!isset($this->definitions[$id]) && !isset($this->obsoleteDefinitions[$id]))
363-
||
364-
(isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())
365-
||
366-
(isset($this->obsoleteDefinitions[$id]) && !$this->obsoleteDefinitions[$id]->isSynthetic())
367-
) {
368-
throw new BadMethodCallException(sprintf('Setting service "%s" on a frozen container is not allowed.', $id));
369-
}
370-
}
371-
372-
if (isset($this->definitions[$id])) {
373-
$this->obsoleteDefinitions[$id] = $this->definitions[$id];
354+
if ($this->isFrozen() && (!isset($this->definitions[$id]) || !$this->definitions[$id]->isSynthetic())) {
355+
throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a frozen container is not allowed.', $id));
374356
}
375357

376358
unset($this->definitions[$id], $this->aliasDefinitions[$id]);

0 commit comments

Comments
 (0)