8000 Merge branch '6.2' into 6.3 · symfony/symfony@67cb407 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67cb407

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: Bump Symfony version to 6.2.2 Update VERSION for 6.2.1 Update CHANGELOG for 6.2.1 [DependencyInjection] Fix `ContainerBuilder` stats env usage with enum [Mailer] Fix rendered templates for notifications [HttpKernel] Fix using entities with the #[Cache()] attribute [DependencyInjection] Remove refs that point to container.excluded services when allowed Revert "bug #48027 [DependencyInjection] Don't autoconfigure tag when it's already set with attributes (nicolas-grekas)" [WebProfilerBundle] Use same color as other icons for the close toolbar btn [Profiler] Fix the dump view panel
2 parents 94d6bbb + f57bcb6 commit 67cb407

File tree

16 files changed

+150
-50
lines changed

16 files changed

+150
-50
lines changed

CHANGELOG-6.2.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ in 6.2 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v6.2.0...v6.2.1
99

10+
* 6.2.1 (2022-12-06)
11+
12+
* bug #48502 [DependencyInjection] Fix `ContainerBuilder` stats env usage with enum (alamirault)
13+
* bug #48509 [HttpKernel] Fix using entities with the `#[Cache()]` attribute (HypeMC)
14+
* bug #48505 [Mailer] Fix rendered templates for notifications (fabpot)
15+
* bug #48476 [WebProfilerBundle] Use same color as other icons for the close toolbar btn (ogizanagi)
16+
* bug #48483 [DependencyInjection] Remove refs that point to container.excluded services when allowed (nicolas-grekas)
17+
* bug #48346 [HttpKernel] In DateTimeValueResolver, convert previously defined date attribute to the expected class (GromNaN)
18+
* bug #48450 [WebProfilerBundle] Fix form panel expanders (MatTheCat)
19+
* bug #48459 [FrameworkBundle] [Framework] Fix Infobip Mailer transport factory import (gnito-org)
20+
* bug #48461 [VarExporter] Fix possible memory-leak when using lazy-objects (nicolas-grekas)
21+
* bug #48335 [TwigBridge] Amend `MoneyType` twig to include a space (mogilvie)
22+
* bug #48046 [WebProfilerBundle] Remove redundant code from logger template (HypeMC)
23+
* bug #48428 Fixed undefined variable error (Kevin Meijer)
24+
* bug #48416 [FrameworkBundle] don't register the MailerTestCommand symfony/console is not installed (xabbuh)
25+
* bug #48395 [String] Fix AsciiSlugger with emojis (fancyweb)
26+
* bug #48385 [Security] Reuse `AbstractFactory`'s config tree in `AccessTokenFactory` (chalasr)
27+
* bug #48292 [Security] [LoginLink] Throw InvalidLoginLinkException on missing parameter (MatTheCat)
28+
1029
* 6.2.0 (2022-11-30)
1130

1231
* bug #48395 [String] Fix AsciiSlugger with emojis (fancyweb)

src/Symfony/Bridge/Twig/Mime/BodyRenderer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ public function render(Message $message): void
5959

6060
if ($template = $message->getTextTemplate()) {
6161
$message->text($this->twig->render($template, $vars));
62-
$message->textTemplate(null);
6362
}
6463

6564
if ($template = $message->getHtmlTemplate()) {
6665
$message->html($this->twig->render($template, $vars));
67-
$message->htmlTemplate(null);
6866
}
6967

70-
$message->context([]);
68+
$message->markAsRendered();
7169

7270
// if text body is empty, compute one from the HTML body
7371
if (!$message->getTextBody() && null !== $html = $message->getHtmlBody()) {

src/Symfony/Bridge/Twig/Mime/NotificationEmail.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class NotificationEmail extends TemplatedEmail
4040
'raw' => false,
4141
'footer_text' => 'Notification e-mail sent by Symfony',
4242
];
43+
private bool $rendered = false;
4344

4445
public function __construct(Headers $headers = null, AbstractPart $body = null)
4546
{
@@ -178,6 +179,18 @@ public function getContext(): array
178179
return array_merge($this->context, parent::getContext());
179180
}
180181

