8000 bug #25413 [HttpKernel] detect deprecations thrown by container initi… · symfony/symfony@d200185 · GitHub
[go: up one dir, main page]

Skip to content

Commit d200185

Browse files
committed
bug #25413 [HttpKernel] detect deprecations thrown by container initialization during tests (nicolas-grekas)
This PR was merged into the 3.3 branch. Discussion ---------- [HttpKernel] detect deprecations thrown by container initialization during tests | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24767 | License | MIT | Doc PR | - Commits ------- 81248bc [HttpKernel] detect deprecations thrown by container initialization during tests
2 parents 7035d01 + 81248bc commit d200185

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ protected function initializeContainer()
536536
if (!$cache->isFresh()) {
537537
if ($this->debug) {
538538
$collectedLogs = array();
539-
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
539+
$previousHandler = defined('PHPUNIT_COMPOSER_INSTALL');
540+
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
540541
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
541542
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
542543
}
@@ -572,7 +573,7 @@ protected function initializeContainer()
572573
$container = $this->buildContainer();
573574
$container->compile();
574575
} finally {
575-
if ($this->debug) {
576+
if ($this->debug && true !== $previousHandler) {
576577
restore_error_handler();
577578

578579
file_put_contents($this->getCacheDir().'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));

0 commit comments

Comments
 (0)
0