Skip to content

Commit 114710d

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: don't use deprecated and internal Twig functions [Notifier][Clickatell] Fixed minor typo add missing translation [Messenger] Add missing Redis cleanup in tests Make sure Serializer::denormalize have show what exception it throws
2 parents 877b173 + 728afe8 commit 114710d

File tree

9 files changed

+78
-35
lines changed

9 files changed

+78
-35
lines changed

src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Twig\Node;
1313

1414
use Twig\Compiler;
15+
use Twig\Extension\CoreExtension;
1516
use Twig\Node\Expression\ArrayExpression;
1617
use Twig\Node\Expression\ConstantExpression;
1718
use Twig\Node\Expression\FunctionExpression;
@@ -50,7 +51,7 @@ public function compile(Compiler $compiler): void
5051
$labelIsExpression = false;
5152

5253
// Only insert the label into the array if it is not empty
53-
if (!twig_test_empty($label->getAttribute('value'))) {
54+
if (null !== $label->getAttribute('value') && false !== $label->getAttribute('value') && '' !== (string) $label->getAttribute('value')) {
5455
$originalVariables = $variables;
5556
$variables = new ArrayExpression([], $lineno);
5657
$labelKey = new ConstantExpression('label', $lineno);
@@ -97,7 +98,12 @@ public function compile(Compiler $compiler): void
9798

9899
// Check at runtime whether the label is empty.
99100
// If not, add it to the array at runtime.
100-
$compiler->raw('(twig_test_empty($_label_ = ');
101+
if (method_exists(CoreExtension::class, 'testEmpty')) {
102+
$compiler->raw('(CoreExtension::testEmpty($_label_ = ');
103+
} else {
104+
$compiler->raw('(twig_test_empty($_label_ = ');
105+
}
106+
101107
$compiler->subcompile($label);
102108
$compiler->raw(') ? [] : ["label" => $_label_])');
103109
}

src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode;
1616
use Twig\Compiler;
1717
use Twig\Environment;
18+
use Twig\Extension\CoreExtension;
1819
use Twig\Loader\LoaderInterface;
1920
use Twig\Node\Expression\ArrayExpression;
2021
use Twig\Node\Expression\ConditionalExpression;
@@ -226,8 +227,9 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
226227
// https://github.com/symfony/symfony/issues/5029
227228
$this->assertEquals(
228229
sprintf(
229-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))',
230-
$this->getVariableGetter('form')
230+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', (%s($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))',
231+
$this->getVariableGetter('form'),
232+
method_exists(CoreExtension::class, 'testEmpty') ? 'CoreExtension::testEmpty' : 'twig_test_empty'
231233
),
232234
trim($compiler->compile($node)->getSource())
233235
);
@@ -263,8 +265,9 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
263265
// https://github.com/symfony/symfony/issues/5029
264266
$this->assertEquals(
265267
sprintf(
266-
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in attributes"] + (twig_test_empty($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))',
267-
$this->getVariableGetter('form')
268+
'$this->env->getRuntime(\'Symfony\Component\Form\FormRenderer\')->searchAndRenderBlock(%s, \'label\', ["foo" => "bar", "label" => "value in attributes"] + (%s($_label_ = ((true) ? (null) : (null))) ? [] : ["label" => $_label_]))',
269+
$this->getVariableGetter('form'),
270+
method_exists(CoreExtension::class, 'testEmpty') ? 'CoreExtension::testEmpty' : 'twig_test_empty'
268271
),
269272
trim($compiler->compile($node)->getSource())
270273
);

src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Symfony\Bundle\WebProfilerBundle\Twig\WebProfilerExtension;
1616
use Symfony\Component\VarDumper\Cloner\VarCloner;
1717
use Twig\Environment;
18-
use Twig\Extension\CoreExtension;
19-
use Twig\Extension\EscaperExtension;
2018

2119
class WebProfilerExtensionTest extends TestCase
2220
{
@@ -25,9 +23,6 @@ class WebProfilerExtensionTest extends TestCase
2523
*/
2624
public function testDumpHeaderIsDisplayed(string $message, array $context, bool $dump1HasHeader, bool $dump2HasHeader)
2725
{
28-
class_exists(CoreExtension::class); // Load twig_convert_encoding()
29-
class_exists(EscaperExtension::class); // Load twig_escape_filter()
30-
3126
$twigEnvironment = $this->mockTwigEnvironment();
3227
$varCloner = new VarCloner();
3328

src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\VarDumper\Cloner\Data;
1515
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
1616
use Twig\Environment;
17+
use Twig\Extension\EscaperExtension;
1718
use Twig\Extension\ProfilerExtension;
1819
use Twig\Profiler\Profile;
1920
use Twig\TwigFunction;
@@ -78,12 +79,12 @@ public function dumpData(Environment $env, Data $data, int $maxDepth = 0): strin
7879

7980
public function dumpLog(Environment $env, string $message, Data $context = null): string
8081
{
81-
$message = twig_escape_filter($env, $message);
82+
$message = self::escape($env, $message);
8283
$message = preg_replace('/&quot;(.*?)&quot;/', '&quot;<b>$1</b>&quot;', $message);
8384

8485
$replacements = [];
8586
foreach ($context ?? [] as $k => $v) {
86-
$k = '{'.twig_escape_filter($env, $k).'}';
87+
$k = '{'.self::escape($env, $k).'}';
8788
if (str_contains($message, $k)) {
8889
$replacements[$k] = $v;
8990
}
@@ -104,4 +105,14 @@ public function getName(): string
104105
{
105106
return 'profiler';
106107
}
108+
109+
private static function escape(Environment $env, string $s): string
110+
{
111+
if (method_exists(EscaperExtension::class, 'escape')) {
112+
return EscaperExtension::escape($env, $s);
113+
}
114+
115+
// to be removed when support for Twig 3 is dropped
116+
return twig_escape_filter($env, $s);
117+
}
107118
}

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php

+40-21
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,19 @@ public function testLazy()
293293
$connection = Connection::fromDsn('redis://localhost/messenger-lazy?lazy=1', [], $redis);
294294

295295
$connection->add('1', []);
296-
$this->assertNotEmpty($message = $connection->get());
297-
$this->assertSame([
298-
'message' => json_encode([
299-
'body' => '1',
300-
'headers' => [],
301-
]),
302-
], $message['data']);
303-
$connection->reject($message['id']);
304-
$redis->del('messenger-lazy');
296+
297+
try {
298+
$this->assertNotEmpty($message = $connection->get());
299+
$this->assertSame([
300+
'message' => json_encode([
301+
'body' => '1',
302+
'headers' => [],
303+
]),
304+
], $message['data']);
305+
$connection->reject($message['id']);
306+
} finally {
307+
$redis->del('messenger-lazy');
308+
}
305309
}
306310

307311
public function testDbIndex()
@@ -328,13 +332,16 @@ public function testFromDsnWithMultipleHosts()
328332
public function testJsonError()
329333
{
330334
$redis = $this->createRedisClient();
331-
$connection = Connection::fromDsn('redis://localhost/json-error', [], $redis);
335+
$connection = Connection::fromDsn('redis://localhost/messenger-json-error', [], $redis);
332336
try {
333337
$connection->add("\xB1\x31", []);
338+
339+
$this->fail('Expected exception to be thrown.');
334340
} catch (TransportException $e) {
341+
$this->assertSame('Malformed UTF-8 characters, possibly incorrectly encoded', $e->getMessage());
342+
} finally {
343+
$redis->del('messenger-json-error');
335344
}
336-
337-
$this->assertSame('Malformed UTF-8 characters, possibly incorrectly encoded', $e->getMessage());
338345
}
339346

340347
public function testGetNonBlocking()
@@ -343,29 +350,41 @@ public function testGetNonBlocking()
343350

344351
$connection = Connection::fromDsn('redis://localhost/messenger-getnonblocking', ['sentinel_master' => null], $redis);
345352

346-
$this->assertNull($connection->get()); // no message, should return null immediately
347-
$connection->add('1', []);
348-
$this->assertNotEmpty($message = $connection->get());
349-
$connection->reject($message['id']);
350-
$redis->del('messenger-getnonblocking');
353+
try {
354+
$this->assertNull($connection->get()); // no message, should return null immediately
355+
$connection->add('1', []);
356+
$this->assertNotEmpty($message = $connection->get());
357+
$connection->reject($message['id']);
358+
} finally {
359+
$redis->del('messenger-getnonblocking');
360+
}
351361
}
352362

353363
public function testGetAfterReject()
354364
{
355365
$redis = $this->createRedisClient();
356366
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', ['sentinel_master' => null], $redis);
357367

358-
$connection->add('1', []);
359-
$connection->add('2', []);
368+
try {
369+
$connection->add('1', []);
370+
$connection->add('2', []);
360371

361-
$failing = $connection->get();
362-
$connection->reject($failing['id']);
372+
$failing = $connection->get();
373+
$connection->reject($failing['id']);
363374

375+
<<<<<<< HEAD
364376
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', ['sentinel_master' => null]);
365377

366378
$this->assertNotNull($connection->get());
367379

368380
$redis->del('messenger-rejectthenget');
381+
=======
382+
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', ['delete_after_ack' => true]);
383+
$this->assertNotNull($connection->get());
384+
} finally {
385+
$redis->del('messenger-rejectthenget');
386+
}
387+
>>>>>>> 5.4
369388
}
370389

371390
public function testItProperlyHandlesEmptyMessages()

src/Symfony/Component/Notifier/Bridge/Clickatell/ClickatellTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function doSend(MessageInterface $message): SentMessage
7979
try {
8080
$statusCode = $response->getStatusCode();
8181
} catch (TransportExceptionInterface $e) {
82-
throw new TransportException('Could not reach the remote Clicktell server.', $response, 0, $e);
82+
throw new TransportException('Could not reach the remote Clickatell server.', $response, 0, $e);
8383
}
8484

8585
if (202 === $statusCode) {

src/Symfony/Component/Serializer/Serializer.php

+1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public function normalize(mixed $data, string $format = null, array $context = [
193193

194194
/**
195195
* @throws NotNormalizableValueException
196+
* @throws PartialDenormalizationException Occurs when one or more properties of $type fails to denormalize
196197
*/
197198
public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
198199
{

src/Symfony/Component/Validator/Resources/translations/validators.de.xlf

+4
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@
426426
<source>Using hidden overlay characters is not allowed.</source>
427427
<target>Verstecke Overlay-Zeichen sind nicht erlaubt.</target>
428428
</trans-unit>
429+
<trans-unit id="110">
430+
<source>The extension of the file is invalid ({{ extension }}). Allowed extensions are {{ extensions }}.</source>
431+
<target>Die Dateiendung ist ungültig ({{ extension }}). Gültige Dateiendungen sind {{ extensions }}.</target>
432+
</trans-unit>
429433
</body>
430434
</file>
431435
</xliff>

src/Symfony/Component/Validator/Resources/translations/validators.en.xlf

+4
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@
426426
<source>Using hidden overlay characters is not allowed.</source>
427427
<target>Using hidden overlay characters is not allowed.</target>
428428
</trans-unit>
429+
<trans-unit id="110">
430+
<source>The extension of the file is invalid ({{ extension }}). Allowed extensions are {{ extensions }}.</source>
431+
<target>The extension of the file is invalid ({{ extension }}). Allowed extensions are {{ extensions }}.</target>
432+
</trans-unit>
429433
</body>
430434
</file>
431435
</xliff>

0 commit comments

Comments
 (0)