mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°6002 - Explicitly add symfony/http-foundation and symfony/http-kernel to composer.json for easier lib update
This commit is contained in:
@@ -69,8 +69,9 @@ final class NotTaggedControllerValueResolver implements ArgumentValueResolverInt
|
||||
}
|
||||
|
||||
if (!$this->container->has($controller)) {
|
||||
$i = strrpos($controller, ':');
|
||||
$controller = substr($controller, 0, $i).strtolower(substr($controller, $i));
|
||||
$controller = (false !== $i = strrpos($controller, ':'))
|
||||
? substr($controller, 0, $i).strtolower(substr($controller, $i))
|
||||
: $controller.'::__invoke';
|
||||
}
|
||||
|
||||
$what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller);
|
||||
|
||||
@@ -33,7 +33,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
|
||||
$class = $reflection->class;
|
||||
} else {
|
||||
$reflection = new \ReflectionFunction($controller);
|
||||
if ($class = str_contains($reflection->name, '{closure}') ? null : $reflection->getClosureScopeClass()) {
|
||||
if ($class = str_contains($reflection->name, '{closure}') ? null : (\PHP_VERSION_ID >= 80111 ? $reflection->getClosureCalledClass() : $reflection->getClosureScopeClass())) {
|
||||
$class = $class->name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
$allChannels = [];
|
||||
foreach ($this->getProcessedLogs() as $log) {
|
||||
if ('' === trim($log['channel'])) {
|
||||
if ('' === trim($log['channel'] ?? '')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
'session_metadata' => $sessionMetadata,
|
||||
'session_attributes' => $sessionAttributes,
|
||||
'session_usages' => array_values($this->sessionUsages),
|
||||
'stateless_check' => $this->requestStack && $this->requestStack->getMainRequest()->attributes->get('_stateless', false),
|
||||
'stateless_check' => $this->requestStack && ($mainRequest = $this->requestStack->getMainRequest()) && $mainRequest->attributes->get('_stateless', false),
|
||||
'flashes' => $flashes,
|
||||
'path_info' => $request->getPathInfo(),
|
||||
'controller' => 'n/a',
|
||||
@@ -479,7 +479,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
}
|
||||
$controller['method'] = $r->name;
|
||||
|
||||
if ($class = $r->getClosureScopeClass()) {
|
||||
if ($class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
|
||||
$controller['class'] = $class->name;
|
||||
} else {
|
||||
return $r->name;
|
||||
|
||||
@@ -24,6 +24,7 @@ use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\TypedReference;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
@@ -174,7 +175,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
$invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE;
|
||||
}
|
||||
|
||||
if (Request::class === $type || SessionInterface::class === $type) {
|
||||
if (Request::class === $type || SessionInterface::class === $type || Response::class === $type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,6 +158,11 @@ abstract class AbstractSessionListener implements EventSubscriberInterface, Rese
|
||||
|
||||
$isSessionEmpty = $session->isEmpty() && empty($_SESSION); // checking $_SESSION to keep compatibility with native sessions
|
||||
if ($requestSessionCookieId && $isSessionEmpty) {
|
||||
// PHP internally sets the session cookie value to "deleted" when setcookie() is called with empty string $value argument
|
||||
// which happens in \Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler::destroy
|
||||
// when the session gets invalidated (for example on logout) so we must handle this case here too
|
||||
// otherwise we would send two Set-Cookie headers back with the response
|
||||
SessionUtils::popSessionCookie($sessionName, 'deleted');
|
||||
$response->headers->clearCookie(
|
||||
$sessionName,
|
||||
$sessionCookiePath,
|
||||
@@ -195,10 +200,11 @@ abstract class AbstractSessionListener implements EventSubscriberInterface, Rese
|
||||
}
|
||||
|
||||
if ($autoCacheControl) {
|
||||
$maxAge = $response->headers->hasCacheControlDirective('public') ? 0 : (int) $response->getMaxAge();
|
||||
$response
|
||||
->setExpires(new \DateTime())
|
||||
->setExpires(new \DateTimeImmutable('+'.$maxAge.' seconds'))
|
||||
->setPrivate()
|
||||
->setMaxAge(0)
|
||||
->setMaxAge($maxAge)
|
||||
->headers->addCacheControlDirective('must-revalidate');
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,14 @@ class ErrorListener implements EventSubscriberInterface
|
||||
protected $controller;
|
||||
protected $logger;
|
||||
protected $debug;
|
||||
/**
|
||||
* @var array<class-string, array{log_level: string|null, status_code: int<100,599>|null}>
|
||||
*/
|
||||
protected $exceptionsMapping;
|
||||
|
||||
/**
|
||||
* @param array<class-string, array{log_level: string|null, status_code: int<100,599>|null}> $exceptionsMapping
|
||||
*/
|
||||
public function __construct($controller, LoggerInterface $logger = null, bool $debug = false, array $exceptionsMapping = [])
|
||||
{
|
||||
$this->controller = $controller;
|
||||
|
||||
@@ -29,17 +29,28 @@ class Store implements StoreInterface
|
||||
private $keyCache;
|
||||
/** @var array<string, resource> */
|
||||
private $locks = [];
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* The available options are:
|
||||
*
|
||||
* * private_headers Set of response headers that should not be stored
|
||||
* when a response is cached. (default: Set-Cookie)
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct(string $root)
|
||||
public function __construct(string $root, array $options = [])
|
||||
{
|
||||
$this->root = $root;
|
||||
if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
|
||||
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
|
||||
}
|
||||
$this->keyCache = new \SplObjectStorage();
|
||||
$this->options = array_merge([
|
||||
'private_headers' => ['Set-Cookie'],
|
||||
], $options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,6 +227,10 @@ class Store implements StoreInterface
|
||||
$headers = $this->persistResponse($response);
|
||||
unset($headers['age']);
|
||||
|
||||
foreach ($this->options['private_headers'] as $h) {
|
||||
unset($headers[strtolower($h)]);
|
||||
}
|
||||
|
||||
array_unshift($entries, [$storedEnv, $headers]);
|
||||
|
||||
if (!$this->save($key, serialize($entries))) {
|
||||
|
||||
@@ -70,6 +70,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
{
|
||||
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
|
||||
|
||||
$this->requestStack->push($request);
|
||||
try {
|
||||
return $this->handleRaw($request, $type);
|
||||
} catch (\Exception $e) {
|
||||
@@ -83,6 +84,8 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
}
|
||||
|
||||
return $this->handleThrowable($e, $request, $type);
|
||||
} finally {
|
||||
$this->requestStack->pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +106,17 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$response = $this->handleThrowable($exception, $request, self::MAIN_REQUEST);
|
||||
if ($pop = $request !== $this->requestStack->getMainRequest()) {
|
||||
$this->requestStack->push($request);
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->handleThrowable($exception, $request, self::MAIN_REQUEST);
|
||||
} finally {
|
||||
if ($pop) {
|
||||
$this->requestStack->pop();
|
||||
}
|
||||
}
|
||||
|
||||
$response->sendHeaders();
|
||||
$response->sendContent();
|
||||
@@ -121,8 +134,6 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
*/
|
||||
private function handleRaw(Request $request, int $type = self::MAIN_REQUEST): Response
|
||||
{
|
||||
$this->requestStack->push($request);
|
||||
|
||||
// request
|
||||
$event = new RequestEvent($this, $request, $type);
|
||||
$this->dispatcher->dispatch($event, KernelEvents::REQUEST);
|
||||
@@ -199,7 +210,6 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
private function finishRequest(Request $request, int $type)
|
||||
{
|
||||
$this->dispatcher->dispatch(new FinishRequestEvent($this, $request, $type), KernelEvents::FINISH_REQUEST);
|
||||
$this->requestStack->pop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,11 +78,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
*/
|
||||
private static $freshCache = [];
|
||||
|
||||
public const VERSION = '5.4.11';
|
||||
public const VERSION_ID = 50411;
|
||||
public const VERSION = '5.4.20';
|
||||
public const VERSION_ID = 50420;
|
||||
public const MAJOR_VERSION = 5;
|
||||
public const MINOR_VERSION = 4;
|
||||
public const RELEASE_VERSION = 11;
|
||||
public const RELEASE_VERSION = 20;
|
||||
public const EXTRA_VERSION = '';
|
||||
|
||||
public const END_OF_MAINTENANCE = '11/2024';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
Copyright (c) 2004-2023 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -49,10 +49,14 @@ class Logger extends AbstractLogger
|
||||
|
||||
if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) {
|
||||
switch ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) {
|
||||
case -1: $minLevel = LogLevel::ERROR; break;
|
||||
case 1: $minLevel = LogLevel::NOTICE; break;
|
||||
case 2: $minLevel = LogLevel::INFO; break;
|
||||
case 3: $minLevel = LogLevel::DEBUG; break;
|
||||
case -1: $minLevel = LogLevel::ERROR;
|
||||
break;
|
||||
case 1: $minLevel = LogLevel::NOTICE;
|
||||
break;
|
||||
case 2: $minLevel = LogLevel::INFO;
|
||||
break;
|
||||
case 3: $minLevel = LogLevel::DEBUG;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +89,7 @@ class Logger extends AbstractLogger
|
||||
|
||||
$formatter = $this->formatter;
|
||||
if ($this->handle) {
|
||||
@fwrite($this->handle, $formatter($level, $message, $context));
|
||||
@fwrite($this->handle, $formatter($level, $message, $context).\PHP_EOL);
|
||||
} else {
|
||||
error_log($formatter($level, $message, $context, false));
|
||||
}
|
||||
@@ -110,7 +114,7 @@ class Logger extends AbstractLogger
|
||||
$message = strtr($message, $replacements);
|
||||
}
|
||||
|
||||
$log = sprintf('[%s] %s', $level, $message).\PHP_EOL;
|
||||
$log = sprintf('[%s] %s', $level, $message);
|
||||
if ($prefixDate) {
|
||||
$log = date(\DateTime::RFC3339).' '.$log;
|
||||
}
|
||||
|
||||
@@ -115,19 +115,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
*/
|
||||
public function read(string $token): ?Profile
|
||||
{
|
||||
if (!$token || !file_exists($file = $this->getFilename($token))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (\function_exists('gzcompress')) {
|
||||
$file = 'compress.zlib://'.$file;
|
||||
}
|
||||
|
||||
if (!$data = unserialize(file_get_contents($file))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->createProfileFromData($token, $data);
|
||||
return $this->doRead($token);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,14 +157,13 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
'status_code' => $profile->getStatusCode(),
|
||||
];
|
||||
|
||||
$context = stream_context_create();
|
||||
$data = serialize($data);
|
||||
|
||||
if (\function_exists('gzcompress')) {
|
||||
$file = 'compress.zlib://'.$file;
|
||||
stream_context_set_option($context, 'zlib', 'level', 3);
|
||||
if (\function_exists('gzencode')) {
|
||||
$data = gzencode($data, 3);
|
||||
}
|
||||
|
||||
if (false === file_put_contents($file, serialize($data), 0, $context)) {
|
||||
if (false === file_put_contents($file, $data, \LOCK_EX)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -291,21 +278,34 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
}
|
||||
|
||||
foreach ($data['children'] as $token) {
|
||||
if (!$token || !file_exists($file = $this->getFilename($token))) {
|
||||
continue;
|
||||
if (null !== $childProfile = $this->doRead($token, $profile)) {
|
||||
$profile->addChild($childProfile);
|
||||
}
|
||||
|
||||
if (\function_exists('gzcompress')) {
|
||||
$file = 'compress.zlib://'.$file;
|
||||
}
|
||||
|
||||
if (!$childData = unserialize(file_get_contents($file))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$profile->addChild($this->createProfileFromData($token, $childData, $profile));
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
private function doRead($token, Profile $profile = null): ?Profile
|
||||
{
|
||||
if (!$token || !file_exists($file = $this->getFilename($token))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$h = fopen($file, 'r');
|
||||
flock($h, \LOCK_SH);
|
||||
$data = stream_get_contents($h);
|
||||
flock($h, \LOCK_UN);
|
||||
fclose($h);
|
||||
|
||||
if (\function_exists('gzdecode')) {
|
||||
$data = @gzdecode($data) ?: $data;
|
||||
}
|
||||
|
||||
if (!$data = unserialize($data)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->createProfileFromData($token, $data, $profile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user