182+
public function isRendered(): bool
183+
{
184+
return $this->rendered;
185+
}
186+
187+
public function markAsRendered(): void
188+
{
189+
parent::markAsRendered();
190+
191+
$this->rendered = true;
192+
}
193+
181194
public function getPreparedHeaders(): Headers
182195
{
183196
$headers = parent::getPreparedHeaders();
@@ -225,15 +238,17 @@ private function getExceptionAsString(\Throwable|FlattenException $exception): s
225238
*/
226239
public function __serialize(): array
227240
{
228-
return [$this->context, $this->theme, parent::__serialize()];
241+
return [$this->context, $this->theme, $this->rendered, parent::__serialize()];
229242
}
230243

231244
/**
232245
* @internal
233246
*/
234247
public function __unserialize(array $data): void
235248
{
236-
if (3 === \count($data)) {
249+
if (4 === \count($data)) {
250+
[$this->context, $this->theme, $this->rendered, $parentData] = $data;
251+
} elseif (3 === \count($data)) {
237252
[$this->context, $this->theme, $parentData] = $data;
238253
} else {
239254
// Backwards compatibility for deserializing data structures that were serialized without the theme

src/Symfony/Bridge/Twig/Mime/TemplatedEmail.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ public function getContext(): array
6767
return $this->context;
6868
}
6969

70+
public function isRendered(): bool
71+
{
72+
return null === $this->htmlTemplate && null === $this->textTemplate;
73+
}
74+
75+
public function markAsRendered(): void
76+
{
77+
$this->textTemplate = null;
78+
$this->htmlTemplate = null;
79+
$this->context = [];
80+
}
81+
7082
/**
7183
* @internal
7284
*/

src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/dump.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
{{ dump.data|raw }}
6969
</div>
7070
{% else %}
71-
<div class="empty">
71+
<div class="empty empty-panel">
7272
<p>No content was dumped.</p>
7373
</div>
7474
{% endfor %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125

126126
.sf-toolbarreset .hide-button {
127127
background: var(--sf-toolbar-gray-800);
128+
color: var(--sf-toolbar-gray-300);
128129
display: block;
129130
position: absolute;
130131
top: 2px;

src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
126126
foreach ($instanceofTags[$i] as $k => $v) {
127127
if (null === $definition->getDecoratedService() || \in_array($k, $tagsToKeep, true)) {
128128
foreach ($v as $v) {
129-
if ($definition->hasTag($k) && (!$v || \in_array($v, $definition->getTag($k)))) {
129+
if ($definition->hasTag($k) && \in_array($v, $definition->getTag($k))) {
130130
continue;
131131
}
132132
$definition->addTag($k, $v);

src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function processValue(mixed $value, int $rootLevel = 0, int $level = 0):
9595
$value = array_values($value);
9696
}
9797
} elseif ($value instanceof Reference) {
98-
if ($this->container->has($id = (string) $value)) {
98+
if ($this->container->hasDefinition($id = (string) $value) ? !$this->container->getDefinition($id)->hasTag('container.excluded') : $this->container->hasAlias($id)) {
9999
return $value;
100100
}
101101

src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function get(string $name): array|bool|string|int|float|\UnitEnum|null
4949
}
5050

5151
$uniqueName = md5($name.'_'.self::$counter++);
52-
$placeholder = sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), strtr($env, ':-.', '___'), $uniqueName);
52+
$placeholder = sprintf('%s_%s_%s', $this->getEnvPlaceholderUniquePrefix(), strtr($env, ':-.\\', '____'), $uniqueName);
5353
$this->envPlaceholders[$env][$placeholder] = $placeholder;
5454

5555
return $placeholder;

src/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ static function (ChildDefinition $definition, CustomAutoconfiguration $attribute
849849
$definition->addTag('app.custom_tag', get_object_vars($attribute) + ['class' => $reflector->getName()]);
850850
}
851851
);
852-
$container->registerForAutoconfiguration(TaggedService1::class)->addTag('app.custom_tag');
853852

854853
$container->register('one', TaggedService1::class)
855854
->setPublic(true)

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInvalidReferencesPassTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ public function testProcessSetOnlyDecoratedAsNullOnInvalid()
165165
$this->assertEquals($unknownArgument, $decoratorDefinition->getArguments()[1]);
166166
}
167167

168+
public function testProcessExcludedServiceAndNullOnInvalid()
169+
{
170+
$container = new ContainerBuilder();
171+
$container->register('foo', \stdClass::class)->addTag('container.excluded');
172+
$container->register('bar', \stdClass::class)->addArgument(new Reference('foo', $container::NULL_ON_INVALID_REFERENCE));
173+
174+
$this->process($container);
175+
176+
$this->assertSame([null], $container->getDefinition('bar')->getArguments());
177+
}
178+
168179
protected function process(ContainerBuilder $container)
169180
{
170181
$pass = new ResolveInvalidReferencesPass();

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument;
5252
use Symfony\Component\DependencyInjection\Tests\Fixtures\ScalarFactory;
5353
use Symfony\Component\DependencyInjection\Tests\Fixtures\SimilarArgumentsDummy;
54+
use Symfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum;
5455
use Symfony\Component\DependencyInjection\Tests\Fixtures\WitherStaticReturnType;
5556
use Symfony\Component\DependencyInjection\TypedReference;
5657
use Symfony\Component\ExpressionLanguage\Expression;
@@ -545,6 +546,23 @@ public function testEnvExpressionFunction()
545546
$this->assertEquals('Foo value', $container->get('bar')->foo);
546547
}
547548

549+
public function testGetEnvCountersWithEnum()
550+
{
551+
$bag = new EnvPlaceholderParameterBag();
552+
$config = new ContainerBuilder($bag);
553+
$config->resolveEnvPlaceholders([
554+
$bag->get('env(enum:'.StringBackedEnum::class.':foo)'),
555+
$bag->get('env(Bar)'),
556+
]);
557+
558+
$expected = [
559+
'enum:Symfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum:foo' => 1,
560+
'Bar' => 1,
561+
];
562+
563+
$this->assertSame($expected, $config->getEnvCounters());
564+
}
565+
548566
public function testCreateServiceWithAbstractArgument()
549567
{
550568
$this->expectException(RuntimeException::class);

src/Symfony/Component/HttpKernel/EventListener/CacheAttributeListener.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\HttpKernel\Attribute\Cache;
19-
use Symfony\Component\HttpKernel\Event\ControllerEvent;
19+
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
2020
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2121
use Symfony\Component\HttpKernel\KernelEvents;
2222

@@ -47,7 +47,7 @@ public function __construct(
4747
/**
4848
* Handles HTTP validation headers.
4949
*/
50-
public function onKernelController(ControllerEvent $event)
50+
public function onKernelControllerArguments(ControllerArgumentsEvent $event)
5151
{
5252
$request = $event->getRequest();
5353

@@ -63,12 +63,12 @@ public function onKernelController(ControllerEvent $event)
6363
/** @var Cache[] $attributes */
6464
foreach ($attributes as $cache) {
6565
if (null !== $cache->lastModified) {
66-
$lastModified = $this->getExpressionLanguage()->evaluate($cache->lastModified, $request->attributes->all());
66+
$lastModified = $this->getExpressionLanguage()->evaluate($cache->lastModified, array_merge($request->attributes->all(), $event->getNamedArguments()));
6767
($response ??= new Response())->setLastModified($lastModified);
6868
}
6969

7070
if (null !== $cache->etag) {
71-
$etag = hash('sha256', $this->getExpressionLanguage()->evaluate($cache->etag, $request->attributes->all()));
71+
$etag = hash('sha256', $this->getExpressionLanguage()->evaluate($cache->etag, array_merge($request->attributes->all(), $event->getNamedArguments())));
7272
($response ??= new Response())->setEtag($etag);
7373
}
7474
}
@@ -169,7 +169,7 @@ public function onKernelResponse(ResponseEvent $event)
169169
public static function getSubscribedEvents(): array
170170
{
171171
return [
172-
KernelEvents::CONTROLLER => ['onKernelController', 10],
172+
KernelEvents::CONTROLLER_ARGUMENTS => ['onKernelControllerArguments', 10],
173173
KernelEvents::RESPONSE => ['onKernelResponse', -10],
174174
];
175175
}

0 commit comments

Comments
 (0)
0