Skip to content

Commit c9fbff0

Browse files
committed
minor #16686 [DI] use try-finally for container (Tobion)
This PR was merged into the 3.0-dev branch. Discussion ---------- [DI] use try-finally for container | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Continuation of #15949 Commits ------- 1ab7316 [DI] use try-finally for container
2 parents 8988409 + 1ab7316 commit c9fbff0

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,13 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
272272
try {
273273
$service = $this->$method();
274274
} catch (\Exception $e) {
275-
unset($this->loading[$id]);
276-
277-
if (array_key_exists($id, $this->services)) {
278-
unset($this->services[$id]);
279-
}
275+
unset($this->services[$id]);
280276

281277
throw $e;
278+
} finally {
279+
unset($this->loading[$id]);
282280
}
283281

284-
unset($this->loading[$id]);
285-
286282
return $service;
287283
}
288284
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy