Merge branch '4.4' into 5.1

* 4.4:
  [HttpKernel] Configure the ErrorHandler even when it is overriden
  Allow relative path to composer cache
This commit is contained in:
Nicolas Grekas 2021-01-25 14:53:56 +01:00
commit be896b5004
2 changed files with 24 additions and 0 deletions

View File

@ -158,6 +158,18 @@ $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
: 'composer';
$prevCacheDir = getenv('COMPOSER_CACHE_DIR');
if ($prevCacheDir) {
if (false === $absoluteCacheDir = realpath($prevCacheDir)) {
@mkdir($prevCacheDir, 0777, true);
$absoluteCacheDir = realpath($prevCacheDir);
}
if ($absoluteCacheDir) {
putenv("COMPOSER_CACHE_DIR=$absoluteCacheDir");
} else {
$prevCacheDir = false;
}
}
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : ''));
$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT]));
$PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
@ -240,6 +252,9 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
$exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress $q", [], $p, getcwd()));
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
if ($prevCacheDir) {
putenv("COMPOSER_CACHE_DIR=$prevCacheDir");
}
if ($exit) {
exit($exit);
}

View File

@ -30,6 +30,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
*/
class DebugHandlersListener implements EventSubscriberInterface
{
private $earlyHandler;
private $exceptionHandler;
private $logger;
private $deprecationLogger;
@ -51,6 +52,10 @@ class DebugHandlersListener implements EventSubscriberInterface
*/
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = \E_ALL, ?int $throwAt = \E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, LoggerInterface $deprecationLogger = null)
{
$handler = set_exception_handler('var_dump');
$this->earlyHandler = \is_array($handler) ? $handler[0] : null;
restore_exception_handler();
$this->exceptionHandler = $exceptionHandler;
$this->logger = $logger;
$this->levels = null === $levels ? \E_ALL : $levels;
@ -78,6 +83,10 @@ class DebugHandlersListener implements EventSubscriberInterface
$handler = \is_array($handler) ? $handler[0] : null;
restore_exception_handler();
if (!$handler instanceof ErrorHandler) {
$handler = $this->earlyHandler;
}
if ($handler instanceof ErrorHandler) {
if ($this->logger || $this->deprecationLogger) {
$this->setDefaultLoggers($handler);