update lock clucknut
All checks were successful
All checks were successful
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException as SerializerInvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||
use Symfony\Component\Serializer\Exception\PartialDenormalizationException;
|
||||
use Symfony\Component\Serializer\Exception\UnsupportedFormatException;
|
||||
@@ -104,7 +105,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo
|
||||
try {
|
||||
$payload = $this->$payloadMapper($request, $type, $argument);
|
||||
} catch (PartialDenormalizationException $e) {
|
||||
$trans = $this->translator ? $this->translator->trans(...) : fn ($m, $p) => strtr($m, $p);
|
||||
$trans = $this->translator ? $this->translator->trans(...) : static fn ($m, $p) => strtr($m, $p);
|
||||
foreach ($e->getErrors() as $error) {
|
||||
$parameters = [];
|
||||
$template = 'This value was of an unexpected type.';
|
||||
@@ -119,6 +120,9 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo
|
||||
$violations->add(new ConstraintViolation($message, $template, $parameters, null, $error->getPath(), null));
|
||||
}
|
||||
$payload = $e->getData();
|
||||
} catch (SerializerInvalidArgumentException $e) {
|
||||
$violations->add(new ConstraintViolation($e->getMessage(), $e->getMessage(), [], null, '', null));
|
||||
$payload = null;
|
||||
}
|
||||
|
||||
if (null !== $payload && !\count($violations)) {
|
||||
@@ -133,6 +137,8 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo
|
||||
$payload = $this->$payloadMapper($request, $type, $argument);
|
||||
} catch (PartialDenormalizationException $e) {
|
||||
throw new HttpException($validationFailedCode, implode("\n", array_map(static fn ($e) => $e->getMessage(), $e->getErrors())), $e);
|
||||
} catch (SerializerInvalidArgumentException $e) {
|
||||
throw new HttpException($validationFailedCode, $e->getMessage(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +187,7 @@ private function mapRequestPayload(Request $request, string $type, MapRequestPay
|
||||
}
|
||||
|
||||
if (\is_array($data)) {
|
||||
return $this->serializer->denormalize($data, $type, 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE);
|
||||
return $this->serializer->denormalize($data, $type, self::hasNonStringScalar($data) ? $format : 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE);
|
||||
}
|
||||
|
||||
if ('form' === $format) {
|
||||
@@ -196,4 +202,21 @@ private function mapRequestPayload(Request $request, string $type, MapRequestPay
|
||||
throw new HttpException(Response::HTTP_BAD_REQUEST, \sprintf('Request payload contains invalid "%s" data.', $format), $e);
|
||||
}
|
||||
}
|
||||
|
||||
private static function hasNonStringScalar(array $data): bool
|
||||
{
|
||||
$stack = [$data];
|
||||
|
||||
while ($stack) {
|
||||
foreach (array_pop($stack) as $v) {
|
||||
if (\is_array($v)) {
|
||||
$stack[] = $v;
|
||||
} elseif (!\is_string($v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public function getMessage(): string
|
||||
return $this->data['exception']->getMessage();
|
||||
}
|
||||
|
||||
public function getCode(): int
|
||||
public function getCode(): int|string
|
||||
{
|
||||
return $this->data['exception']->getCode();
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ public function process(ContainerBuilder $container)
|
||||
}
|
||||
|
||||
if ($autowireAttributes) {
|
||||
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
|
||||
$attribute = $autowireAttributes[0]->newInstance();
|
||||
$value = $parameterBag->resolveValue($attribute->value);
|
||||
|
||||
@@ -203,8 +204,10 @@ public function process(ContainerBuilder $container)
|
||||
|
||||
$args[$p->name] = new Reference($erroredId, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE);
|
||||
} else {
|
||||
$target = preg_replace('/(^|[(|&])\\\\/', '\1', $target);
|
||||
$args[$p->name] = $type ? new TypedReference($target, $type, $invalidBehavior, Target::parseName($p)) : new Reference($target, $invalidBehavior);
|
||||
$targetAttribute = null;
|
||||
$name = Target::parseName($p, $targetAttribute);
|
||||
$target = preg_replace('/(^|[(|&])\\\\/', '\\1', $target);
|
||||
$args[$p->name] = $type ? new TypedReference($target, $type, $invalidBehavior, $name, $targetAttribute ? [$targetAttribute] : []) : new Reference($target, $invalidBehavior);
|
||||
}
|
||||
}
|
||||
// register the maps as a per-method service-locators
|
||||
|
||||
@@ -41,12 +41,13 @@ public function __construct(RequestStack $requestStack, string $defaultLocale =
|
||||
$this->requestStack = $requestStack;
|
||||
$this->router = $router;
|
||||
$this->useAcceptLanguageHeader = $useAcceptLanguageHeader;
|
||||
$this->enabledLocales = $enabledLocales;
|
||||
$this->enabledLocales = $enabledLocales ? array_values(array_unique(array_merge([$defaultLocale], $enabledLocales))) : [];
|
||||
}
|
||||
|
||||
public function setDefaultLocale(KernelEvent $event): void
|
||||
{
|
||||
$event->getRequest()->setDefaultLocale($this->defaultLocale);
|
||||
$this->setRouterLocale($this->defaultLocale);
|
||||
}
|
||||
|
||||
public function onKernelRequest(RequestEvent $event): void
|
||||
@@ -54,14 +55,12 @@ public function onKernelRequest(RequestEvent $event): void
|
||||
$request = $event->getRequest();
|
||||
|
||||
$this->setLocale($request);
|
||||
$this->setRouterContext($request);
|
||||
$this->setRouterLocale($request->getLocale());
|
||||
}
|
||||
|
||||
public function onKernelFinishRequest(FinishRequestEvent $event): void
|
||||
{
|
||||
if (null !== $parentRequest = $this->requestStack->getParentRequest()) {
|
||||
$this->setRouterContext($parentRequest);
|
||||
}
|
||||
$this->setRouterLocale($this->requestStack->getParentRequest()?->getLocale() ?? $this->defaultLocale);
|
||||
}
|
||||
|
||||
private function setLocale(Request $request): void
|
||||
@@ -76,9 +75,9 @@ private function setLocale(Request $request): void
|
||||
}
|
||||
}
|
||||
|
||||
private function setRouterContext(Request $request): void
|
||||
private function setRouterLocale(string $locale): void
|
||||
{
|
||||
$this->router?->getContext()->setParameter('_locale', $request->getLocale());
|
||||
$this->router?->getContext()->setParameter('_locale', $locale);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
|
||||
37
vendor/symfony/http-kernel/Kernel.php
vendored
37
vendor/symfony/http-kernel/Kernel.php
vendored
@@ -70,17 +70,18 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
private ?string $warmupDir = null;
|
||||
private int $requestStackSize = 0;
|
||||
private bool $resetServices = false;
|
||||
private bool $handlingHttpCache = false;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private static array $freshCache = [];
|
||||
|
||||
public const VERSION = '6.4.31';
|
||||
public const VERSION_ID = 60431;
|
||||
public const VERSION = '6.4.36';
|
||||
public const VERSION_ID = 60436;
|
||||
public const MAJOR_VERSION = 6;
|
||||
public const MINOR_VERSION = 4;
|
||||
public const RELEASE_VERSION = 31;
|
||||
public const RELEASE_VERSION = 36;
|
||||
public const EXTRA_VERSION = '';
|
||||
|
||||
public const END_OF_MAINTENANCE = '11/2026';
|
||||
@@ -101,6 +102,7 @@ public function __clone()
|
||||
$this->container = null;
|
||||
$this->requestStackSize = 0;
|
||||
$this->resetServices = false;
|
||||
$this->handlingHttpCache = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +110,7 @@ public function __clone()
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (true === $this->booted) {
|
||||
if ($this->booted) {
|
||||
if (!$this->requestStackSize && $this->resetServices) {
|
||||
if ($this->container->has('services_resetter')) {
|
||||
$this->container->get('services_resetter')->reset();
|
||||
@@ -122,7 +124,7 @@ public function boot()
|
||||
return;
|
||||
}
|
||||
|
||||
if (null === $this->container) {
|
||||
if (!$this->container) {
|
||||
$this->preBoot();
|
||||
}
|
||||
|
||||
@@ -149,7 +151,7 @@ public function reboot(?string $warmupDir)
|
||||
*/
|
||||
public function terminate(Request $request, Response $response)
|
||||
{
|
||||
if (false === $this->booted) {
|
||||
if (!$this->booted) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,7 +165,7 @@ public function terminate(Request $request, Response $response)
|
||||
*/
|
||||
public function shutdown()
|
||||
{
|
||||
if (false === $this->booted) {
|
||||
if (!$this->booted) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,17 +183,26 @@ public function shutdown()
|
||||
|
||||
public function handle(Request $request, int $type = HttpKernelInterface::MAIN_REQUEST, bool $catch = true): Response
|
||||
{
|
||||
if (!$this->booted) {
|
||||
$container = $this->container ?? $this->preBoot();
|
||||
if (!$this->container) {
|
||||
$this->preBoot();
|
||||
}
|
||||
|
||||
if ($container->has('http_cache')) {
|
||||
return $container->get('http_cache')->handle($request, $type, $catch);
|
||||
if (HttpKernelInterface::MAIN_REQUEST === $type && !$this->handlingHttpCache && $this->container->has('http_cache')) {
|
||||
$this->handlingHttpCache = true;
|
||||
|
||||
try {
|
||||
return $this->container->get('http_cache')->handle($request, $type, $catch);
|
||||
} finally {
|
||||
$this->handlingHttpCache = false;
|
||||
$this->resetServices = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->boot();
|
||||
++$this->requestStackSize;
|
||||
$this->resetServices = true;
|
||||
if (!$this->handlingHttpCache) {
|
||||
$this->resetServices = true;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->getHttpKernel()->handle($request, $type, $catch);
|
||||
@@ -603,7 +614,7 @@ protected function buildContainer(): ContainerBuilder
|
||||
{
|
||||
foreach (['cache' => $this->getCacheDir(), 'build' => $this->warmupDir ?: $this->getBuildDir(), 'logs' => $this->getLogDir()] as $name => $dir) {
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
|
||||
if (!@mkdir($dir, 0o777, true) && !is_dir($dir)) {
|
||||
throw new \RuntimeException(\sprintf('Unable to create the "%s" directory (%s).', $name, $dir));
|
||||
}
|
||||
} elseif (!is_writable($dir)) {
|
||||
|
||||
2
vendor/symfony/http-kernel/composer.json
vendored
2
vendor/symfony/http-kernel/composer.json
vendored
@@ -30,7 +30,7 @@
|
||||
"symfony/config": "^6.1|^7.0",
|
||||
"symfony/console": "^5.4|^6.0|^7.0",
|
||||
"symfony/css-selector": "^5.4|^6.0|^7.0",
|
||||
"symfony/dependency-injection": "^6.4|^7.0",
|
||||
"symfony/dependency-injection": "^6.4.1|^7.0.1",
|
||||
"symfony/dom-crawler": "^5.4|^6.0|^7.0",
|
||||
"symfony/expression-language": "^5.4|^6.0|^7.0",
|
||||
"symfony/finder": "^5.4|^6.0|^7.0",
|
||||
|
||||
Reference in New Issue
Block a user