Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 728afe8

Browse filesBrowse files
committed
Merge branch '5.4' into 6.3
* 5.4: 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 1aa17b8 + 85b3a05 commit 728afe8
Copy full SHA for 728afe8

File tree

Expand file treeCollapse file tree

9 files changed

+78
-35
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+78
-35
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php
+8-2Lines changed: 8 additions & 2 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
+7-4Lines changed: 7 additions & 4 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Tests/Twig/WebProfilerExtensionTest.php
-5Lines changed: 0 additions & 5 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
+13-2Lines changed: 13 additions & 2 deletions
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;
@@ -84,12 +85,12 @@ public function dumpData(Environment $env, Data $data, int $maxDepth = 0): strin
8485

8586
public function dumpLog(Environment $env, string $message, Data $context = null): string
8687
{
87-
$message = twig_escape_filter($env, $message);
88+
$message = self::escape($env, $message);
8889
$message = preg_replace('/&quot;(.*?)&quot;/', '&quot;<b>$1</b>&quot;', $message);
8990

9091
$replacements = [];
9192
foreach ($context ?? [] as $k => $v) {
92-
$k = '{'.twig_escape_filter($env, $k).'}';
93+
$k = '{'.self::escape($env, $k).'}';
9394
if (str_contains($message, $k)) {
9495
$replacements[$k] = $v;
9596
}
@@ -110,4 +111,14 @@ public function getName(): string
110111
{
111112
return 'profiler';
112113
}
114+
115+
private static function escape(Environment $env, string $s): string
116+
{
117+
if (method_exists(EscaperExtension::class, 'escape')) {
118+
return EscaperExtension::escape($env, $s);
119+
}
120+
121+
// to be removed when support for Twig 3 is dropped
122+
return twig_escape_filter($env, $s);
123+
}
113124
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php
+40-21Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,19 @@ public function testLazy()
264264
$connection = Connection::fromDsn('redis://localhost/messenger-lazy?lazy=1', [], $redis);
265265

266266
$connection->add('1', []);
267-
$this->assertNotEmpty($message = $connection->get());
268-
$this->assertSame([
269-
'message' => json_encode([
270-
'body' => '1',
271-
'headers' => [],
272-
]),
273-
], $message['data']);
274-
$connection->reject($message['id']);
275-
$redis->del('messenger-lazy');
267+
268+
try {
269+
$this->assertNotEmpty($message = $connection->get());
270+
$this->assertSame([
271+
'message' => json_encode([
272+
'body' => '1',
273+
'headers' => [],
274+
]),
275+
], $message['data']);
276+
$connection->reject($message['id']);
277+
} finally {
278+
$redis->del('messenger-lazy');
279+
}
276280
}
277281

278282
public function testDbIndex()
@@ -299,13 +303,16 @@ public function testFromDsnWithMultipleHosts()
299303
public function testJsonError()
300304
{
301305
$redis = $this->createRedisClient();
302-
$connection = Connection::fromDsn('redis://localhost/json-error', [], $redis);
306+
$connection = Connection::fromDsn('redis://localhost/messenger-json-error', [], $redis);
303307
try {
304308
$connection->add("\xB1\x31", []);
309+
310+
$this->fail('Expected exception to be thrown.');
305311
} catch (TransportException $e) {
312+
$this->assertSame('Malformed UTF-8 characters, possibly incorrectly encoded', $e->getMessage());
313+
} finally {
314+
$redis->del('messenger-json-error');
306315
}
307-
308-
$this->assertSame('Malformed UTF-8 characters, possibly incorrectly encoded', $e->getMessage());
309316
}
310317

311318
public function testGetNonBlocking()
@@ -314,29 +321,41 @@ public function testGetNonBlocking()
314321

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

317-
$this->assertNull($connection->get()); // no message, should return null immediately
318-
$connection->add('1', []);
319-
$this->assertNotEmpty($message = $connection->get());
320-
$connection->reject($message['id']);
321-
$redis->del('messenger-getnonblocking');
324+
try {
325+
$this->assertNull($connection->get()); // no message, should return null immediately
326+
$connection->add('1', []);
327+
$this->assertNotEmpty($message = $connection->get());
328+
$connection->reject($message['id']);
329+
} finally {
330+
$redis->del('messenger-getnonblocking');
331+
}
322332
}
323333

324334
public function testGetAfterReject()
325335
{
326336
$redis = $this->createRedisClient();
327337
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', ['sentinel_master' => null], $redis);
328338

329-
$connection->add('1', []);
330-
$connection->add('2', []);
339+
try {
340+
$connection->add('1', []);
341+
$connection->add('2', []);
331342

332-
$failing = $connection->get();
333-
$connection->reject($failing['id']);
343+
$failing = $connection->get();
344+
$connection->reject($failing['id']);
334345

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

337349
$this->assertNotNull($connection->get());
338350

339351
$redis->del('messenger-rejectthenget');
352+
=======
353+
$connection = Connection::fromDsn('redis://localhost/messenger-rejectthenget', ['delete_after_ack' => true]);
354+
$this->assertNotNull($connection->get());
355+
} finally {
356+
$redis->del('messenger-rejectthenget');
357+
}
358+
>>>>>>> 5.4
340359
}
341360

342361
public function testItProperlyHandlesEmptyMessages()

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Clickatell/ClickatellTransport.php
+1-1Lines changed: 1 addition & 1 deletion
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Serializer.php
+1Lines changed: 1 addition & 0 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.de.xlf
+4Lines changed: 4 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.en.xlf
+4Lines changed: 4 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.