From 80eb60974da1e7dde9214e644ca668342364ceff Mon Sep 17 00:00:00 2001 From: Thomas Bibaut Date: Thu, 19 Dec 2024 14:46:32 +0100 Subject: [PATCH 01/44] [DependencyInjection] Fix env default processor with scalar node --- .../Compiler/ValidateEnvPlaceholdersPass.php | 59 +++++++++++++++---- .../ValidateEnvPlaceholdersPassTest.php | 30 ++++++++++ 2 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php index 2d6542660b39c..75bd6097deee6 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php @@ -49,17 +49,8 @@ public function process(ContainerBuilder $container) $defaultBag = new ParameterBag($resolvingBag->all()); $envTypes = $resolvingBag->getProvidedTypes(); foreach ($resolvingBag->getEnvPlaceholders() + $resolvingBag->getUnusedEnvPlaceholders() as $env => $placeholders) { - $values = []; - if (false === $i = strpos($env, ':')) { - $default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::TYPE_FIXTURES['string']; - $defaultType = null !== $default ? get_debug_type($default) : 'string'; - $values[$defaultType] = $default; - } else { - $prefix = substr($env, 0, $i); - foreach ($envTypes[$prefix] ?? ['string'] as $type) { - $values[$type] = self::TYPE_FIXTURES[$type] ?? null; - } - } + $values = $this->getPlaceholderValues($env, $defaultBag, $envTypes); + foreach ($placeholders as $placeholder) { BaseNode::setPlaceholder($placeholder, $values); } @@ -100,4 +91,50 @@ public function getExtensionConfig(): array $this->extensionConfig = []; } } + + /** + * @param array> $envTypes + * + * @return array + */ + private function getPlaceholderValues(string $env, ParameterBag $defaultBag, array $envTypes): array + { + if (false === $i = strpos($env, ':')) { + [$default, $defaultType] = $this->getParameterDefaultAndDefaultType("env($env)", $defaultBag); + + return [$defaultType => $default]; + } + + $prefix = substr($env, 0, $i); + if ('default' === $prefix) { + $parts = explode(':', $env); + array_shift($parts); // Remove 'default' prefix + $parameter = array_shift($parts); // Retrieve and remove parameter + + [$defaultParameter, $defaultParameterType] = $this->getParameterDefaultAndDefaultType($parameter, $defaultBag); + + return [ + $defaultParameterType => $defaultParameter, + ...$this->getPlaceholderValues(implode(':', $parts), $defaultBag, $envTypes), + ]; + } + + $values = []; + foreach ($envTypes[$prefix] ?? ['string'] as $type) { + $values[$type] = self::TYPE_FIXTURES[$type] ?? null; + } + + return $values; + } + + /** + * @return array{0: string, 1: string} + */ + private function getParameterDefaultAndDefaultType(string $name, ParameterBag $defaultBag): array + { + $default = $defaultBag->has($name) ? $defaultBag->get($name) : self::TYPE_FIXTURES['string']; + $defaultType = null !== $default ? get_debug_type($default) : 'string'; + + return [$default, $defaultType]; + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index 8c5c4cc32323e..17ef87c3fffad 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -73,6 +73,36 @@ public function testDefaultEnvWithoutPrefixIsValidatedInConfig() $this->doProcess($container); } + public function testDefaultProcessorWithScalarNode() + { + $container = new ContainerBuilder(); + $container->setParameter('parameter_int', 12134); + $container->setParameter('env(FLOATISH)', 4.2); + $container->registerExtension($ext = new EnvExtension()); + $container->prependExtensionConfig('env_extension', $expected = [ + 'scalar_node' => '%env(default:parameter_int:FLOATISH)%', + ]); + + $this->doProcess($container); + $this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig())); + } + + public function testDefaultProcessorAndAnotherProcessorWithScalarNode() + { + $this->expectException(InvalidTypeException::class); + $this->expectExceptionMessageMatches('/^Invalid type for path "env_extension\.scalar_node"\. Expected one of "bool", "int", "float", "string", but got one of "int", "array"\.$/'); + + $container = new ContainerBuilder(); + $container->setParameter('parameter_int', 12134); + $container->setParameter('env(JSON)', '{ "foo": "bar" }'); + $container->registerExtension($ext = new EnvExtension()); + $container->prependExtensionConfig('env_extension', [ + 'scalar_node' => '%env(default:parameter_int:json:JSON)%', + ]); + + $this->doProcess($container); + } + public function testEnvsAreValidatedInConfigWithInvalidPlaceholder() { $this->expectException(InvalidTypeException::class); From a8516b7184f96ffa497d39eef869f5acda52d979 Mon Sep 17 00:00:00 2001 From: PHAS Developer <110562019+phasdev@users.noreply.github.com> Date: Tue, 28 Jan 2025 19:24:43 +0000 Subject: [PATCH 02/44] [Security] Return null instead of empty username to fix deprecation notice --- .../Security/Http/Authenticator/RemoteUserAuthenticator.php | 2 +- .../Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php b/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php index 958eeaeaec227..39649666ccace 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php +++ b/src/Symfony/Component/Security/Http/Authenticator/RemoteUserAuthenticator.php @@ -45,6 +45,6 @@ protected function extractUsername(Request $request): ?string throw new BadCredentialsException(sprintf('User key was not found: "%s".', $this->userKey)); } - return $request->server->get($this->userKey); + return $request->server->get($this->userKey) ?: null; } } diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php index 5119f8ce09e74..b94f90884e2e0 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php @@ -36,6 +36,7 @@ public function testSupportNoUser() $authenticator = new RemoteUserAuthenticator(new InMemoryUserProvider(), new TokenStorage(), 'main'); $this->assertFalse($authenticator->supports($this->createRequest([]))); + $this->assertFalse($authenticator->supports($this->createRequest(['REMOTE_USER' => '']))); } public function testSupportTokenStorageWithToken() From 0549c6f6541b4797fe040333dc99e75818cdf332 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 29 Jan 2025 08:32:49 +0100 Subject: [PATCH 03/44] Bump Symfony version to 6.4.19 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index e2a01a4ac0835..d4ee156b89380 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.18'; - public const VERSION_ID = 60418; + public const VERSION = '6.4.19-DEV'; + public const VERSION_ID = 60419; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 18; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 19; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027'; From 2d37c7908daaa3d3a3faa7271b818dfd2fe7ddca Mon Sep 17 00:00:00 2001 From: Benjamin Ellis Date: Thu, 30 Jan 2025 09:40:15 +0100 Subject: [PATCH 04/44] [Mime] use isRendered method to avoid rendering an email twice --- src/Symfony/Bridge/Twig/Mime/BodyRenderer.php | 2 +- src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php b/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php index d5b6d14c139a0..b7ae05f4b0e65 100644 --- a/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php +++ b/src/Symfony/Bridge/Twig/Mime/BodyRenderer.php @@ -45,7 +45,7 @@ public function render(Message $message): void return; } - if (null === $message->getTextTemplate() && null === $message->getHtmlTemplate()) { + if ($message->isRendered()) { // email has already been rendered return; } diff --git a/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php b/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php index f5d37e7d45c4e..cce8ee9a68839 100644 --- a/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php @@ -105,10 +105,14 @@ public function testRenderedOnce() ; $email->textTemplate('text'); + $this->assertFalse($email->isRendered()); $renderer->render($email); + $this->assertTrue($email->isRendered()); + $this->assertEquals('Text', $email->getTextBody()); $email->text('reset'); + $this->assertTrue($email->isRendered()); $renderer->render($email); $this->assertEquals('reset', $email->getTextBody()); From dc71298643380c20d3c1446bfc7014409cc0b8b0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 30 Jan 2025 11:03:01 +0100 Subject: [PATCH 05/44] [HttpClient] Fix uploading files > 2GB --- src/Symfony/Component/HttpClient/CurlHttpClient.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index 3e15bef74cc9e..15b8d1499fb00 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -237,7 +237,7 @@ public function request(string $method, string $url, array $options = []): Respo if (!\is_string($body)) { if (\is_resource($body)) { - $curlopts[\CURLOPT_INFILE] = $body; + $curlopts[\CURLOPT_READDATA] = $body; } else { $curlopts[\CURLOPT_READFUNCTION] = static function ($ch, $fd, $length) use ($body) { static $eof = false; @@ -316,6 +316,9 @@ public function request(string $method, string $url, array $options = []): Respo } foreach ($curlopts as $opt => $value) { + if (\CURLOPT_INFILESIZE === $opt && $value >= 1 << 31) { + $opt = 115; // 115 === CURLOPT_INFILESIZE_LARGE, but it's not defined in PHP + } if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt && (!\defined('CURLOPT_HEADEROPT') || \CURLOPT_HEADEROPT !== $opt)) { $constantName = $this->findConstantName($opt); throw new TransportException(sprintf('Curl option "%s" is not supported.', $constantName ?? $opt)); @@ -472,7 +475,7 @@ private function validateExtraCurlOptions(array $options): void \CURLOPT_RESOLVE => 'resolve', \CURLOPT_NOSIGNAL => 'timeout', \CURLOPT_HTTPHEADER => 'headers', - \CURLOPT_INFILE => 'body', + \CURLOPT_READDATA => 'body', \CURLOPT_READFUNCTION => 'body', \CURLOPT_INFILESIZE => 'body', \CURLOPT_POSTFIELDS => 'body', From f8fe846d0904c3af3aaf0758aa60a4f6a44619e0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 2 Feb 2025 20:54:34 +0100 Subject: [PATCH 06/44] relax expected format for PHP 8.5 compatibility --- .../ErrorHandler/Tests/phpt/fatal_with_nested_handlers.phpt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/ErrorHandler/Tests/phpt/fatal_with_nested_handlers.phpt b/src/Symfony/Component/ErrorHandler/Tests/phpt/fatal_with_nested_handlers.phpt index 81becafd8e350..80a7645770a62 100644 --- a/src/Symfony/Component/ErrorHandler/Tests/phpt/fatal_with_nested_handlers.phpt +++ b/src/Symfony/Component/ErrorHandler/Tests/phpt/fatal_with_nested_handlers.phpt @@ -40,7 +40,7 @@ object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) { string(209) "Error: Class Symfony\Component\ErrorHandler\Broken contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Iterator::current, Iterator::next, Iterator::key, ...)" %a ["error":"Symfony\Component\ErrorHandler\Error\FatalError":private]=> - array(4) { + array(%d) { ["type"]=> int(1) ["message"]=> @@ -48,6 +48,6 @@ object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) { ["file"]=> string(%d) "%s" ["line"]=> - int(%d) + int(%d)%A } } From 31ef3e2f4004792e162734a46d9c025c7e6a49ba Mon Sep 17 00:00:00 2001 From: Juliano Petronetto Date: Mon, 3 Feb 2025 15:30:57 +0100 Subject: [PATCH 07/44] [Validator] Review missing translations for Portuguese --- .../Resources/translations/validators.pt.xlf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf index 759eb5369bd8e..68a7f5ff6c7ea 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf @@ -444,31 +444,31 @@ This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words. - Este valor é muito curto. Deve conter pelo menos uma palavra.|Este valor é muito curto. Deve conter pelo menos {{ min }} palavras. + Este valor é muito curto. Deve conter pelo menos uma palavra.|Este valor é muito curto. Deve conter pelo menos {{ min }} palavras. This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less. - Este valor é muito longo. Deve conter apenas uma palavra.|Este valor é muito longo. Deve conter {{ max }} palavras ou menos. + Este valor é muito longo. Deve conter apenas uma palavra.|Este valor é muito longo. Deve conter {{ max }} palavras ou menos. This value does not represent a valid week in the ISO 8601 format. - Este valor não representa uma semana válida no formato ISO 8601. + Este valor não representa uma semana válida no formato ISO 8601. This value is not a valid week. - Este valor não é uma semana válida. + Este valor não é uma semana válida. This value should not be before week "{{ min }}". - Este valor não deve ser anterior à semana "{{ min }}". + Este valor não deve ser anterior à semana "{{ min }}". This value should not be after week "{{ max }}". - Este valor não deve estar após a semana "{{ max }}". + Este valor não deve estar após a semana "{{ max }}". This value is not a valid slug. - Este valor não é um slug válido. + Este valor não é um slug válido. From 19a50f7e5fb4e429a59143f24ecbcbc3186168a5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 3 Feb 2025 10:59:13 +0100 Subject: [PATCH 08/44] [HttpClient] Fix buffering AsyncResponse with no passthru --- .../HttpClient/Response/AsyncResponse.php | 17 +++++------------ .../Tests/AsyncDecoratorTraitTest.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php index 25f6409b6e319..7aa16bcb17c00 100644 --- a/src/Symfony/Component/HttpClient/Response/AsyncResponse.php +++ b/src/Symfony/Component/HttpClient/Response/AsyncResponse.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpClient\Response; use Symfony\Component\HttpClient\Chunk\ErrorChunk; -use Symfony\Component\HttpClient\Chunk\FirstChunk; use Symfony\Component\HttpClient\Chunk\LastChunk; use Symfony\Component\HttpClient\Exception\TransportException; use Symfony\Contracts\HttpClient\ChunkInterface; @@ -245,7 +244,7 @@ public static function stream(iterable $responses, ?float $timeout = null, ?stri $wrappedResponses[] = $r->response; if ($r->stream) { - yield from self::passthruStream($response = $r->response, $r, new FirstChunk(), $asyncMap); + yield from self::passthruStream($response = $r->response, $r, $asyncMap, new LastChunk()); if (!isset($asyncMap[$response])) { array_pop($wrappedResponses); @@ -276,15 +275,9 @@ public static function stream(iterable $responses, ?float $timeout = null, ?stri } if (!$r->passthru) { - if (null !== $chunk->getError() || $chunk->isLast()) { - unset($asyncMap[$response]); - } elseif (null !== $r->content && '' !== ($content = $chunk->getContent()) && \strlen($content) !== fwrite($r->content, $content)) { - $chunk = new ErrorChunk($r->offset, new TransportException(sprintf('Failed writing %d bytes to the response buffer.', \strlen($content)))); - $r->info['error'] = $chunk->getError(); - $r->response->cancel(); - } + $r->stream = (static fn () => yield $chunk)(); + yield from self::passthruStream($response, $r, $asyncMap); - yield $r => $chunk; continue; } @@ -347,13 +340,13 @@ private static function passthru(HttpClientInterface $client, self $r, ChunkInte } $r->stream = $stream; - yield from self::passthruStream($response, $r, null, $asyncMap); + yield from self::passthruStream($response, $r, $asyncMap); } /** * @param \SplObjectStorage|null $asyncMap */ - private static function passthruStream(ResponseInterface $response, self $r, ?ChunkInterface $chunk, ?\SplObjectStorage $asyncMap): \Generator + private static function passthruStream(ResponseInterface $response, self $r, ?\SplObjectStorage $asyncMap, ?ChunkInterface $chunk = null): \Generator { while (true) { try { diff --git a/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php b/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php index 97e4c42a0c79a..8e8b43348b601 100644 --- a/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/AsyncDecoratorTraitTest.php @@ -232,6 +232,20 @@ public function testBufferPurePassthru() $this->assertStringContainsString('SERVER_PROTOCOL', $response->getContent()); $this->assertStringContainsString('HTTP_HOST', $response->getContent()); + + $client = new class(parent::getHttpClient(__FUNCTION__)) implements HttpClientInterface { + use AsyncDecoratorTrait; + + public function request(string $method, string $url, array $options = []): ResponseInterface + { + return new AsyncResponse($this->client, $method, $url, $options); + } + }; + + $response = $client->request('GET', 'http://localhost:8057/'); + + $this->assertStringContainsString('SERVER_PROTOCOL', $response->getContent()); + $this->assertStringContainsString('HTTP_HOST', $response->getContent()); } public function testRetryTimeout() From c237f8e0f34a7bd20fe95267bf7144e7f39e6f12 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 4 Feb 2025 11:18:48 +0100 Subject: [PATCH 09/44] [Process] Fix process status tracking --- src/Symfony/Component/Process/Process.php | 18 +++--------------- .../Component/Process/Tests/ProcessTest.php | 3 +++ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 280a732d5db54..6dfb25e7b9c5d 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -80,7 +80,6 @@ class Process implements \IteratorAggregate private WindowsPipes|UnixPipes $processPipes; private ?int $latestSignal = null; - private ?int $cachedExitCode = null; private static ?bool $sigchild = null; @@ -1289,21 +1288,10 @@ protected function updateStatus(bool $blocking) return; } - $this->processInformation = proc_get_status($this->process); - $running = $this->processInformation['running']; - - // In PHP < 8.3, "proc_get_status" only returns the correct exit status on the first call. - // Subsequent calls return -1 as the process is discarded. This workaround caches the first - // retrieved exit status for consistent results in later calls, mimicking PHP 8.3 behavior. - if (\PHP_VERSION_ID < 80300) { - if (!isset($this->cachedExitCode) && !$running && -1 !== $this->processInformation['exitcode']) { - $this->cachedExitCode = $this->processInformation['exitcode']; - } - - if (isset($this->cachedExitCode) && !$running && -1 === $this->processInformation['exitcode']) { - $this->processInformation['exitcode'] = $this->cachedExitCode; - } + if ($this->processInformation['running'] ?? true) { + $this->processInformation = proc_get_status($this->process); } + $running = $this->processInformation['running']; $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running); diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index eb0b2bcc3c3ea..0f302c2aabd3c 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -711,6 +711,9 @@ public function testProcessIsSignaledIfStopped() if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX signals'); } + if (\PHP_VERSION_ID < 80300 && isset($_SERVER['GITHUB_ACTIONS'])) { + $this->markTestSkipped('Transient on GHA with PHP < 8.3'); + } $process = $this->getProcessForCode('sleep(32);'); $process->start(); From 018a384828be7e84ec1826889108d9ff88eaf056 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 4 Feb 2025 17:23:00 +0100 Subject: [PATCH 10/44] pass CURLOPT_INFILESIZE_LARGE only when supported --- src/Symfony/Component/HttpClient/CurlHttpClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index 15b8d1499fb00..31eca9d836f21 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -316,8 +316,8 @@ public function request(string $method, string $url, array $options = []): Respo } foreach ($curlopts as $opt => $value) { - if (\CURLOPT_INFILESIZE === $opt && $value >= 1 << 31) { - $opt = 115; // 115 === CURLOPT_INFILESIZE_LARGE, but it's not defined in PHP + if (\PHP_INT_SIZE === 8 && \defined('CURLOPT_INFILESIZE_LARGE') && \CURLOPT_INFILESIZE === $opt && $value >= 1 << 31) { + $opt = \CURLOPT_INFILESIZE_LARGE; } if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt && (!\defined('CURLOPT_HEADEROPT') || \CURLOPT_HEADEROPT !== $opt)) { $constantName = $this->findConstantName($opt); From ee3451b3c7a523d8d088164277e395778bd5e653 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 7 Feb 2025 15:14:19 +0100 Subject: [PATCH 11/44] [HttpClient] Fix activity tracking leading to negative timeout errors --- .../HttpClient/Response/AmpResponse.php | 20 +++++------ .../HttpClient/Response/CurlResponse.php | 4 +-- .../HttpClient/Response/MockResponse.php | 2 +- .../HttpClient/Response/NativeResponse.php | 2 +- .../Response/TransportResponseTrait.php | 36 ++++++++++--------- 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/Symfony/Component/HttpClient/Response/AmpResponse.php b/src/Symfony/Component/HttpClient/Response/AmpResponse.php index e01d97eb868e4..00001ccecba06 100644 --- a/src/Symfony/Component/HttpClient/Response/AmpResponse.php +++ b/src/Symfony/Component/HttpClient/Response/AmpResponse.php @@ -179,19 +179,17 @@ private static function schedule(self $response, array &$runningResponses): void /** * @param AmpClientState $multi */ - private static function perform(ClientState $multi, ?array &$responses = null): void + private static function perform(ClientState $multi, ?array $responses = null): void { - if ($responses) { - foreach ($responses as $response) { - try { - if ($response->info['start_time']) { - $response->info['total_time'] = microtime(true) - $response->info['start_time']; - ($response->onProgress)(); - } - } catch (\Throwable $e) { - $multi->handlesActivity[$response->id][] = null; - $multi->handlesActivity[$response->id][] = $e; + foreach ($responses ?? [] as $response) { + try { + if ($response->info['start_time']) { + $response->info['total_time'] = microtime(true) - $response->info['start_time']; + ($response->onProgress)(); } + } catch (\Throwable $e) { + $multi->handlesActivity[$response->id][] = null; + $multi->handlesActivity[$response->id][] = $e; } } } diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 88cb764384dad..e5dfd3e52d3c1 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -265,11 +265,11 @@ private static function schedule(self $response, array &$runningResponses): void /** * @param CurlClientState $multi */ - private static function perform(ClientState $multi, ?array &$responses = null): void + private static function perform(ClientState $multi, ?array $responses = null): void { if ($multi->performing) { if ($responses) { - $response = current($responses); + $response = $responses[array_key_first($responses)]; $multi->handlesActivity[(int) $response->handle][] = null; $multi->handlesActivity[(int) $response->handle][] = new TransportException(sprintf('Userland callback cannot use the client nor the response while processing "%s".', curl_getinfo($response->handle, \CURLINFO_EFFECTIVE_URL))); } diff --git a/src/Symfony/Component/HttpClient/Response/MockResponse.php b/src/Symfony/Component/HttpClient/Response/MockResponse.php index 0493bcb7c6fc2..c6b96c0b18416 100644 --- a/src/Symfony/Component/HttpClient/Response/MockResponse.php +++ b/src/Symfony/Component/HttpClient/Response/MockResponse.php @@ -167,7 +167,7 @@ protected static function schedule(self $response, array &$runningResponses): vo $runningResponses[0][1][$response->id] = $response; } - protected static function perform(ClientState $multi, array &$responses): void + protected static function perform(ClientState $multi, array $responses): void { foreach ($responses as $response) { $id = $response->id; diff --git a/src/Symfony/Component/HttpClient/Response/NativeResponse.php b/src/Symfony/Component/HttpClient/Response/NativeResponse.php index 9a5184ed6f6d4..54312884cd957 100644 --- a/src/Symfony/Component/HttpClient/Response/NativeResponse.php +++ b/src/Symfony/Component/HttpClient/Response/NativeResponse.php @@ -228,7 +228,7 @@ private static function schedule(self $response, array &$runningResponses): void /** * @param NativeClientState $multi */ - private static function perform(ClientState $multi, ?array &$responses = null): void + private static function perform(ClientState $multi, ?array $responses = null): void { foreach ($multi->openHandles as $i => [$pauseExpiry, $h, $buffer, $onProgress]) { if ($pauseExpiry) { diff --git a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php index 7b65fd7990464..95f7e9624c912 100644 --- a/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/TransportResponseTrait.php @@ -92,7 +92,7 @@ abstract protected static function schedule(self $response, array &$runningRespo /** * Performs all pending non-blocking operations. */ - abstract protected static function perform(ClientState $multi, array &$responses): void; + abstract protected static function perform(ClientState $multi, array $responses): void; /** * Waits for network activity. @@ -150,10 +150,15 @@ public static function stream(iterable $responses, ?float $timeout = null): \Gen $lastActivity = hrtime(true) / 1E9; $elapsedTimeout = 0; - if ($fromLastTimeout = 0.0 === $timeout && '-0' === (string) $timeout) { - $timeout = null; - } elseif ($fromLastTimeout = 0 > $timeout) { - $timeout = -$timeout; + if ((0.0 === $timeout && '-0' === (string) $timeout) || 0 > $timeout) { + $timeout = $timeout ? -$timeout : null; + + /** @var ClientState $multi */ + foreach ($runningResponses as [$multi]) { + if (null !== $multi->lastTimeout) { + $elapsedTimeout = max($elapsedTimeout, $lastActivity - $multi->lastTimeout); + } + } } while (true) { @@ -162,8 +167,7 @@ public static function stream(iterable $responses, ?float $timeout = null): \Gen $timeoutMin = $timeout ?? \INF; /** @var ClientState $multi */ - foreach ($runningResponses as $i => [$multi]) { - $responses = &$runningResponses[$i][1]; + foreach ($runningResponses as $i => [$multi, &$responses]) { self::perform($multi, $responses); foreach ($responses as $j => $response) { @@ -171,26 +175,25 @@ public static function stream(iterable $responses, ?float $timeout = null): \Gen $timeoutMin = min($timeoutMin, $response->timeout, 1); $chunk = false; - if ($fromLastTimeout && null !== $multi->lastTimeout) { - $elapsedTimeout = hrtime(true) / 1E9 - $multi->lastTimeout; - } - if (isset($multi->handlesActivity[$j])) { $multi->lastTimeout = null; + $elapsedTimeout = 0; } elseif (!isset($multi->openHandles[$j])) { + $hasActivity = true; unset($responses[$j]); continue; } elseif ($elapsedTimeout >= $timeoutMax) { $multi->handlesActivity[$j] = [new ErrorChunk($response->offset, sprintf('Idle timeout reached for "%s".', $response->getInfo('url')))]; $multi->lastTimeout ??= $lastActivity; + $elapsedTimeout = $timeoutMax; } else { continue; } - while ($multi->handlesActivity[$j] ?? false) { - $hasActivity = true; - $elapsedTimeout = 0; + $lastActivity = null; + $hasActivity = true; + while ($multi->handlesActivity[$j] ?? false) { if (\is_string($chunk = array_shift($multi->handlesActivity[$j]))) { if (null !== $response->inflate && false === $chunk = @inflate_add($response->inflate, $chunk)) { $multi->handlesActivity[$j] = [null, new TransportException(sprintf('Error while processing content unencoding for "%s".', $response->getInfo('url')))]; @@ -227,7 +230,6 @@ public static function stream(iterable $responses, ?float $timeout = null): \Gen } } elseif ($chunk instanceof ErrorChunk) { unset($responses[$j]); - $elapsedTimeout = $timeoutMax; } elseif ($chunk instanceof FirstChunk) { if ($response->logger) { $info = $response->getInfo(); @@ -274,10 +276,12 @@ public static function stream(iterable $responses, ?float $timeout = null): \Gen if ($chunk instanceof ErrorChunk && !$chunk->didThrow()) { // Ensure transport exceptions are always thrown $chunk->getContent(); + throw new \LogicException('A transport exception should have been thrown.'); } } if (!$responses) { + $hasActivity = true; unset($runningResponses[$i]); } @@ -291,7 +295,7 @@ public static function stream(iterable $responses, ?float $timeout = null): \Gen } if ($hasActivity) { - $lastActivity = hrtime(true) / 1E9; + $lastActivity ??= hrtime(true) / 1E9; continue; } From a60cff54b6ed544b06b349b6852bc9f6dd2fa6ae Mon Sep 17 00:00:00 2001 From: Peter van Dommelen Date: Fri, 7 Feb 2025 11:36:11 +0100 Subject: [PATCH 12/44] [DependencyInjection] Fix cloned lazy services not sharing their dependencies when dumped with PhpDumper --- .../Compiler/InlineServiceDefinitionsPass.php | 4 +- .../DependencyInjection/Dumper/PhpDumper.php | 6 ++ .../Tests/Dumper/PhpDumperTest.php | 55 +++++++++++++++++++ .../Tests/Fixtures/DependencyContainer.php | 25 +++++++++ .../Fixtures/DependencyContainerInterface.php | 17 ++++++ .../Tests/Fixtures/config/child.expected.yml | 4 +- .../config/from_callable.expected.yml | 4 +- .../Tests/Fixtures/php/closure_proxy.php | 2 +- .../Tests/Fixtures/php/lazy_closure.php | 4 +- .../php/services_almost_circular_private.php | 44 ++++++++++++--- .../php/services_almost_circular_public.php | 18 +++++- .../Fixtures/php/services_wither_lazy.php | 2 +- 12 files changed, 168 insertions(+), 17 deletions(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainer.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainerInterface.php diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index e0dc3a653e6b9..884977fff3d1f 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -224,6 +224,8 @@ private function isInlineableDefinition(string $id, Definition $definition): boo return false; } - return $this->container->getDefinition($srcId)->isShared(); + $srcDefinition = $this->container->getDefinition($srcId); + + return $srcDefinition->isShared() && !$srcDefinition->isLazy(); } } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 23e65483b03d3..5f544a859ceb1 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -2185,6 +2185,12 @@ private function isSingleUsePrivateNode(ServiceReferenceGraphNode $node): bool if ($edge->isLazy() || !$value instanceof Definition || !$value->isShared()) { return false; } + + // When the source node is a proxy or ghost, it will construct its references only when the node itself is initialized. + // Since the node can be cloned before being fully initialized, we do not know how often its references are used. + if ($this->getProxyDumper()->isProxyCandidate($value)) { + return false; + } $ids[$edge->getSourceNode()->getId()] = true; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 2d0a8aad0ce16..7622d858a3110 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -55,6 +55,8 @@ use Symfony\Component\DependencyInjection\Tests\Compiler\Wither; use Symfony\Component\DependencyInjection\Tests\Compiler\WitherAnnotation; use Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition; +use Symfony\Component\DependencyInjection\Tests\Fixtures\DependencyContainer; +use Symfony\Component\DependencyInjection\Tests\Fixtures\DependencyContainerInterface; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithEnumAttribute; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument; @@ -1677,6 +1679,59 @@ public function testWitherWithStaticReturnType() $this->assertInstanceOf(Foo::class, $wither->foo); } + public function testCloningLazyGhostWithDependency() + { + $container = new ContainerBuilder(); + $container->register('dependency', \stdClass::class); + $container->register(DependencyContainer::class) + ->addArgument(new Reference('dependency')) + ->setLazy(true) + ->setPublic(true); + + $container->compile(); + $dumper = new PhpDumper($container); + $dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Service_CloningLazyGhostWithDependency']); + eval('?>'.$dump); + + $container = new \Symfony_DI_PhpDumper_Service_CloningLazyGhostWithDependency(); + + $bar = $container->get(DependencyContainer::class); + $this->assertInstanceOf(DependencyContainer::class, $bar); + + $first_clone = clone $bar; + $second_clone = clone $bar; + + $this->assertSame($first_clone->dependency, $second_clone->dependency); + } + + public function testCloningProxyWithDependency() + { + $container = new ContainerBuilder(); + $container->register('dependency', \stdClass::class); + $container->register(DependencyContainer::class) + ->addArgument(new Reference('dependency')) + ->setLazy(true) + ->addTag('proxy', [ + 'interface' => DependencyContainerInterface::class, + ]) + ->setPublic(true); + + $container->compile(); + $dumper = new PhpDumper($container); + $dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_Service_CloningProxyWithDependency']); + eval('?>'.$dump); + + $container = new \Symfony_DI_PhpDumper_Service_CloningProxyWithDependency(); + + $bar = $container->get(DependencyContainer::class); + $this->assertInstanceOf(DependencyContainerInterface::class, $bar); + + $first_clone = clone $bar; + $second_clone = clone $bar; + + $this->assertSame($first_clone->getDependency(), $second_clone->getDependency()); + } + public function testCurrentFactoryInlining() { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainer.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainer.php new file mode 100644 index 0000000000000..5e222bdf060be --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainer.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures; + +class DependencyContainer implements DependencyContainerInterface +{ + public function __construct( + public mixed $dependency, + ) { + } + + public function getDependency(): mixed + { + return $this->dependency; + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainerInterface.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainerInterface.php new file mode 100644 index 0000000000000..ed109cad78dcd --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/DependencyContainerInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Fixtures; + +interface DependencyContainerInterface +{ + public function getDependency(): mixed; +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml index 44dbbd571b788..97380f388ca2a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/child.expected.yml @@ -11,7 +11,9 @@ services: - container.decorator: { id: bar, inner: b } file: file.php lazy: true - arguments: [!service { class: Class1 }] + arguments: ['@b'] + b: + class: Class1 bar: alias: foo public: true diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml index d4dbbbadd48bf..1ab1643af1b48 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/from_callable.expected.yml @@ -8,5 +8,7 @@ services: class: stdClass public: true lazy: true - arguments: [[!service { class: stdClass }, do]] + arguments: [['@bar', do]] factory: [Closure, fromCallable] + bar: + class: stdClass diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php index 2bef92604d3a9..eaf303c7d068c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/closure_proxy.php @@ -55,6 +55,6 @@ protected function createProxy($class, \Closure $factory) */ protected static function getClosureProxyService($container, $lazyLoad = true) { - return $container->services['closure_proxy'] = new class(fn () => new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure implements \Symfony\Component\DependencyInjection\Tests\Compiler\SingleMethodInterface { public function theMethod() { return $this->service->cloneFoo(...\func_get_args()); } }; + return $container->services['closure_proxy'] = new class(fn () => ($container->privates['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo())) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure implements \Symfony\Component\DependencyInjection\Tests\Compiler\SingleMethodInterface { public function theMethod() { return $this->service->cloneFoo(...\func_get_args()); } }; } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php index 0af28f2650147..2bf27779df041 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/lazy_closure.php @@ -57,7 +57,7 @@ protected function createProxy($class, \Closure $factory) */ protected static function getClosure1Service($container, $lazyLoad = true) { - return $container->services['closure1'] = (new class(fn () => new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function cloneFoo(?\stdClass $bar = null): \Symfony\Component\DependencyInjection\Tests\Compiler\Foo { return $this->service->cloneFoo(...\func_get_args()); } })->cloneFoo(...); + return $container->services['closure1'] = (new class(fn () => ($container->privates['foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo())) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function cloneFoo(?\stdClass $bar = null): \Symfony\Component\DependencyInjection\Tests\Compiler\Foo { return $this->service->cloneFoo(...\func_get_args()); } })->cloneFoo(...); } /** @@ -67,6 +67,6 @@ protected static function getClosure1Service($container, $lazyLoad = true) */ protected static function getClosure2Service($container, $lazyLoad = true) { - return $container->services['closure2'] = (new class(fn () => new \Symfony\Component\DependencyInjection\Tests\Compiler\FooVoid()) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function __invoke(string $name): void { $this->service->__invoke(...\func_get_args()); } })->__invoke(...); + return $container->services['closure2'] = (new class(fn () => ($container->privates['foo_void'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\FooVoid())) extends \Symfony\Component\DependencyInjection\Argument\LazyClosure { public function __invoke(string $name): void { $this->service->__invoke(...\func_get_args()); } })->__invoke(...); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php index 0a9c519c8e69c..0c234ac3934c3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php @@ -373,15 +373,13 @@ protected static function getManager2Service($container) */ protected static function getManager3Service($container, $lazyLoad = true) { - $a = ($container->services['listener3'] ?? self::getListener3Service($container)); + $a = ($container->privates['connection3'] ?? self::getConnection3Service($container)); if (isset($container->services['manager3'])) { return $container->services['manager3']; } - $b = new \stdClass(); - $b->listener = [$a]; - return $container->services['manager3'] = new \stdClass($b); + return $container->services['manager3'] = new \stdClass($a); } /** @@ -481,6 +479,34 @@ protected static function getBar6Service($container) return $container->privates['bar6'] = new \stdClass($a); } + /** + * Gets the private 'connection3' shared service. + * + * @return \stdClass + */ + protected static function getConnection3Service($container) + { + $container->privates['connection3'] = $instance = new \stdClass(); + + $instance->listener = [($container->services['listener3'] ?? self::getListener3Service($container))]; + + return $instance; + } + + /** + * Gets the private 'connection4' shared service. + * + * @return \stdClass + */ + protected static function getConnection4Service($container) + { + $container->privates['connection4'] = $instance = new \stdClass(); + + $instance->listener = [($container->services['listener4'] ?? self::getListener4Service($container))]; + + return $instance; + } + /** * Gets the private 'doctrine.listener' shared service. * @@ -572,13 +598,13 @@ protected static function getMailerInline_TransportFactory_AmazonService($contai */ protected static function getManager4Service($container, $lazyLoad = true) { - $a = new \stdClass(); + $a = ($container->privates['connection4'] ?? self::getConnection4Service($container)); - $container->privates['manager4'] = $instance = new \stdClass($a); - - $a->listener = [($container->services['listener4'] ?? self::getListener4Service($container))]; + if (isset($container->privates['manager4'])) { + return $container->privates['manager4']; + } - return $instance; + return $container->privates['manager4'] = new \stdClass($a); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php index 2250e860264dc..ae283e556a0da 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php @@ -259,7 +259,7 @@ protected static function getDispatcher2Service($container, $lazyLoad = true) { $container->services['dispatcher2'] = $instance = new \stdClass(); - $instance->subscriber2 = new \stdClass(($container->services['manager2'] ?? self::getManager2Service($container))); + $instance->subscriber2 = ($container->privates['subscriber2'] ?? self::getSubscriber2Service($container)); return $instance; } @@ -820,4 +820,20 @@ protected static function getManager4Service($container, $lazyLoad = true) return $container->privates['manager4'] = new \stdClass($a); } + + /** + * Gets the private 'subscriber2' shared service. + * + * @return \stdClass + */ + protected static function getSubscriber2Service($container) + { + $a = ($container->services['manager2'] ?? self::getManager2Service($container)); + + if (isset($container->privates['subscriber2'])) { + return $container->privates['subscriber2']; + } + + return $container->privates['subscriber2'] = new \stdClass($a); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php index f52f226597625..d5c3738a62a0b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy.php @@ -61,7 +61,7 @@ protected static function getWitherService($container, $lazyLoad = true) $instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither(); - $a = new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo(); + $a = ($container->privates['Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); $instance = $instance->withFoo1($a); $instance = $instance->withFoo2($a); From b52b760dff21415453f242a755f7db61e837d6b0 Mon Sep 17 00:00:00 2001 From: Artem Lopata Date: Fri, 7 Feb 2025 09:04:01 +0100 Subject: [PATCH 13/44] [DependencyInjection] Do not preload functions --- .../DependencyInjection/Dumper/PhpDumper.php | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 23e65483b03d3..8719ce967e784 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -353,7 +353,7 @@ class %s extends {$options['class']} EOF; foreach ($this->preload as $class) { - if (!$class || str_contains($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void'], true)) { + if (!$class || str_contains($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void', 'never'], true)) { continue; } if (!(class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false)) || (new \ReflectionClass($class))->isUserDefined()) { @@ -846,8 +846,7 @@ private function addService(string $id, Definition $definition): array if ($class = $definition->getClass()) { $class = $class instanceof Parameter ? '%'.$class.'%' : $this->container->resolveEnvPlaceholders($class); $return[] = sprintf(str_starts_with($class, '%') ? '@return object A %1$s instance' : '@return \%s', ltrim($class, '\\')); - } elseif ($definition->getFactory()) { - $factory = $definition->getFactory(); + } elseif ($factory = $definition->getFactory()) { if (\is_string($factory) && !str_starts_with($factory, '@=')) { $return[] = sprintf('@return object An instance returned by %s()', $factory); } elseif (\is_array($factory) && (\is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) { @@ -1170,9 +1169,7 @@ private function addNewInstance(Definition $definition, string $return = '', ?st $arguments[] = (\is_string($i) ? $i.': ' : '').$this->dumpValue($value); } - if (null !== $definition->getFactory()) { - $callable = $definition->getFactory(); - + if ($callable = $definition->getFactory()) { if ('current' === $callable && [0] === array_keys($definition->getArguments()) && \is_array($value) && [0] === array_keys($value)) { return $return.$this->dumpValue($value[0]).$tail; } @@ -2293,7 +2290,6 @@ private function getAutoloadFile(): ?string private function getClasses(Definition $definition, string $id): array { $classes = []; - $resolve = $this->container->getParameterBag()->resolveValue(...); while ($definition instanceof Definition) { foreach ($definition->getTag($this->preloadTags[0]) as $tag) { @@ -2305,24 +2301,24 @@ private function getClasses(Definition $definition, string $id): array } if ($class = $definition->getClass()) { - $classes[] = trim($resolve($class), '\\'); + $classes[] = trim($class, '\\'); } $factory = $definition->getFactory(); + if (\is_string($factory) && !str_starts_with($factory, '@=') && str_contains($factory, '::')) { + $factory = explode('::', $factory); + } + if (!\is_array($factory)) { - $factory = [$factory]; + $definition = $factory; + continue; } - if (\is_string($factory[0])) { - $factory[0] = $resolve($factory[0]); + $definition = $factory[0] ?? null; - if (false !== $i = strrpos($factory[0], '::')) { - $factory[0] = substr($factory[0], 0, $i); - } + if (\is_string($definition)) { $classes[] = trim($factory[0], '\\'); } - - $definition = $factory[0]; } return $classes; From 416aa0e86f971cbf3a4e28b3c3fab76703608499 Mon Sep 17 00:00:00 2001 From: Hugo Posnic Date: Fri, 29 Nov 2024 11:17:22 +0100 Subject: [PATCH 14/44] [WebProfilerBundle] Fix interception for non conventional redirects --- .../WebProfilerBundle/EventListener/WebDebugToolbarListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index c2b350ff05d68..87cb3d55fe42f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -107,7 +107,7 @@ public function onKernelResponse(ResponseEvent $event): void return; } - if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat()) { + if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat() && $response->headers->has('Location')) { if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) { // keep current flashes for one more request if using AutoExpireFlashBag $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); From 0fbfc3e32de07cc56d1f95d5704af4bf5487d372 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 11 Feb 2025 14:07:09 +0100 Subject: [PATCH 15/44] [BrowserKit] Fix submitting forms with empty file fields --- .../Component/BrowserKit/HttpBrowser.php | 9 +++-- .../BrowserKit/Tests/HttpBrowserTest.php | 33 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/HttpBrowser.php b/src/Symfony/Component/BrowserKit/HttpBrowser.php index 9d84bda751ba5..4eb30b5be9ba0 100644 --- a/src/Symfony/Component/BrowserKit/HttpBrowser.php +++ b/src/Symfony/Component/BrowserKit/HttpBrowser.php @@ -143,10 +143,15 @@ private function getUploadedFiles(array $files): array } if (!isset($file['tmp_name'])) { $uploadedFiles[$name] = $this->getUploadedFiles($file); + continue; } - if (isset($file['tmp_name'])) { - $uploadedFiles[$name] = DataPart::fromPath($file['tmp_name'], $file['name']); + + if ('' === $file['tmp_name']) { + $uploadedFiles[$name] = new DataPart('', ''); + continue; } + + $uploadedFiles[$name] = DataPart::fromPath($file['tmp_name'], $file['name']); } return $uploadedFiles; diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php index e1f19b16ce814..3a2547d89f488 100644 --- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php @@ -14,6 +14,8 @@ use Symfony\Component\BrowserKit\CookieJar; use Symfony\Component\BrowserKit\History; use Symfony\Component\BrowserKit\HttpBrowser; +use Symfony\Component\HttpClient\MockHttpClient; +use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; @@ -208,6 +210,37 @@ public static function forwardSlashesRequestPathProvider() ]; } + public function testEmptyUpload() + { + $client = new MockHttpClient(function ($method, $url, $options) { + $this->assertSame('POST', $method); + $this->assertSame('http://localhost/', $url); + $this->assertStringStartsWith('Content-Type: multipart/form-data; boundary=', $options['normalized_headers']['content-type'][0]); + + $body = ''; + while ('' !== $data = $options['body'](1024)) { + $body .= $data; + } + + $expected = <<assertStringMatchesFormat($expected, $body); + + return new MockResponse(); + }); + + $browser = new HttpBrowser($client); + $browser->request('POST', '/', [], ['file' => ['tmp_name' => '', 'name' => 'file']]); + } + private function uploadFile(string $data): string { $path = tempnam(sys_get_temp_dir(), 'http'); From 159e6b9154696bfbac320e768156b4e633a81ed1 Mon Sep 17 00:00:00 2001 From: DemigodCode Date: Tue, 11 Feb 2025 13:06:06 +0100 Subject: [PATCH 16/44] [Cache] Tests for Redis Replication with cache --- .github/workflows/integration-tests.yml | 12 ++++ .../PredisRedisReplicationAdapterTest.php | 29 +++++++++ .../Adapter/PredisReplicationAdapterTest.php | 24 +++++++ .../PredisTagAwareReplicationAdapterTest.php | 37 +++++++++++ .../Adapter/RedisReplicationAdapterTest.php | 65 +++++++++++++++++++ .../Component/Cache/Traits/RedisTrait.php | 14 +++- 6 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php create mode 100644 src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php create mode 100644 src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php create mode 100644 src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 29b9b8ec62409..5c2839d74f818 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -81,6 +81,17 @@ jobs: REDIS_MASTER_HOST: redis REDIS_MASTER_SET: redis_sentinel REDIS_SENTINEL_QUORUM: 1 + redis-primary: + image: redis:latest + hostname: redis-primary + ports: + - 16381:6379 + + redis-replica: + image: redis:latest + ports: + - 16382:6379 + command: redis-server --slaveof redis-primary 6379 memcached: image: memcached:1.6.5 ports: @@ -239,6 +250,7 @@ jobs: REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005' REDIS_SENTINEL_HOSTS: 'unreachable-host:26379 localhost:26379 localhost:26379' REDIS_SENTINEL_SERVICE: redis_sentinel + REDIS_REPLICATION_HOSTS: 'localhost:16381 localhost:16382' MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01" diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php new file mode 100644 index 0000000000000..552727740c18b --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Symfony\Component\Cache\Adapter\RedisAdapter; + +/** + * @group integration + */ +class PredisRedisReplicationAdapterTest extends AbstractRedisAdapterTestCase +{ + public static function setUpBeforeClass(): void + { + if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) { + self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.'); + } + + self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][alias]=master', ['class' => \Predis\Client::class, 'prefix' => 'prefix_']); + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php new file mode 100644 index 0000000000000..4add9d5f18c4a --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +/** + * @group integration + */ +class PredisReplicationAdapterTest extends AbstractRedisAdapterTestCase +{ + public static function setUpBeforeClass(): void + { + parent::setUpBeforeClass(); + self::$redis = new \Predis\Client(array_combine(['host', 'port'], explode(':', getenv('REDIS_HOST')) + [1 => 6379]), ['prefix' => 'prefix_']); + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php new file mode 100644 index 0000000000000..4d8651ce4ceb6 --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; + +/** + * @group integration + */ +class PredisTagAwareReplicationAdapterTest extends PredisReplicationAdapterTest +{ + use TagAwareTestTrait; + + protected function setUp(): void + { + parent::setUp(); + $this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite'; + } + + public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface + { + $this->assertInstanceOf(\Predis\Client::class, self::$redis); + $adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); + + return $adapter; + } +} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php new file mode 100644 index 0000000000000..e41745057f141 --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Cache\Tests\Adapter; + +use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\Adapter\AbstractAdapter; +use Symfony\Component\Cache\Adapter\RedisAdapter; +use Symfony\Component\Cache\Exception\InvalidArgumentException; +use Symfony\Component\Cache\Traits\RedisClusterProxy; + +/** + * @group integration + */ +class RedisReplicationAdapterTest extends AbstractRedisAdapterTestCase +{ + public static function setUpBeforeClass(): void + { + if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) { + self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.'); + } + + self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][alias]=master', ['lazy' => true]); + self::$redis->setOption(\Redis::OPT_PREFIX, 'prefix_'); + } + + public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface + { + if ('testClearWithPrefix' === $testMethod && \defined('Redis::SCAN_PREFIX')) { + self::$redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_PREFIX); + } + + $this->assertInstanceOf(RedisClusterProxy::class, self::$redis); + $adapter = new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); + + return $adapter; + } + + /** + * @dataProvider provideFailedCreateConnection + */ + public function testFailedCreateConnection(string $dsn) + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Redis connection '); + RedisAdapter::createConnection($dsn); + } + + public static function provideFailedCreateConnection(): array + { + return [ + ['redis://localhost:1234'], + ['redis://foo@localhost?role=master'], + ['redis://localhost/123?role=master'], + ]; + } +} diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index fc8f5cec60472..2ebaed16f1804 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -17,6 +17,7 @@ use Predis\Connection\Aggregate\ReplicationInterface; use Predis\Connection\Cluster\ClusterInterface as Predis2ClusterInterface; use Predis\Connection\Cluster\RedisCluster as Predis2RedisCluster; +use Predis\Connection\Replication\ReplicationInterface as Predis2ReplicationInterface; use Predis\Response\ErrorInterface; use Predis\Response\Status; use Relay\Relay; @@ -473,9 +474,16 @@ protected function doClear(string $namespace): bool $cleared = true; $hosts = $this->getHosts(); $host = reset($hosts); - if ($host instanceof \Predis\Client && $host->getConnection() instanceof ReplicationInterface) { - // Predis supports info command only on the master in replication environments - $hosts = [$host->getClientFor('master')]; + if ($host instanceof \Predis\Client) { + $connection = $host->getConnection(); + + if ($connection instanceof ReplicationInterface) { + $hosts = [$host->getClientFor('master')]; + } elseif ($connection instanceof Predis2ReplicationInterface) { + $connection->switchToMaster(); + + $hosts = [$host]; + } } foreach ($hosts as $host) { From 5cf6c66409bebdac24b9adaa4a35f608407ba960 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 11 Feb 2025 17:41:13 +0100 Subject: [PATCH 17/44] [WebProfilerBundle] Fix tests --- .../Tests/EventListener/WebDebugToolbarListenerTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php index 33bf1a32d27f8..cf3c189204301 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -63,6 +63,7 @@ public static function getInjectToolbarTests() public function testHtmlRedirectionIsIntercepted($statusCode) { $response = new Response('Some content', $statusCode); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response); @@ -76,6 +77,7 @@ public function testHtmlRedirectionIsIntercepted($statusCode) public function testNonHtmlRedirectionIsNotIntercepted() { $response = new Response('Some content', '301'); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response); @@ -139,6 +141,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() public function testToolbarIsNotInjectedOnRedirection($statusCode) { $response = new Response('', $statusCode); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response); From 74baaf08ce464ce649fde7fd8478250e0c5f81c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pr=C3=A9vot?= Date: Wed, 12 Feb 2025 03:01:53 +0100 Subject: [PATCH 18/44] ntfy-notifier: tfix in description Bug-Debian: https://bugs.debian.org/1095786 --- src/Symfony/Component/Notifier/Bridge/Ntfy/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Ntfy/composer.json b/src/Symfony/Component/Notifier/Bridge/Ntfy/composer.json index 5fdbc79b1cd21..988a4ce85efb4 100644 --- a/src/Symfony/Component/Notifier/Bridge/Ntfy/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Ntfy/composer.json @@ -1,7 +1,7 @@ { "name": "symfony/ntfy-notifier", "type": "symfony-notifier-bridge", - "description": "Symfony Ntyf Notifier Bridge", + "description": "Symfony Ntfy Notifier Bridge", "keywords": ["ntfy", "notifier"], "homepage": "https://symfony.com", "license": "MIT", From 707c3d7632004fa3b6f2a3b5f1e3ebb9993d5e3f Mon Sep 17 00:00:00 2001 From: David Vancl <43696921+davidvancl@users.noreply.github.com> Date: Tue, 11 Feb 2025 09:36:58 +0100 Subject: [PATCH 19/44] [Translation] check empty notes --- .../Translation/Dumper/XliffFileDumper.php | 2 +- .../Tests/Dumper/XliffFileDumperTest.php | 36 +++++++++++++++++++ .../Fixtures/resources-2.0-empty-notes.xlf | 20 +++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf diff --git a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php index d0f016b23c365..f5ce96a02580c 100644 --- a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php @@ -176,7 +176,7 @@ private function dumpXliff2(string $defaultLocale, MessageCatalogue $messages, ? $metadata = $messages->getMetadata($source, $domain); // Add notes section - if ($this->hasMetadataArrayInfo('notes', $metadata)) { + if ($this->hasMetadataArrayInfo('notes', $metadata) && $metadata['notes']) { $notesElement = $dom->createElement('notes'); foreach ($metadata['notes'] as $note) { $n = $dom->createElement('note'); diff --git a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php index f9ae8986f52fe..a1a125f605880 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php @@ -147,4 +147,40 @@ public function testDumpCatalogueWithXliffExtension() $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR']) ); } + + public function testFormatCatalogueXliff2WithSegmentAttributes() + { + $catalogue = new MessageCatalogue('en_US'); + $catalogue->add([ + 'foo' => 'bar', + 'key' => '', + ]); + $catalogue->setMetadata('foo', ['segment-attributes' => ['state' => 'translated']]); + $catalogue->setMetadata('key', ['segment-attributes' => ['state' => 'translated', 'subState' => 'My Value']]); + + $dumper = new XliffFileDumper(); + + $this->assertStringEqualsFile( + __DIR__.'/../Fixtures/resources-2.0-segment-attributes.xlf', + $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0']) + ); + } + + public function testEmptyMetadataNotes() + { + $catalogue = new MessageCatalogue('en_US'); + $catalogue->add([ + 'empty' => 'notes', + 'full' => 'notes', + ]); + $catalogue->setMetadata('empty', ['notes' => []]); + $catalogue->setMetadata('full', ['notes' => [['category' => 'file-source', 'priority' => 1, 'content' => 'test/path/to/translation/Example.1.html.twig:27']]]); + + $dumper = new XliffFileDumper(); + + $this->assertStringEqualsFile( + __DIR__.'/../Fixtures/resources-2.0-empty-notes.xlf', + $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0']) + ); + } } diff --git a/src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf b/src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf new file mode 100644 index 0000000000000..7cba2cc09b41e --- /dev/null +++ b/src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf @@ -0,0 +1,20 @@ + + + + + + empty + notes + + + + + test/path/to/translation/Example.1.html.twig:27 + + + full + notes + + + + From 540253a89b7a90130f683091558a8b167e425e13 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 12 Feb 2025 17:44:25 +0100 Subject: [PATCH 20/44] [VarExporter] Fix lazy objects with hooked properties --- .../VarExporter/Internal/Hydrator.php | 2 + .../Internal/LazyObjectRegistry.php | 17 ++- .../Component/VarExporter/ProxyHelper.php | 109 +++++++++++++++++- .../VarExporter/Tests/Fixtures/Hooked.php | 25 ++++ .../VarExporter/Tests/LazyGhostTraitTest.php | 26 +++++ .../VarExporter/Tests/LazyProxyTraitTest.php | 28 +++++ .../VarExporter/Tests/ProxyHelperTest.php | 12 ++ 7 files changed, 211 insertions(+), 8 deletions(-) create mode 100644 src/Symfony/Component/VarExporter/Tests/Fixtures/Hooked.php diff --git a/src/Symfony/Component/VarExporter/Internal/Hydrator.php b/src/Symfony/Component/VarExporter/Internal/Hydrator.php index 49d636fb8e0ce..97ffe4c831627 100644 --- a/src/Symfony/Component/VarExporter/Internal/Hydrator.php +++ b/src/Symfony/Component/VarExporter/Internal/Hydrator.php @@ -287,6 +287,8 @@ public static function getPropertyScopes($class) if (\ReflectionProperty::IS_PROTECTED & $flags) { $propertyScopes["\0*\0$name"] = $propertyScopes[$name]; + } elseif (\PHP_VERSION_ID >= 80400 && $property->getHooks()) { + $propertyScopes[$name][] = true; } } diff --git a/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php b/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php index fddc6fb3b9664..a7b4987e3b0db 100644 --- a/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php +++ b/src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php @@ -50,6 +50,7 @@ class LazyObjectRegistry public static function getClassResetters($class) { $classProperties = []; + $hookedProperties = []; if ((self::$classReflectors[$class] ??= new \ReflectionClass($class))->isInternal()) { $propertyScopes = []; @@ -60,7 +61,13 @@ public static function getClassResetters($class) foreach ($propertyScopes as $key => [$scope, $name, $readonlyScope]) { $propertyScopes[$k = "\0$scope\0$name"] ?? $propertyScopes[$k = "\0*\0$name"] ?? $k = $name; - if ($k === $key && "\0$class\0lazyObjectState" !== $k) { + if ($k !== $key || "\0$class\0lazyObjectState" === $k) { + continue; + } + + if ($k === $name && ($propertyScopes[$k][4] ?? false)) { + $hookedProperties[$k] = true; + } else { $classProperties[$readonlyScope ?? $scope][$name] = $key; } } @@ -76,9 +83,13 @@ public static function getClassResetters($class) }, null, $scope); } - $resetters[] = static function ($instance, $skippedProperties, $onlyProperties = null) { + $resetters[] = static function ($instance, $skippedProperties, $onlyProperties = null) use ($hookedProperties) { foreach ((array) $instance as $name => $value) { - if ("\0" !== ($name[0] ?? '') && !\array_key_exists($name, $skippedProperties) && (null === $onlyProperties || \array_key_exists($name, $onlyProperties))) { + if ("\0" !== ($name[0] ?? '') + && !\array_key_exists($name, $skippedProperties) + && (null === $onlyProperties || \array_key_exists($name, $onlyProperties)) + && !isset($hookedProperties[$name]) + ) { unset($instance->$name); } } diff --git a/src/Symfony/Component/VarExporter/ProxyHelper.php b/src/Symfony/Component/VarExporter/ProxyHelper.php index d5a8d7418b807..246dc4d404bc7 100644 --- a/src/Symfony/Component/VarExporter/ProxyHelper.php +++ b/src/Symfony/Component/VarExporter/ProxyHelper.php @@ -58,6 +58,37 @@ public static function generateLazyGhost(\ReflectionClass $class): string throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" extends "%s" which is internal.', $class->name, $parent->name)); } } + + $hooks = ''; + $propertyScopes = Hydrator::$propertyScopes[$class->name] ??= Hydrator::getPropertyScopes($class->name); + foreach ($propertyScopes as $name => $scope) { + if (!isset($scope[4]) || ($p = $scope[3])->isVirtual()) { + continue; + } + + $type = self::exportType($p); + $hooks .= "\n public {$type} \${$name} {\n"; + + foreach ($p->getHooks() as $hook => $method) { + if ($method->isFinal()) { + throw new LogicException(sprintf('Cannot generate lazy ghost: hook "%s::%s()" is final.', $class->name, $method->name)); + } + + if ('get' === $hook) { + $ref = ($method->returnsReference() ? '&' : ''); + $hooks .= " {$ref}get { \$this->initializeLazyObject(); return parent::\${$name}::get(); }\n"; + } elseif ('set' === $hook) { + $parameters = self::exportParameters($method, true); + $arg = '$'.$method->getParameters()[0]->name; + $hooks .= " set({$parameters}) { \$this->initializeLazyObject(); parent::\${$name}::set({$arg}); }\n"; + } else { + throw new LogicException(sprintf('Cannot generate lazy ghost: hook "%s::%s()" is not supported.', $class->name, $method->name)); + } + } + + $hooks .= " }\n"; + } + $propertyScopes = self::exportPropertyScopes($class->name); return <<name)); } + $hookedProperties = []; + if (\PHP_VERSION_ID >= 80400 && $class) { + $propertyScopes = Hydrator::$propertyScopes[$class->name] ??= Hydrator::getPropertyScopes($class->name); + foreach ($propertyScopes as $name => $scope) { + if (isset($scope[4]) && !($p = $scope[3])->isVirtual()) { + $hookedProperties[$name] = [$p, $p->getHooks()]; + } + } + } + $methodReflectors = [$class?->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) ?? []]; foreach ($interfaces as $interface) { if (!$interface->isInterface()) { throw new LogicException(sprintf('Cannot generate lazy proxy: "%s" is not an interface.', $interface->name)); } $methodReflectors[] = $interface->getMethods(); + + if (\PHP_VERSION_ID >= 80400 && !$class) { + foreach ($interface->getProperties() as $p) { + $hookedProperties[$p->name] ??= [$p, []]; + $hookedProperties[$p->name][1] += $p->getHooks(); + } + } + } + + $hooks = ''; + foreach ($hookedProperties as $name => [$p, $methods]) { + $type = self::exportType($p); + $hooks .= "\n public {$type} \${$p->name} {\n"; + + foreach ($methods as $hook => $method) { + if ($method->isFinal()) { + throw new LogicException(sprintf('Cannot generate lazy proxy: hook "%s::%s()" is final.', $class->name, $method->name)); + } + + if ('get' === $hook) { + $ref = ($method->returnsReference() ? '&' : ''); + $hooks .= <<lazyObjectState)) { + return (\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$p->name}; + } + + return parent::\${$p->name}::get(); + } + + EOPHP; + } elseif ('set' === $hook) { + $parameters = self::exportParameters($method, true); + $arg = '$'.$method->getParameters()[0]->name; + $hooks .= <<lazyObjectState)) { + \$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)(); + \$this->lazyObjectState->realInstance->{$p->name} = {$arg}; + } + + parent::\${$p->name}::set({$arg}); + } + + EOPHP; + } else { + throw new LogicException(sprintf('Cannot generate lazy proxy: hook "%s::%s()" is not supported.', $class->name, $method->name)); + } + } + + $hooks .= " }\n"; } - $methodReflectors = array_merge(...$methodReflectors); $extendsInternalClass = false; if ($parent = $class) { @@ -112,6 +203,7 @@ public static function generateLazyProxy(?\ReflectionClass $class, array $interf } $methodsHaveToBeProxied = $extendsInternalClass; $methods = []; + $methodReflectors = array_merge(...$methodReflectors); foreach ($methodReflectors as $method) { if ('__get' !== strtolower($method->name) || 'mixed' === ($type = self::exportType($method) ?? 'mixed')) { @@ -228,7 +320,7 @@ public function __unserialize(\$data): void {$lazyProxyTraitStatement} private const LAZY_OBJECT_PROPERTY_SCOPES = {$propertyScopes}; - {$body}} + {$hooks}{$body}} // Help opcache.preload discover always-needed symbols class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); @@ -238,7 +330,7 @@ class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); EOPHP; } - public static function exportSignature(\ReflectionFunctionAbstract $function, bool $withParameterTypes = true, ?string &$args = null): string + public static function exportParameters(\ReflectionFunctionAbstract $function, bool $withParameterTypes = true, ?string &$args = null): string { $byRefIndex = 0; $args = ''; @@ -268,8 +360,15 @@ public static function exportSignature(\ReflectionFunctionAbstract $function, bo $args = implode(', ', $args); } + return implode(', ', $parameters); + } + + public static function exportSignature(\ReflectionFunctionAbstract $function, bool $withParameterTypes = true, ?string &$args = null): string + { + $parameters = self::exportParameters($function, $withParameterTypes, $args); + $signature = 'function '.($function->returnsReference() ? '&' : '') - .($function->isClosure() ? '' : $function->name).'('.implode(', ', $parameters).')'; + .($function->isClosure() ? '' : $function->name).'('.$parameters.')'; if ($function instanceof \ReflectionMethod) { $signature = ($function->isPublic() ? 'public ' : ($function->isProtected() ? 'protected ' : 'private ')) diff --git a/src/Symfony/Component/VarExporter/Tests/Fixtures/Hooked.php b/src/Symfony/Component/VarExporter/Tests/Fixtures/Hooked.php new file mode 100644 index 0000000000000..0c46d37afe922 --- /dev/null +++ b/src/Symfony/Component/VarExporter/Tests/Fixtures/Hooked.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter\Tests\Fixtures; + +class Hooked +{ + public int $notBacked { + get { return 123; } + set { throw \LogicException('Cannot set value.'); } + } + + public int $backed { + get { return $this->backed ??= 234; } + set { $this->backed = $value; } + } +} diff --git a/src/Symfony/Component/VarExporter/Tests/LazyGhostTraitTest.php b/src/Symfony/Component/VarExporter/Tests/LazyGhostTraitTest.php index 68e76a7dac1fa..00f090a43c292 100644 --- a/src/Symfony/Component/VarExporter/Tests/LazyGhostTraitTest.php +++ b/src/Symfony/Component/VarExporter/Tests/LazyGhostTraitTest.php @@ -17,6 +17,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\VarExporter\Internal\LazyObjectState; use Symfony\Component\VarExporter\ProxyHelper; +use Symfony\Component\VarExporter\Tests\Fixtures\Hooked; use Symfony\Component\VarExporter\Tests\Fixtures\LazyGhost\ChildMagicClass; use Symfony\Component\VarExporter\Tests\Fixtures\LazyGhost\ChildStdClass; use Symfony\Component\VarExporter\Tests\Fixtures\LazyGhost\ChildTestClass; @@ -478,6 +479,31 @@ public function testNormalization() $this->assertSame(['property' => 'property', 'method' => 'method'], $output); } + /** + * @requires PHP 8.4 + */ + public function testPropertyHooks() + { + $initialized = false; + $object = $this->createLazyGhost(Hooked::class, function ($instance) use (&$initialized) { + $initialized = true; + }); + + $this->assertSame(123, $object->notBacked); + $this->assertFalse($initialized); + $this->assertSame(234, $object->backed); + $this->assertTrue($initialized); + + $initialized = false; + $object = $this->createLazyGhost(Hooked::class, function ($instance) use (&$initialized) { + $initialized = true; + }); + + $object->backed = 345; + $this->assertTrue($initialized); + $this->assertSame(345, $object->backed); + } + /** * @template T * diff --git a/src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php b/src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php index c4234d085b6dc..938b304461291 100644 --- a/src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php +++ b/src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php @@ -18,6 +18,7 @@ use Symfony\Component\VarExporter\Exception\LogicException; use Symfony\Component\VarExporter\LazyProxyTrait; use Symfony\Component\VarExporter\ProxyHelper; +use Symfony\Component\VarExporter\Tests\Fixtures\Hooked; use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\FinalPublicClass; use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\ReadOnlyClass; use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\StringMagicGetClass; @@ -298,6 +299,33 @@ public function testNormalization() $this->assertSame(['property' => 'property', 'method' => 'method'], $output); } + /** + * @requires PHP 8.4 + */ + public function testPropertyHooks() + { + $initialized = false; + $object = $this->createLazyProxy(Hooked::class, function () use (&$initialized) { + $initialized = true; + return new Hooked(); + }); + + $this->assertSame(123, $object->notBacked); + $this->assertFalse($initialized); + $this->assertSame(234, $object->backed); + $this->assertTrue($initialized); + + $initialized = false; + $object = $this->createLazyProxy(Hooked::class, function () use (&$initialized) { + $initialized = true; + return new Hooked(); + }); + + $object->backed = 345; + $this->assertTrue($initialized); + $this->assertSame(345, $object->backed); + } + /** * @template T * diff --git a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php index b7372632de217..d0085a70498c5 100644 --- a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php +++ b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\VarExporter\Exception\LogicException; use Symfony\Component\VarExporter\ProxyHelper; +use Symfony\Component\VarExporter\Tests\Fixtures\Hooked; use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\Php82NullStandaloneReturnType; use Symfony\Component\VarExporter\Tests\Fixtures\LazyProxy\StringMagicGetClass; @@ -246,6 +247,17 @@ public function testNullStandaloneReturnType() ProxyHelper::generateLazyProxy(new \ReflectionClass(Php82NullStandaloneReturnType::class)) ); } + + /** + * @requires PHP 8.4 + */ + public function testPropertyHooks() + { + self::assertStringContainsString( + "[parent::class, 'backed', null, 4 => true]", + ProxyHelper::generateLazyProxy(new \ReflectionClass(Hooked::class)) + ); + } } abstract class TestForProxyHelper From 4a475e09ccb454357dfd1b677cbc44bcb2b8260e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 13 Feb 2025 10:55:13 +0100 Subject: [PATCH 21/44] [HttpClient] Don't send any default content-type when the body is empty --- src/Symfony/Component/HttpClient/HttpClientTrait.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 89446ff8cfd78..4be9afa798296 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -356,9 +356,11 @@ private static function normalizeBody($body, array &$normalizedHeaders = []) } }); - $body = http_build_query($body, '', '&'); + if ('' === $body = http_build_query($body, '', '&')) { + return ''; + } - if ('' === $body || !$streams && !str_contains($normalizedHeaders['content-type'][0] ?? '', 'multipart/form-data')) { + if (!$streams && !str_contains($normalizedHeaders['content-type'][0] ?? '', 'multipart/form-data')) { if (!str_contains($normalizedHeaders['content-type'][0] ?? '', 'application/x-www-form-urlencoded')) { $normalizedHeaders['content-type'] = ['Content-Type: application/x-www-form-urlencoded']; } From 7b9968e16e9d21871857954811f8eab409808f5f Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Thu, 13 Feb 2025 10:59:49 +0100 Subject: [PATCH 22/44] Fixes XliffFileDumperTest for 6.4 --- .../Tests/Dumper/XliffFileDumperTest.php | 18 ------------------ .../Fixtures/resources-2.0-empty-notes.xlf | 4 ++-- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php index a1a125f605880..ed016304110d0 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php @@ -148,24 +148,6 @@ public function testDumpCatalogueWithXliffExtension() ); } - public function testFormatCatalogueXliff2WithSegmentAttributes() - { - $catalogue = new MessageCatalogue('en_US'); - $catalogue->add([ - 'foo' => 'bar', - 'key' => '', - ]); - $catalogue->setMetadata('foo', ['segment-attributes' => ['state' => 'translated']]); - $catalogue->setMetadata('key', ['segment-attributes' => ['state' => 'translated', 'subState' => 'My Value']]); - - $dumper = new XliffFileDumper(); - - $this->assertStringEqualsFile( - __DIR__.'/../Fixtures/resources-2.0-segment-attributes.xlf', - $dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR', 'xliff_version' => '2.0']) - ); - } - public function testEmptyMetadataNotes() { $catalogue = new MessageCatalogue('en_US'); diff --git a/src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf b/src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf index 7cba2cc09b41e..edda607139eee 100644 --- a/src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf +++ b/src/Symfony/Component/Translation/Tests/Fixtures/resources-2.0-empty-notes.xlf @@ -1,13 +1,13 @@ - + empty notes - + test/path/to/translation/Example.1.html.twig:27 From 5953ff72731c253646da1d31750c4fea59f9441b Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 14 Feb 2025 10:47:54 +0100 Subject: [PATCH 23/44] [TwigBridge] Fix compatibility with Twig 3.21 --- .../Twig/TokenParser/DumpTokenParser.php | 18 +++++++++++++++++- .../Twig/TokenParser/FormThemeTokenParser.php | 10 +++++++--- .../Twig/TokenParser/StopwatchTokenParser.php | 4 +++- .../TransDefaultDomainTokenParser.php | 4 +++- .../Twig/TokenParser/TransTokenParser.php | 12 ++++++++---- 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php index e671f9ba0b7dd..9c12dc23dfba5 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php @@ -14,6 +14,7 @@ use Symfony\Bridge\Twig\Node\DumpNode; use Twig\Node\Expression\Variable\LocalVariable; use Twig\Node\Node; +use Twig\Node\Nodes; use Twig\Token; use Twig\TokenParser\AbstractTokenParser; @@ -34,13 +35,28 @@ public function parse(Token $token): Node { $values = null; if (!$this->parser->getStream()->test(Token::BLOCK_END_TYPE)) { - $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); + $values = method_exists($this->parser, 'parseExpression') ? + $this->parseMultitargetExpression() : + $this->parser->getExpressionParser()->parseMultitargetExpression(); } $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); return new DumpNode(class_exists(LocalVariable::class) ? new LocalVariable(null, $token->getLine()) : $this->parser->getVarName(), $values, $token->getLine(), $this->getTag()); } + private function parseMultitargetExpression(): Node + { + $targets = []; + while (true) { + $targets[] = $this->parser->parseExpression(); + if (!$this->parser->getStream()->nextIf(Token::PUNCTUATION_TYPE, ',')) { + break; + } + } + + return new Nodes($targets); + } + public function getTag(): string { return 'dump'; diff --git a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php index b95a2a05e76a4..c5fc2311e5eec 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php @@ -29,12 +29,16 @@ public function parse(Token $token): Node $lineno = $token->getLine(); $stream = $this->parser->getStream(); - $form = $this->parser->getExpressionParser()->parseExpression(); + $parseExpression = method_exists($this->parser, 'parseExpression') + ? $this->parser->parseExpression(...) + : $this->parser->getExpressionParser()->parseExpression(...); + + $form = $parseExpression(); $only = false; if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) { $this->parser->getStream()->next(); - $resources = $this->parser->getExpressionParser()->parseExpression(); + $resources = $parseExpression(); if ($this->parser->getStream()->nextIf(Token::NAME_TYPE, 'only')) { $only = true; @@ -42,7 +46,7 @@ public function parse(Token $token): Node } else { $resources = new ArrayExpression([], $stream->getCurrent()->getLine()); do { - $resources->addElement($this->parser->getExpressionParser()->parseExpression()); + $resources->addElement($parseExpression()); } while (!$stream->test(Token::BLOCK_END_TYPE)); } diff --git a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php index 324f9d453ac78..c478d9e6d783f 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php @@ -38,7 +38,9 @@ public function parse(Token $token): Node $stream = $this->parser->getStream(); // {% stopwatch 'bar' %} - $name = $this->parser->getExpressionParser()->parseExpression(); + $name = method_exists($this->parser, 'parseExpression') ? + $this->parser->parseExpression() : + $this->parser->getExpressionParser()->parseExpression(); $stream->expect(Token::BLOCK_END_TYPE); diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php index c6d850d07cbf7..a64a2332810e7 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php @@ -25,7 +25,9 @@ final class TransDefaultDomainTokenParser extends AbstractTokenParser { public function parse(Token $token): Node { - $expr = $this->parser->getExpressionParser()->parseExpression(); + $expr = method_exists($this->parser, 'parseExpression') ? + $this->parser->parseExpression() : + $this->parser->getExpressionParser()->parseExpression(); $this->parser->getStream()->expect(Token::BLOCK_END_TYPE); diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index e60263a4a783f..2d17c9da70ab3 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -36,29 +36,33 @@ public function parse(Token $token): Node $vars = new ArrayExpression([], $lineno); $domain = null; $locale = null; + $parseExpression = method_exists($this->parser, 'parseExpression') + ? $this->parser->parseExpression(...) + : $this->parser->getExpressionParser()->parseExpression(...); + if (!$stream->test(Token::BLOCK_END_TYPE)) { if ($stream->test('count')) { // {% trans count 5 %} $stream->next(); - $count = $this->parser->getExpressionParser()->parseExpression(); + $count = $parseExpression(); } if ($stream->test('with')) { // {% trans with vars %} $stream->next(); - $vars = $this->parser->getExpressionParser()->parseExpression(); + $vars = $parseExpression(); } if ($stream->test('from')) { // {% trans from "messages" %} $stream->next(); - $domain = $this->parser->getExpressionParser()->parseExpression(); + $domain = $parseExpression(); } if ($stream->test('into')) { // {% trans into "fr" %} $stream->next(); - $locale = $this->parser->getExpressionParser()->parseExpression(); + $locale = $parseExpression(); } elseif (!$stream->test(Token::BLOCK_END_TYPE)) { throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()); } From 535953ed1a968af30dac4776a8c908236f468c86 Mon Sep 17 00:00:00 2001 From: Raffaele Carelle Date: Thu, 13 Feb 2025 14:50:49 +0100 Subject: [PATCH 24/44] Enable `JSON_PRESERVE_ZERO_FRACTION` in `jsonRequest` method --- src/Symfony/Component/BrowserKit/AbstractBrowser.php | 2 +- .../Component/BrowserKit/Tests/AbstractBrowserTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php index d2a1faead4f67..37ab49d0cb7d1 100644 --- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php +++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php @@ -170,7 +170,7 @@ public function xmlHttpRequest(string $method, string $uri, array $parameters = */ public function jsonRequest(string $method, string $uri, array $parameters = [], array $server = [], bool $changeHistory = true): Crawler { - $content = json_encode($parameters); + $content = json_encode($parameters, \JSON_PRESERVE_ZERO_FRACTION); $this->setServerParameter('CONTENT_TYPE', 'application/json'); $this->setServerParameter('HTTP_ACCEPT', 'application/json'); diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index 2267fca448799..504cc95878ef2 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -67,12 +67,12 @@ public function testXmlHttpRequest() public function testJsonRequest() { $client = $this->getBrowser(); - $client->jsonRequest('GET', 'http://example.com/', ['param' => 1], [], true); + $client->jsonRequest('GET', 'http://example.com/', ['param' => 1, 'float' => 10.0], [], true); $this->assertSame('application/json', $client->getRequest()->getServer()['CONTENT_TYPE']); $this->assertSame('application/json', $client->getRequest()->getServer()['HTTP_ACCEPT']); $this->assertFalse($client->getServerParameter('CONTENT_TYPE', false)); $this->assertFalse($client->getServerParameter('HTTP_ACCEPT', false)); - $this->assertSame('{"param":1}', $client->getRequest()->getContent()); + $this->assertSame('{"param":1,"float":10.0}', $client->getRequest()->getContent()); } public function testGetRequestWithIpAsHttpHost() From d4e8a5cf3f4a318131b3a778cb71b37efdf18f0f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 14 Feb 2025 13:21:59 +0100 Subject: [PATCH 25/44] fix rendering notifier message options --- .../Resources/views/Collector/notifier.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig index 9de8d216e6d1f..ed363f1d92fe2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/notifier.html.twig @@ -151,7 +151,7 @@ {%- if message.getOptions() is null %} {{- '(empty)' }} {%- else %} - {{- message.getOptions()|json_encode(constant('JSON_PRETTY_PRINT')) }} + {{- message.getOptions().toArray()|json_encode(constant('JSON_PRETTY_PRINT')) }} {%- endif %} From 9a98452471f18a8c28f3bb0e2bb2b3182a204b7e Mon Sep 17 00:00:00 2001 From: Tom Kaminski Date: Fri, 14 Feb 2025 09:16:52 -0600 Subject: [PATCH 26/44] Check for null parent Nodes in the case of orphaned branches --- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- .../Tests/AbstractCrawlerTestCase.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index ac5a9833842ff..005a69319263e 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -431,7 +431,7 @@ public function closest(string $selector): ?self $domNode = $this->getNode(0); - while (\XML_ELEMENT_NODE === $domNode->nodeType) { + while (null !== $domNode && \XML_ELEMENT_NODE === $domNode->nodeType) { $node = $this->createSubCrawler($domNode); if ($node->matches($selector)) { return $node; diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php index 97b16b9fe6073..5cdbbbf45870d 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php @@ -1031,6 +1031,29 @@ public function testClosest() $this->assertNull($notFound); } + public function testClosestWithOrphanedNode() + { + $html = <<<'HTML' + + +
+
+
+ + +HTML; + + $crawler = $this->createCrawler($this->getDoctype().$html); + $foo = $crawler->filter('#foo'); + + $fooNode = $foo->getNode(0); + + $fooNode->parentNode->replaceChild($fooNode->ownerDocument->createElement('ol'), $fooNode); + + $body = $foo->closest('body'); + $this->assertNull($body); + } + public function testOuterHtml() { $html = <<<'HTML' From 07e67881b55a3aad72d7c7d9d862d7a114eb998a Mon Sep 17 00:00:00 2001 From: DemigodCode Date: Fri, 14 Feb 2025 23:53:43 +0100 Subject: [PATCH 27/44] fix integration tests --- .github/workflows/integration-tests.yml | 21 ++++-- .../PredisRedisReplicationAdapterTest.php | 2 +- .../Adapter/PredisReplicationAdapterTest.php | 18 ++++- .../PredisTagAwareReplicationAdapterTest.php | 37 ----------- .../Adapter/RedisReplicationAdapterTest.php | 65 ------------------- 5 files changed, 33 insertions(+), 110 deletions(-) delete mode 100644 src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 5c2839d74f818..9ea7e0992d939 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -82,16 +82,25 @@ jobs: REDIS_MASTER_SET: redis_sentinel REDIS_SENTINEL_QUORUM: 1 redis-primary: - image: redis:latest - hostname: redis-primary + image: bitnami/redis:latest ports: - 16381:6379 - + env: + ALLOW_EMPTY_PASSWORD: "yes" + REDIS_REPLICATION_MODE: "master" + options: >- + --name=redis-primary redis-replica: - image: redis:latest + image: bitnami/redis:latest ports: - 16382:6379 - command: redis-server --slaveof redis-primary 6379 + env: + ALLOW_EMPTY_PASSWORD: "yes" + REDIS_REPLICATION_MODE: "slave" + REDIS_MASTER_HOST: redis-primary + REDIS_MASTER_PORT_NUMBER: "6379" + options: >- + --name=redis-replica memcached: image: memcached:1.6.5 ports: @@ -250,7 +259,7 @@ jobs: REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005' REDIS_SENTINEL_HOSTS: 'unreachable-host:26379 localhost:26379 localhost:26379' REDIS_SENTINEL_SERVICE: redis_sentinel - REDIS_REPLICATION_HOSTS: 'localhost:16381 localhost:16382' + REDIS_REPLICATION_HOSTS: 'localhost:16382 localhost:16381' MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01" diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php index 552727740c18b..cda92af8c7a6c 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php @@ -24,6 +24,6 @@ public static function setUpBeforeClass(): void self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.'); } - self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][alias]=master', ['class' => \Predis\Client::class, 'prefix' => 'prefix_']); + self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][role]=master', ['replication' => 'predis', 'class' => \Predis\Client::class, 'prefix' => 'prefix_']); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php index 4add9d5f18c4a..28af1b5b4e27e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php @@ -19,6 +19,22 @@ class PredisReplicationAdapterTest extends AbstractRedisAdapterTestCase public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - self::$redis = new \Predis\Client(array_combine(['host', 'port'], explode(':', getenv('REDIS_HOST')) + [1 => 6379]), ['prefix' => 'prefix_']); + + if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) { + self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.'); + } + + $hosts = explode(' ', getenv('REDIS_REPLICATION_HOSTS')); + $lastArrayKey = array_key_last($hosts); + $hostTable = []; + foreach($hosts as $key => $host) { + $hostInformation = array_combine(['host', 'port'], explode(':', $host)); + if($lastArrayKey === $key) { + $hostInformation['role'] = 'master'; + } + $hostTable[] = $hostInformation; + } + + self::$redis = new \Predis\Client($hostTable, ['replication' => 'predis', 'prefix' => 'prefix_']); } } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php deleted file mode 100644 index 4d8651ce4ceb6..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Adapter; - -use Psr\Cache\CacheItemPoolInterface; -use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; - -/** - * @group integration - */ -class PredisTagAwareReplicationAdapterTest extends PredisReplicationAdapterTest -{ - use TagAwareTestTrait; - - protected function setUp(): void - { - parent::setUp(); - $this->skippedTests['testTagItemExpiry'] = 'Testing expiration slows down the test suite'; - } - - public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface - { - $this->assertInstanceOf(\Predis\Client::class, self::$redis); - $adapter = new RedisTagAwareAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); - - return $adapter; - } -} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php deleted file mode 100644 index e41745057f141..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Adapter; - -use Psr\Cache\CacheItemPoolInterface; -use Symfony\Component\Cache\Adapter\AbstractAdapter; -use Symfony\Component\Cache\Adapter\RedisAdapter; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\Cache\Traits\RedisClusterProxy; - -/** - * @group integration - */ -class RedisReplicationAdapterTest extends AbstractRedisAdapterTestCase -{ - public static function setUpBeforeClass(): void - { - if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) { - self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.'); - } - - self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][alias]=master', ['lazy' => true]); - self::$redis->setOption(\Redis::OPT_PREFIX, 'prefix_'); - } - - public function createCachePool(int $defaultLifetime = 0, ?string $testMethod = null): CacheItemPoolInterface - { - if ('testClearWithPrefix' === $testMethod && \defined('Redis::SCAN_PREFIX')) { - self::$redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_PREFIX); - } - - $this->assertInstanceOf(RedisClusterProxy::class, self::$redis); - $adapter = new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); - - return $adapter; - } - - /** - * @dataProvider provideFailedCreateConnection - */ - public function testFailedCreateConnection(string $dsn) - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Redis connection '); - RedisAdapter::createConnection($dsn); - } - - public static function provideFailedCreateConnection(): array - { - return [ - ['redis://localhost:1234'], - ['redis://foo@localhost?role=master'], - ['redis://localhost/123?role=master'], - ]; - } -} From 0d4a4982e7307979485c06639187087a0fa87852 Mon Sep 17 00:00:00 2001 From: tinect Date: Mon, 17 Feb 2025 22:23:52 +0100 Subject: [PATCH 28/44] [MIME] use address for body at PathHeader --- src/Symfony/Component/Mime/Header/PathHeader.php | 2 +- src/Symfony/Component/Mime/Tests/Header/HeadersTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mime/Header/PathHeader.php b/src/Symfony/Component/Mime/Header/PathHeader.php index 63eb30af01bf8..4b0b7d3955673 100644 --- a/src/Symfony/Component/Mime/Header/PathHeader.php +++ b/src/Symfony/Component/Mime/Header/PathHeader.php @@ -57,6 +57,6 @@ public function getAddress(): Address public function getBodyAsString(): string { - return '<'.$this->address->toString().'>'; + return '<'.$this->address->getEncodedAddress().'>'; } } diff --git a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php index b1892978c1a0b..b0a28fdbf992e 100644 --- a/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php +++ b/src/Symfony/Component/Mime/Tests/Header/HeadersTest.php @@ -346,4 +346,12 @@ public function testSetHeaderParameterNotParameterized() $this->expectException(\LogicException::class); $headers->setHeaderParameter('Content-Disposition', 'name', 'foo'); } + + public function testPathHeaderHasNoName() + { + $headers = new Headers(); + + $headers->addPathHeader('Return-Path', new Address('some@path', 'any ignored name')); + $this->assertSame('', $headers->get('Return-Path')->getBodyAsString()); + } } From b1d5de50bd6cbf24636570017fab5e599677ca83 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 18 Feb 2025 09:43:25 +0100 Subject: [PATCH 29/44] [DoctrineBridge] Fix deprecation with `doctrine/dbal` ^4.3 --- .../Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php index 94becf73b5795..0373417b2c8bb 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; +use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\OneToOne; #[Entity] @@ -21,6 +22,7 @@ class SingleAssociationToIntIdEntity { public function __construct( #[Id, OneToOne(cascade: ['ALL'])] + #[JoinColumn(nullable: false)] protected SingleIntIdNoToStringEntity $entity, #[Column(nullable: true)] From e71a278737e54dfa6efa25e0344808e47eec4123 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 18 Feb 2025 13:36:18 +0100 Subject: [PATCH 30/44] [Validator] Fix incorrect assertion in `WhenTest` --- .../Component/Validator/Tests/Constraints/WhenTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php b/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php index 7e11f0f683746..de13876db6867 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php @@ -89,7 +89,7 @@ public function testAnnotations() [$barConstraint] = $metadata->properties['bar']->getConstraints(); - self::assertInstanceOf(When::class, $fooConstraint); + self::assertInstanceOf(When::class, $barConstraint); self::assertSame('false', $barConstraint->expression); self::assertEquals([ new NotNull([ @@ -161,7 +161,7 @@ public function testAttributes() [$barConstraint] = $metadata->properties['bar']->getConstraints(); - self::assertInstanceOf(When::class, $fooConstraint); + self::assertInstanceOf(When::class, $barConstraint); self::assertSame('false', $barConstraint->expression); self::assertEquals([ new NotNull([ From 9c0213b0d23688c74c09b2d5586fde96c12afa64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20M=C3=B6nch?= Date: Tue, 18 Feb 2025 16:35:34 +0100 Subject: [PATCH 31/44] [Semaphore] allow redis cluster/sentinel dsn --- .../Semaphore/Store/StoreFactory.php | 4 +- .../Tests/Store/StoreFactoryTest.php | 49 ++++++------------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/Symfony/Component/Semaphore/Store/StoreFactory.php b/src/Symfony/Component/Semaphore/Store/StoreFactory.php index 639298bab2453..97fe89749e592 100644 --- a/src/Symfony/Component/Semaphore/Store/StoreFactory.php +++ b/src/Symfony/Component/Semaphore/Store/StoreFactory.php @@ -35,8 +35,8 @@ public static function createStore(#[\SensitiveParameter] object|string $connect case !\is_string($connection): throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection::class)); - case str_starts_with($connection, 'redis://'): - case str_starts_with($connection, 'rediss://'): + case str_starts_with($connection, 'redis:'): + case str_starts_with($connection, 'rediss:'): if (!class_exists(AbstractAdapter::class)) { throw new InvalidArgumentException('Unsupported Redis DSN. Try running "composer require symfony/cache".'); } diff --git a/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php b/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php index 23d01346a8b0b..f69e7161e4677 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/StoreFactoryTest.php @@ -12,54 +12,37 @@ namespace Symfony\Component\Semaphore\Tests\Store; use PHPUnit\Framework\TestCase; -use Symfony\Component\Cache\Traits\RedisProxy; use Symfony\Component\Semaphore\Store\RedisStore; use Symfony\Component\Semaphore\Store\StoreFactory; /** * @author Jérémy Derussé - * - * @requires extension redis */ class StoreFactoryTest extends TestCase { - public function testCreateRedisStore() + /** + * @dataProvider validConnections + */ + public function testCreateStore($connection, string $expectedStoreClass) { - $store = StoreFactory::createStore($this->createMock(\Redis::class)); + $store = StoreFactory::createStore($connection); - $this->assertInstanceOf(RedisStore::class, $store); + $this->assertInstanceOf($expectedStoreClass, $store); } - public function testCreateRedisProxyStore() + public static function validConnections(): \Generator { - if (!class_exists(RedisProxy::class)) { - $this->markTestSkipped(); - } + yield [new \Predis\Client(), RedisStore::class]; - $store = StoreFactory::createStore($this->createMock(RedisProxy::class)); - - $this->assertInstanceOf(RedisStore::class, $store); - } - - public function testCreateRedisAsDsnStore() - { - if (!class_exists(RedisProxy::class)) { - $this->markTestSkipped(); + if (class_exists(\Redis::class)) { + yield [new \Redis(), RedisStore::class]; } - - $store = StoreFactory::createStore('redis://localhost'); - - $this->assertInstanceOf(RedisStore::class, $store); - } - - public function testCreatePredisStore() - { - if (!class_exists(\Predis\Client::class)) { - $this->markTestSkipped(); + if (class_exists(\Redis::class) && class_exists(AbstractAdapter::class)) { + yield ['redis://localhost', RedisStore::class]; + yield ['redis://localhost?lazy=1', RedisStore::class]; + yield ['redis://localhost?redis_cluster=1', RedisStore::class]; + yield ['redis://localhost?redis_cluster=1&lazy=1', RedisStore::class]; + yield ['redis:?host[localhost]&host[localhost:6379]&redis_cluster=1', RedisStore::class]; } - - $store = StoreFactory::createStore(new \Predis\Client()); - - $this->assertInstanceOf(RedisStore::class, $store); } } From b188dccd491e150b5247b5add6a91dcb2c76287d Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 18 Feb 2025 17:53:06 +0100 Subject: [PATCH 32/44] [psalm] ensureOverrideAttribute="false" --- psalm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/psalm.xml b/psalm.xml index a21be22fe248f..86491b32709c7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -10,6 +10,7 @@ findUnusedBaselineEntry="false" findUnusedCode="false" findUnusedIssueHandlerSuppression="false" + ensureOverrideAttribute="false" > From 5c2ebfba1ce08d9e5d562fde9a6bd6aa8492bd0c Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Wed, 19 Feb 2025 14:12:02 +0100 Subject: [PATCH 33/44] [Validator] Synchronize IBAN formats --- .../Component/Validator/Constraints/IbanValidator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 11619efd8ec7a..13d91315b5dea 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -69,7 +69,7 @@ class IbanValidator extends ConstraintValidator 'DK' => 'DK\d{2}\d{4}\d{9}\d{1}', // Denmark 'DO' => 'DO\d{2}[\dA-Z]{4}\d{20}', // Dominican Republic 'DZ' => 'DZ\d{2}\d{22}', // Algeria - 'EE' => 'EE\d{2}\d{2}\d{2}\d{11}\d{1}', // Estonia + 'EE' => 'EE\d{2}\d{2}\d{14}', // Estonia 'EG' => 'EG\d{2}\d{4}\d{4}\d{17}', // Egypt 'ES' => 'ES\d{2}\d{4}\d{4}\d{1}\d{1}\d{10}', // Spain 'FI' => 'FI\d{2}\d{3}\d{11}', // Finland @@ -126,7 +126,7 @@ class IbanValidator extends ConstraintValidator 'MZ' => 'MZ\d{2}\d{21}', // Mozambique 'NC' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France 'NE' => 'NE\d{2}[A-Z]{2}\d{22}', // Niger - 'NI' => 'NI\d{2}[A-Z]{4}\d{24}', // Nicaragua + 'NI' => 'NI\d{2}[A-Z]{4}\d{20}', // Nicaragua 'NL' => 'NL\d{2}[A-Z]{4}\d{10}', // Netherlands (The) 'NO' => 'NO\d{2}\d{4}\d{6}\d{1}', // Norway 'OM' => 'OM\d{2}\d{3}[\dA-Z]{16}', // Oman @@ -150,7 +150,7 @@ class IbanValidator extends ConstraintValidator 'SM' => 'SM\d{2}[A-Z]{1}\d{5}\d{5}[\dA-Z]{12}', // San Marino 'SN' => 'SN\d{2}[A-Z]{2}\d{22}', // Senegal 'SO' => 'SO\d{2}\d{4}\d{3}\d{12}', // Somalia - 'ST' => 'ST\d{2}\d{4}\d{4}\d{11}\d{2}', // Sao Tome and Principe + 'ST' => 'ST\d{2}\d{8}\d{11}\d{2}', // Sao Tome and Principe 'SV' => 'SV\d{2}[A-Z]{4}\d{20}', // El Salvador 'TD' => 'TD\d{2}\d{23}', // Chad 'TF' => 'FR\d{2}\d{5}\d{5}[\dA-Z]{11}\d{2}', // France From 124087b405520e7446dd79426035e16a099f6b6d Mon Sep 17 00:00:00 2001 From: Artem Lopata Date: Wed, 19 Feb 2025 12:07:11 +0100 Subject: [PATCH 34/44] [DependencyInjection] Defer check for circular references instead of skipping them. --- .../Compiler/CheckCircularReferencesPass.php | 35 +++++++++++++------ .../CheckCircularReferencesPassTest.php | 18 ++++++++++ 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php index 1fb8935c3e102..a4a8ce368e51d 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php @@ -28,6 +28,7 @@ class CheckCircularReferencesPass implements CompilerPassInterface { private array $currentPath; private array $checkedNodes; + private array $checkedLazyNodes; /** * Checks the ContainerBuilder object for circular references. @@ -59,22 +60,36 @@ private function checkOutEdges(array $edges): void $node = $edge->getDestNode(); $id = $node->getId(); - if (empty($this->checkedNodes[$id])) { - // Don't check circular references for lazy edges - if (!$node->getValue() || (!$edge->isLazy() && !$edge->isWeak())) { - $searchKey = array_search($id, $this->currentPath); - $this->currentPath[] = $id; + if (!empty($this->checkedNodes[$id])) { + continue; + } + + $isLeaf = !!$node->getValue(); + $isConcrete = !$edge->isLazy() && !$edge->isWeak(); + + // Skip already checked lazy services if they are still lazy. Will not gain any new information. + if (!empty($this->checkedLazyNodes[$id]) && (!$isLeaf || !$isConcrete)) { + continue; + } - if (false !== $searchKey) { - throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey)); - } + // Process concrete references, otherwise defer check circular references for lazy edges. + if (!$isLeaf || $isConcrete) { + $searchKey = array_search($id, $this->currentPath); + $this->currentPath[] = $id; - $this->checkOutEdges($node->getOutEdges()); + if (false !== $searchKey) { + throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey)); } + $this->checkOutEdges($node->getOutEdges()); + $this->checkedNodes[$id] = true; - array_pop($this->currentPath); + unset($this->checkedLazyNodes[$id]); + } else { + $this->checkedLazyNodes[$id] = true; } + + array_pop($this->currentPath); } } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php index c9bcb10878bec..20a0a7b5a8d5a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php @@ -13,9 +13,12 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; +use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; +use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass; use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass; use Symfony\Component\DependencyInjection\Compiler\Compiler; +use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; use Symfony\Component\DependencyInjection\Reference; @@ -126,6 +129,21 @@ public function testProcessIgnoresLazyServices() $this->addToAssertionCount(1); } + public function testProcessDefersLazyServices() + { + $container = new ContainerBuilder(); + + $container->register('a')->addArgument(new ServiceLocatorArgument(new TaggedIteratorArgument('tag', needsIndexes: true))); + $container->register('b')->addArgument(new Reference('c'))->addTag('tag'); + $container->register('c')->addArgument(new Reference('b')); + + (new ServiceLocatorTagPass())->process($container); + + $this->expectException(ServiceCircularReferenceException::class); + + $this->process($container); + } + public function testProcessIgnoresIteratorArguments() { $container = new ContainerBuilder(); From e737911a9c43e38da4d07aeeb76e4de529c2986f Mon Sep 17 00:00:00 2001 From: Alexander Dmitryuk Date: Fri, 21 Feb 2025 09:36:22 +0000 Subject: [PATCH 35/44] [Stopwatch] Fix StopWatchEvent never throws InvalidArgumentException --- src/Symfony/Component/Stopwatch/StopwatchEvent.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/Stopwatch/StopwatchEvent.php b/src/Symfony/Component/Stopwatch/StopwatchEvent.php index 1a85d80cae92f..782307b5a5e8f 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchEvent.php +++ b/src/Symfony/Component/Stopwatch/StopwatchEvent.php @@ -39,8 +39,6 @@ class StopwatchEvent * @param string|null $category The event category or null to use the default * @param bool $morePrecision If true, time is stored as float to keep the original microsecond precision * @param string|null $name The event name or null to define the name as default - * - * @throws \InvalidArgumentException When the raw time is not valid */ public function __construct(float $origin, ?string $category = null, bool $morePrecision = false, ?string $name = null) { @@ -207,8 +205,6 @@ protected function getNow(): float /** * Formats a time. - * - * @throws \InvalidArgumentException When the raw time is not valid */ private function formatTime(float $time): float { From 04ff18d41957935efbd259e5539cc0bdcb1b6ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Hlavat=C3=BD?= <107676055+Pepperoni1337@users.noreply.github.com> Date: Sun, 23 Feb 2025 11:21:59 +0100 Subject: [PATCH 36/44] Update GetSetMethodNormalizer.php Fix: Add length check for setter method detection --- .../Component/Serializer/Normalizer/GetSetMethodNormalizer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 951005545f5e9..3cb9b992bd8db 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -118,6 +118,7 @@ private function isSetMethod(\ReflectionMethod $method): bool return !$method->isStatic() && !$method->getAttributes(Ignore::class) && 0 < $method->getNumberOfParameters() + && 3 < \strlen($method->name) && str_starts_with($method->name, 'set') && !ctype_lower($method->name[3]) ; From 00525422a2742e239823701918fdff6c72ccf84a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 24 Feb 2025 11:00:12 +0100 Subject: [PATCH 37/44] skip failing Semaphore component tests on GitHub Actions with PHP 8.5 --- .../Component/Semaphore/Tests/Store/RelayStoreTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Semaphore/Tests/Store/RelayStoreTest.php b/src/Symfony/Component/Semaphore/Tests/Store/RelayStoreTest.php index a7db8f8f10cf1..aeaf8c3d451ce 100644 --- a/src/Symfony/Component/Semaphore/Tests/Store/RelayStoreTest.php +++ b/src/Symfony/Component/Semaphore/Tests/Store/RelayStoreTest.php @@ -25,6 +25,10 @@ protected function setUp(): void public static function setUpBeforeClass(): void { + if (\PHP_VERSION_ID <= 80500 && isset($_SERVER['GITHUB_ACTIONS'])) { + self::markTestSkipped('Test segfaults on PHP 8.5'); + } + try { new Relay(...explode(':', getenv('REDIS_HOST'))); } catch (\Relay\Exception $e) { From 83b0491341f219420b59744aa8cad106ff867058 Mon Sep 17 00:00:00 2001 From: iraouf Date: Sun, 23 Feb 2025 01:24:22 +0100 Subject: [PATCH 38/44] [Mailer][Postmark] Set CID for attachments when it exists --- .../Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php index ea5ac37671c12..1ed5e5c6bc644 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php @@ -147,7 +147,7 @@ private function getAttachments(Email $email): array ]; if ('inline' === $disposition) { - $att['ContentID'] = 'cid:'.$filename; + $att['ContentID'] = 'cid:'.($attachment->hasContentId() ? $attachment->getContentId() : $filename); } $attachments[] = $att; From a50880b0675b941a945f388b82a90f77239e975d Mon Sep 17 00:00:00 2001 From: fabi Date: Fri, 14 Feb 2025 20:13:35 +0100 Subject: [PATCH 39/44] [Mailer] fix multiple transports default injection --- .../DependencyInjection/FrameworkExtension.php | 1 - .../Bundle/FrameworkBundle/Resources/config/mailer.php | 5 +---- .../Tests/DependencyInjection/FrameworkExtensionTestCase.php | 3 +-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index f918eafbb209c..3a518bee7959e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2660,7 +2660,6 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co } $transports = $config['dsn'] ? ['main' => $config['dsn']] : $config['transports']; $container->getDefinition('mailer.transports')->setArgument(0, $transports); - $container->getDefinition('mailer.default_transport')->setArgument(0, current($transports)); $mailer = $container->getDefinition('mailer.mailer'); if (false === $messageBus = $config['message_bus']) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php index 9eb545ca268ea..7a3a95739b0f2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/mailer.php @@ -46,10 +46,7 @@ ]) ->set('mailer.default_transport', TransportInterface::class) - ->factory([service('mailer.transport_factory'), 'fromString']) - ->args([ - abstract_arg('env(MAILER_DSN)'), - ]) + ->alias('mailer.default_transport', 'mailer.transports') ->alias(TransportInterface::class, 'mailer.default_transport') ->set('mailer.messenger.message_handler', MessageHandler::class) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index c891ec143fa13..7f94b83ce58c4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -2103,8 +2103,7 @@ public function testMailer(string $configFile, array $expectedTransports, array $this->assertTrue($container->hasAlias('mailer')); $this->assertTrue($container->hasDefinition('mailer.transports')); $this->assertSame($expectedTransports, $container->getDefinition('mailer.transports')->getArgument(0)); - $this->assertTrue($container->hasDefinition('mailer.default_transport')); - $this->assertSame(current($expectedTransports), $container->getDefinition('mailer.default_transport')->getArgument(0)); + $this->assertTrue($container->hasAlias('mailer.default_transport')); $this->assertTrue($container->hasDefinition('mailer.envelope_listener')); $l = $container->getDefinition('mailer.envelope_listener'); $this->assertSame('sender@example.org', $l->getArgument(0)); From 34c7e6f1902842bee641010916f138535800c73d Mon Sep 17 00:00:00 2001 From: Wolfgang Klinger Date: Thu, 12 Dec 2024 10:44:13 +0100 Subject: [PATCH 40/44] [Messenger] Filter out non-consumable receivers when registering `ConsumeMessagesCommand` --- .../FrameworkExtension.php | 12 +++++--- .../Command/ConsumeMessagesCommand.php | 6 ++++ .../DependencyInjection/MessengerPass.php | 6 +++- .../DependencyInjection/MessengerPassTest.php | 29 +++++++++++++++++++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index f918eafbb209c..61f68c198c447 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2282,13 +2282,17 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder $transportRateLimiterReferences = []; foreach ($config['transports'] as $name => $transport) { $serializerId = $transport['serializer'] ?? 'messenger.default_serializer'; + $tags = [ + 'alias' => $name, + 'is_failure_transport' => \in_array($name, $failureTransports), + ]; + if (str_starts_with($transport['dsn'], 'sync://')) { + $tags['is_consumable'] = false; + } $transportDefinition = (new Definition(TransportInterface::class)) ->setFactory([new Reference('messenger.transport_factory'), 'createTransport']) ->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)]) - ->addTag('messenger.receiver', [ - 'alias' => $name, - 'is_failure_transport' => \in_array($name, $failureTransports), - ]) + ->addTag('messenger.receiver', $tags) ; $container->setDefinition($transportId = 'messenger.transport.'.$name, $transportDefinition); $senderAliases[$name] = $transportId; diff --git a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php index a959c2baee911..7aa8752f5616c 100644 --- a/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php +++ b/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php @@ -136,6 +136,12 @@ protected function interact(InputInterface $input, OutputInterface $output) $io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output); if ($this->receiverNames && !$input->getArgument('receivers')) { + if (1 === \count($this->receiverNames)) { + $input->setArgument('receivers', $this->receiverNames); + + return; + } + $io->block('Which transports/receivers do you want to consume?', null, 'fg=white;bg=blue', ' ', true); $io->writeln('Choose which receivers you want to consume messages from in order of priority.'); diff --git a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php index 032ec76efa5e2..98ad205838bf9 100644 --- a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php +++ b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php @@ -274,6 +274,7 @@ private function registerReceivers(ContainerBuilder $container, array $busIds): } } + $consumableReceiverNames = []; foreach ($container->findTaggedServiceIds('messenger.receiver') as $id => $tags) { $receiverClass = $this->getServiceClass($container, $id); if (!is_subclass_of($receiverClass, ReceiverInterface::class)) { @@ -289,6 +290,9 @@ private function registerReceivers(ContainerBuilder $container, array $busIds): $failureTransportsMap[$tag['alias']] = $receiverMapping[$id]; } } + if (!isset($tag['is_consumable']) || $tag['is_consumable'] !== false) { + $consumableReceiverNames[] = $tag['alias'] ?? $id; + } } } @@ -314,7 +318,7 @@ private function registerReceivers(ContainerBuilder $container, array $busIds): $consumeCommandDefinition->replaceArgument(0, new Reference('messenger.routable_message_bus')); } - $consumeCommandDefinition->replaceArgument(4, array_values($receiverNames)); + $consumeCommandDefinition->replaceArgument(4, $consumableReceiverNames); try { $consumeCommandDefinition->replaceArgument(6, $busIds); } catch (OutOfBoundsException) { diff --git a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php index 13d18993eb97c..e75117e5573b0 100644 --- a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php +++ b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; +use Symfony\Component\Console\Command\Command; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\AttributeAutoconfigurationPass; use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass; @@ -506,6 +507,34 @@ public function testItSetsTheReceiverNamesOnTheSetupTransportsCommand() $this->assertSame(['amqp', 'dummy'], $container->getDefinition('console.command.messenger_setup_transports')->getArgument(1)); } + public function testOnlyConsumableTransportsAreAddedToConsumeCommand() + { + $container = new ContainerBuilder(); + + $container->register('messenger.transport.async', DummyReceiver::class) + ->addTag('messenger.receiver', ['alias' => 'async']); + $container->register('messenger.transport.sync', DummyReceiver::class) + ->addTag('messenger.receiver', ['alias' => 'sync', 'is_consumable' => false]); + $container->register('messenger.receiver_locator', ServiceLocator::class) + ->setArguments([[]]); + + $container->register('console.command.messenger_consume_messages', Command::class) + ->setArguments([ + null, + null, + null, + null, + [], + ]); + + (new MessengerPass())->process($container); + + $this->assertSame( + ['async'], + $container->getDefinition('console.command.messenger_consume_messages')->getArgument(4) + ); + } + /** * @group legacy */ From 3686ba153e041f3b0361278ab02f1bd10b1a8e09 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Wed, 26 Feb 2025 09:12:21 +0100 Subject: [PATCH 41/44] [Cache] Fix `PredisAdapter` tests --- .../Cache/Tests/Adapter/PredisAdapterTest.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php index 5fdd35cafb68c..d9afd85a8e1f6 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisAdapterTest.php @@ -36,6 +36,8 @@ public function testCreateConnection() $this->assertInstanceOf(StreamConnection::class, $connection); $redisHost = explode(':', $redisHost); + $connectionParameters = $connection->getParameters()->toArray(); + $params = [ 'scheme' => 'tcp', 'host' => $redisHost[0], @@ -46,7 +48,12 @@ public function testCreateConnection() 'tcp_nodelay' => true, 'database' => '1', ]; - $this->assertSame($params, $connection->getParameters()->toArray()); + + if (isset($connectionParameters['conn_uid'])) { + $params['conn_uid'] = $connectionParameters['conn_uid']; // if present, the value cannot be predicted + } + + $this->assertSame($params, $connectionParameters); } public function testCreateSslConnection() @@ -60,6 +67,8 @@ public function testCreateSslConnection() $this->assertInstanceOf(StreamConnection::class, $connection); $redisHost = explode(':', $redisHost); + $connectionParameters = $connection->getParameters()->toArray(); + $params = [ 'scheme' => 'tls', 'host' => $redisHost[0], @@ -71,7 +80,12 @@ public function testCreateSslConnection() 'tcp_nodelay' => true, 'database' => '1', ]; - $this->assertSame($params, $connection->getParameters()->toArray()); + + if (isset($connectionParameters['conn_uid'])) { + $params['conn_uid'] = $connectionParameters['conn_uid']; // if present, the value cannot be predicted + } + + $this->assertSame($params, $connectionParameters); } public function testAclUserPasswordAuth() From 4892b8cc6bfdf239cd34e420c87336cdba48294f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 26 Feb 2025 11:51:06 +0100 Subject: [PATCH 42/44] Update CHANGELOG for 6.4.19 --- CHANGELOG-6.4.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGELOG-6.4.md b/CHANGELOG-6.4.md index 883cd3cd7dd62..0640c9486abb1 100644 --- a/CHANGELOG-6.4.md +++ b/CHANGELOG-6.4.md @@ -7,6 +7,35 @@ in 6.4 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v6.4.0...v6.4.1 +* 6.4.19 (2025-02-26) + + * bug #59198 [Messenger] Filter out non-consumable receivers when registering `ConsumeMessagesCommand` (wazum) + * bug #59781 [Mailer] fix multiple transports default injection (fkropfhamer) + * bug #59836 [Mailer][Postmark] Set CID for attachments when it exists (IssamRaouf) + * bug #59840 Fix PHP warning in GetSetMethodNormalizer when a "set()" method is defined (Pepperoni1337) + * bug #59810 [DependencyInjection] Defer check for circular references instead of skipping them (biozshock) + * bug #59811 [Validator] Synchronize IBAN formats (alexandre-daubois) + * bug #59796 [Mime] use address for body at `PathHeader` (tinect) + * bug #59803 [Semaphore] allow redis cluster/sentinel dsn (smoench) + * bug #59779 [DomCrawler] Bug #43921 Check for null parent nodes in the case of orphaned branches (ttk) + * bug #59776 [WebProfilerBundle] fix rendering notifier message options (xabbuh) + * bug #59769 Enable `JSON_PRESERVE_ZERO_FRACTION` in `jsonRequest` method (raffaelecarelle) + * bug #59774 [TwigBridge] Fix compatibility with Twig 3.21 (alexandre-daubois) + * bug #59761 [VarExporter] Fix lazy objects with hooked properties (nicolas-grekas) + * bug #59763 [HttpClient] Don't send any default content-type when the body is empty (nicolas-grekas) + * bug #59747 [Translation] check empty notes (davidvancl) + * bug #59751 [Cache] Tests for Redis Replication with cache (DemigodCode) + * bug #59752 [BrowserKit] Fix submitting forms with empty file fields (nicolas-grekas) + * bug #59033 [WebProfilerBundle] Fix interception for non conventional redirects (Huluti) + * bug #59713 [DependencyInjection] Do not preload functions (biozshock) + * bug #59723 [DependencyInjection] Fix cloned lazy services not sharing their dependencies when dumped with PhpDumper (pvandommelen) + * bug #59727 [HttpClient] Fix activity tracking leading to negative timeout errors (nicolas-grekas) + * bug #59262 [DependencyInjection] Fix env default processor with scalar node (tBibaut) + * bug #59640 [Security] Return null instead of empty username to fix deprecation notice (phasdev) + * bug #59596 [Mime] use `isRendered` method to ensure we can avoid rendering an email twice (walva) + * bug #59689 [HttpClient] Fix buffering AsyncResponse with no passthru (nicolas-grekas) + * bug #59654 [HttpClient] Fix uploading files > 2GB (nicolas-grekas) + * 6.4.18 (2025-01-29) * bug #58889 [Serializer] Handle default context in Serializer (Valmonzo) From 45c7fd3465dcc433e7bdbeae77ec2d3c69f3d9ce Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 26 Feb 2025 11:51:35 +0100 Subject: [PATCH 43/44] Update CONTRIBUTORS for 6.4.19 --- CONTRIBUTORS.md | 53 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8af7f51d72c7d..f8902ba18f029 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -53,9 +53,9 @@ The Symfony Connect username in parenthesis allows to get more information - Mathieu Lechat (mat_the_cat) - Mathias Arlaud (mtarld) - Simon André (simonandre) + - Vincent Langlet (deviling) - Matthias Pigulla (mpdude) - Gabriel Ostrolucký (gadelat) - - Vincent Langlet (deviling) - Jonathan Wage (jwage) - Valentin Udaltsov (vudaltsov) - Grégoire Paris (greg0ire) @@ -73,9 +73,9 @@ The Symfony Connect username in parenthesis allows to get more information - Titouan Galopin (tgalopin) - Pierre du Plessis (pierredup) - David Maicher (dmaicher) + - Dariusz Ruminski - Tomasz Kowalczyk (thunderer) - Bulat Shakirzyanov (avalanche123) - - Dariusz Ruminski - Iltar van der Berg - Miha Vrhovnik (mvrhov) - Gary PEGEOT (gary-p) @@ -101,6 +101,7 @@ The Symfony Connect username in parenthesis allows to get more information - Tomas Norkūnas (norkunas) - Christian Raue - Eric Clemmons (ericclemmons) + - Hubert Lenoir (hubert_lenoir) - Denis (yethee) - Alex Pott - Michel Weimerskirch (mweimerskirch) @@ -110,7 +111,6 @@ The Symfony Connect username in parenthesis allows to get more information - Frank A. Fiebig (fafiebig) - Baldini - Fran Moreno (franmomu) - - Hubert Lenoir (hubert_lenoir) - Charles Sarrazin (csarrazi) - Henrik Westphal (snc) - Dariusz Górecki (canni) @@ -135,6 +135,7 @@ The Symfony Connect username in parenthesis allows to get more information - John Wards (johnwards) - Yanick Witschi (toflar) - Antoine Hérault (herzult) + - Valtteri R (valtzu) - Konstantin.Myakshin - Jeroen Spee (jeroens) - Arnaud Le Blanc (arnaud-lb) @@ -144,7 +145,6 @@ The Symfony Connect username in parenthesis allows to get more information - Tac Tacelosky (tacman1123) - gnito-org - Tim Nagel (merk) - - Valtteri R (valtzu) - Chris Wilkinson (thewilkybarkid) - Jérôme Vasseur (jvasseur) - Peter Kokot (peterkokot) @@ -194,6 +194,7 @@ The Symfony Connect username in parenthesis allows to get more information - Niels Keurentjes (curry684) - OGAWA Katsuhiro (fivestar) - Jhonny Lidfors (jhonne) + - Florent Morselli (spomky_) - Juti Noppornpitak (shiroyuki) - Gregor Harlan (gharlan) - Anthony MARTIN @@ -206,6 +207,7 @@ The Symfony Connect username in parenthesis allows to get more information - Thomas Landauer (thomas-landauer) - Arnaud Kleinpeter (nanocom) - Guilherme Blanco (guilhermeblanco) + - David Prévot (taffit) - Saif Eddin Gmati (azjezz) - Farhad Safarov (safarov) - SpacePossum @@ -217,8 +219,6 @@ The Symfony Connect username in parenthesis allows to get more information - Rafael Dohms (rdohms) - Roman Martinuk (a2a4) - jwdeitch - - David Prévot (taffit) - - Florent Morselli (spomky_) - Jérôme Parmentier (lctrs) - Ahmed TAILOULOUTE (ahmedtai) - Simon Berger @@ -317,6 +317,7 @@ The Symfony Connect username in parenthesis allows to get more information - Mathieu Lemoine (lemoinem) - Christian Schmidt - Andreas Hucks (meandmymonkey) + - Artem Lopata - Indra Gunawan (indragunawan) - Noel Guilbert (noel) - Bastien Jaillot (bastnic) @@ -352,6 +353,7 @@ The Symfony Connect username in parenthesis allows to get more information - John Kary (johnkary) - Võ Xuân Tiến (tienvx) - fd6130 (fdtvui) + - Antonio J. García Lagar (ajgarlag) - Priyadi Iman Nurcahyo (priyadi) - Alan Poulain (alanpoulain) - Oleg Andreyev (oleg.andreyev) @@ -388,6 +390,7 @@ The Symfony Connect username in parenthesis allows to get more information - Dariusz - Daniel Gorgan - Francois Zaninotto + - Aurélien Pillevesse (aurelienpillevesse) - Daniel Tschinder - Christian Schmidt - Alexander Kotynia (olden) @@ -395,7 +398,6 @@ The Symfony Connect username in parenthesis allows to get more information - Manuel Reinhard (sprain) - Zan Baldwin (zanbaldwin) - Tim Goudriaan (codedmonkey) - - Antonio J. García Lagar (ajgarlag) - BoShurik - Quentin Devos - Adam Prager (padam87) @@ -409,7 +411,6 @@ The Symfony Connect username in parenthesis allows to get more information - Sylvain Fabre (sylfabre) - Xavier Perez - Arjen Brouwer (arjenjb) - - Artem Lopata - Patrick McDougle (patrick-mcdougle) - Arnt Gulbrandsen - Michel Roca (mroca) @@ -460,7 +461,6 @@ The Symfony Connect username in parenthesis allows to get more information - renanbr - Sébastien Lavoie (lavoiesl) - Alex Rock (pierstoval) - - Aurélien Pillevesse (aurelienpillevesse) - Matthieu Lempereur (mryamous) - Wodor Wodorski - Beau Simensen (simensen) @@ -514,6 +514,7 @@ The Symfony Connect username in parenthesis allows to get more information - Ismael Ambrosi (iambrosi) - Craig Duncan (duncan3dc) - Emmanuel BORGES + - Mathieu Rochette (mathroc) - Karoly Negyesi (chx) - Aurelijus Valeiša (aurelijus) - Jan Decavele (jandc) @@ -540,6 +541,7 @@ The Symfony Connect username in parenthesis allows to get more information - Ahmed Raafat - Philippe Segatori - Thibaut Cheymol (tcheymol) + - Raffaele Carelle - Erin Millard - Matthew Lewinski (lewinski) - Islam Israfilov (islam93) @@ -628,7 +630,6 @@ The Symfony Connect username in parenthesis allows to get more information - Saif Eddin G - Endre Fejes - Tobias Naumann (tna) - - Mathieu Rochette (mathroc) - Daniel Beyer - Ivan Sarastov (isarastov) - flack (flack) @@ -674,8 +675,10 @@ The Symfony Connect username in parenthesis allows to get more information - Benjamin (yzalis) - Jeanmonod David (jeanmonod) - Webnet team (webnet) + - Christian Gripp (core23) - Tobias Bönner - Nicolas Rigaud + - PHAS Developer - Ben Ramsey (ramsey) - Berny Cantos (xphere81) - Antonio Jose Cerezo (ajcerezo) @@ -692,7 +695,6 @@ The Symfony Connect username in parenthesis allows to get more information - Neil Peyssard (nepey) - Niklas Fiekas - Mark Challoner (markchalloner) - - Raffaele Carelle - Andreas Hennings - Markus Bachmann (baachi) - Gunnstein Lye (glye) @@ -755,6 +757,7 @@ The Symfony Connect username in parenthesis allows to get more information - Arnaud POINTET (oipnet) - Tristan Pouliquen - Miro Michalicka + - Hans Mackowiak - M. Vondano - Dominik Zogg - Maximilian Zumbansen @@ -948,7 +951,6 @@ The Symfony Connect username in parenthesis allows to get more information - Paul Oms - James Hemery - wuchen90 - - PHAS Developer - Wouter van der Loop (toppy-hennie) - Ninos - julien57 @@ -991,6 +993,7 @@ The Symfony Connect username in parenthesis allows to get more information - Noémi Salaün (noemi-salaun) - Sinan Eldem (sineld) - Gennady Telegin + - Benedikt Lenzen (demigodcode) - ampaze - Alexandre Dupuy (satchette) - Michel Hunziker @@ -1224,6 +1227,7 @@ The Symfony Connect username in parenthesis allows to get more information - Besnik Br - Issam Raouf (iraouf) - Simon Mönch + - Valmonzo - Sherin Bloemendaal - Jose Gonzalez - Jonathan (jlslew) @@ -1279,6 +1283,7 @@ The Symfony Connect username in parenthesis allows to get more information - Alexander Grimalovsky (flying) - Andrew Hilobok (hilobok) - Noah Heck (myesain) + - Sébastien JEAN (sebastien76) - Christian Soronellas (theunic) - Max Baldanza - Volodymyr Panivko @@ -1340,7 +1345,6 @@ The Symfony Connect username in parenthesis allows to get more information - James Michael DuPont - Tinjo Schöni - Carlos Buenosvinos (carlosbuenosvinos) - - Christian Gripp (core23) - Jake (jakesoft) - Rustam Bakeev (nommyde) - Vincent CHALAMON @@ -1548,8 +1552,10 @@ The Symfony Connect username in parenthesis allows to get more information - Guillaume Gammelin - Valérian Galliat - Sorin Pop (sorinpop) + - Elías Fernández - d-ph - Stewart Malik + - Frank Schulze (xit) - Renan Taranto (renan-taranto) - Ninos Ego - Samael tomas @@ -1635,6 +1641,7 @@ The Symfony Connect username in parenthesis allows to get more information - Michael H. Arieli - Miloš Milutinović - Jitendra Adhikari (adhocore) + - Kevin Jansen - Nicolas Martin (cocorambo) - Tom Panier (neemzy) - Fred Cox @@ -1650,6 +1657,7 @@ The Symfony Connect username in parenthesis allows to get more information - Adoni Pavlakis (adoni) - Nicolas Le Goff (nlegoff) - Maarten Nusteling (nusje2000) + - Peter van Dommelen - Anne-Sophie Bachelard - Gordienko Vladislav - Ahmed EBEN HASSINE (famas23) @@ -1762,6 +1770,7 @@ The Symfony Connect username in parenthesis allows to get more information - Asil Barkin Elik (asilelik) - Bhujagendra Ishaya - Guido Donnari + - Jérôme Dumas - Mert Simsek (mrtsmsk0) - Lin Clark - Christophe Meneses (c77men) @@ -1802,6 +1811,7 @@ The Symfony Connect username in parenthesis allows to get more information - Dominic Luidold - Piotr Antosik (antek88) - Nacho Martin (nacmartin) + - Thomas Bibaut - Thibaut Chieux - mwos - Aydin Hassan @@ -1857,7 +1867,6 @@ The Symfony Connect username in parenthesis allows to get more information - Mikkel Paulson - Michał Strzelecki - Bert Ramakers - - Hans Mackowiak - Hugo Fonseca (fonsecas72) - Marc Duboc (icemad) - uncaught @@ -1942,11 +1951,13 @@ The Symfony Connect username in parenthesis allows to get more information - Joas Schilling - Ener-Getick - Markus Thielen + - Peter Trebaticky - Moza Bogdan (bogdan_moza) - Viacheslav Sychov - Nicolas Sauveur (baishu) - Helmut Hummel (helhum) - Matt Brunt + - David Vancl - Carlos Ortega Huetos - Péter Buri (burci) - Evgeny Efimov (edefimov) @@ -1982,10 +1993,14 @@ The Symfony Connect username in parenthesis allows to get more information - rchoquet - v.shevelev - rvoisin + - Dan Brown - gitlost - Taras Girnyk + - Simon Mönch + - Barthold Bos - cthulhu - Andoni Larzabal (andonilarz) + - Staormin - Dmitry Derepko - Rémi Leclerc - Jan Vernarsky @@ -2113,6 +2128,7 @@ The Symfony Connect username in parenthesis allows to get more information - martkop26 - Raphaël Davaillaud - Sander Hagen + - Alexander Menk - cilefen (cilefen) - Prasetyo Wicaksono (jowy) - Mo Di (modi) @@ -2293,6 +2309,7 @@ The Symfony Connect username in parenthesis allows to get more information - Willem Verspyck - Kim Laï Trinh - Johan de Ruijter + - InbarAbraham - Jason Desrosiers - m.chwedziak - marbul @@ -2348,6 +2365,7 @@ The Symfony Connect username in parenthesis allows to get more information - Phillip Look (plook) - Foxprodev - Artfaith + - Tom Kaminski - developer-av - Max Summe - Ema Panz @@ -2637,6 +2655,7 @@ The Symfony Connect username in parenthesis allows to get more information - Jakub Simon - TheMhv - Eviljeks + - Juliano Petronetto - robin.de.croock - Brandon Antonio Lorenzo - Bouke Haarsma @@ -2826,6 +2845,7 @@ The Symfony Connect username in parenthesis allows to get more information - Botond Dani (picur) - Rémi Faivre (rfv) - Radek Wionczek (rwionczek) + - tinect (tinect) - Nick Stemerdink - Bernhard Rusch - David Stone @@ -3008,6 +3028,7 @@ The Symfony Connect username in parenthesis allows to get more information - Viet Pham - Alan Bondarchuk - Pchol + - Benjamin Ellis - Shamimul Alam - Cyril HERRERA - dropfen @@ -3305,7 +3326,6 @@ The Symfony Connect username in parenthesis allows to get more information - Jimmy Leger (redpanda) - Ronny López (ronnylt) - Julius (sakalys) - - Sébastien JEAN (sebastien76) - Dmitry (staratel) - Marcin Szepczynski (szepczynski) - Tito Miguel Costa (titomiguelcosta) @@ -3578,6 +3598,7 @@ The Symfony Connect username in parenthesis allows to get more information - Thorsten Hallwas - Brian Freytag - Arend Hummeling + - Joseph FRANCLIN - Marco Pfeiffer - Alex Nostadt - Michael Squires @@ -3658,13 +3679,13 @@ The Symfony Connect username in parenthesis allows to get more information - Julia - Lin Lu - arduanov - - Valmonzo - sualko - Marc Bennewitz - Fabien - Martin Komischke - Yendric - ADmad + - Hugo Posnic - Nicolas Roudaire - Marc Jauvin - Matthias Meyer From 60a42b59bccc0e8a13785b1d5e3d2af1ec8b8574 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 26 Feb 2025 11:51:37 +0100 Subject: [PATCH 44/44] Update VERSION for 6.4.19 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index d4ee156b89380..087a393071a9d 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.4.19-DEV'; + public const VERSION = '6.4.19'; public const VERSION_ID = 60419; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 19; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2026'; public const END_OF_LIFE = '11/2027';