8000 Merge branch '5.4' into 6.0 · pl-github/symfony@3fe88b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fe88b2

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Console] Prevent PHP 8.1 str_replace deprec on null Improve DE translations for Form/Validator [Serializer] Fix ignore attribute in Xml files [Console] Escape % in command name & description from getDefault*() [WebProfilerBundle] Fix dark theme selected line highlight color & reuse css vars [Mime] Check that the path is a file in the DataPart::fromPath [Cache] do not pass null to strlen() [Mailer] Sort transports alphabetically [Security] Fix some phpdoc [Serializer] Get attributeContext after converting name
2 parents 15addfa + 8d0d9fa commit 3fe88b2

File tree

19 files changed

+105
-26
lines changed

19 files changed

+105
-26
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2330,11 +2330,11 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
23302330
MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
23312331
MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
23322332
MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
2333+
OhMySmtpTransportFactory::class => 'mailer.transport_factory.ohmysmtp',
23332334
PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
23342335
SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
23352336
SendinblueTransportFactory::class => 'mailer.transport_factory.sendinblue',
23362337
SesTransportFactory::class => 'mailer.transport_factory.amazon',
2337-
OhMySmtpTransportFactory::class => 'mailer.transport_factory.ohmysmtp',
23382338
];
23392339

23402340
foreach ($classToServices as $class => $service) {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
--highlight-default: #222222;
5252
--highlight-keyword: #a71d5d;
5353
--highlight-string: #183691;
54+
--highlight-selected-line: rgba(255, 255, 153, 0.5);
5455
--base-0: #fff;
5556
--base-1: #f5f5f5;
5657
--base-2: #e0e0e0;
@@ -104,6 +105,7 @@
104105
--highlight-default: var(--base-6);
105106
--highlight-keyword: #ff413c;
106107
--highlight-string: #70a6fd;
108+
--highlight-selected-line: rgba(14, 14, 14, 0.5);
107109
--base-0: #2e3136;
108110
--base-1: #444;
109111
--base-2: #666;
@@ -1296,15 +1298,15 @@ tr.log-status-silenced {
12961298
padding: 0;
12971299
}
12981300
#collector-content .sf-validator .trace li.selected {
1299-
background: rgba(255, 255, 153, 0.5);
1301+
background: var(--highlight-selected-line);
13001302
}
13011303

13021304
{# Messenger panel
13031305
========================================================================= #}
13041306

13051307
#collector-content .message-bus .trace {
1306-
border: 1px solid #DDD;
1307-
background: #FFF;
1308+
border: var(--border);
1309+
background: var(--base-0);
13081310
padding: 10px;
13091311
margin: 0.5em 0;
13101312
overflow: auto;
@@ -1317,7 +1319,7 @@ tr.log-status-silenced {
13171319
padding: 0;
13181320
}
13191321
#collector-content .message-bus .trace li.selected {
1320-
background: rgba(255, 255, 153, 0.5);
1322+
background: var(--highlight-selected-line);
13211323
}
13221324

13231325
{# Dump panel

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ protected function doClear(string $namespace): bool
378378
{
379379
if ($this->redis instanceof \Predis\ClientInterface) {
380380
$prefix = $this->redis->getOptions()->prefix ? $this->redis->getOptions()->prefix->getPrefix() : '';
381-
$prefixLen = \strlen($prefix);
381+
$prefixLen = \strlen($prefix ?? '');
382382
}
383383

384384
$cleared = true;

src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function process(ContainerBuilder $container)
5050
if (!$r->isSubclassOf(Command::class)) {
5151
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
5252
}
53-
$aliases = $class::getDefaultName();
53+
$aliases = str_replace('%', '%%', $class::getDefaultName() ?? '');
5454
}
5555

5656
$aliases = explode('|', $aliases ?? '');
@@ -107,7 +107,7 @@ public function process(ContainerBuilder $container)
107107
if (!$r->isSubclassOf(Command::class)) {
108108
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
109109
}
110-
$description = $class::getDefaultDescription();
110+
$description = str_replace('%', '%%', $class::getDefaultDescription());
111111
}
112112

113113
if ($description) {

src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,33 @@ public function testProcessFallsBackToDefaultDescription()
153153
$this->assertSame(1 + $initCounter, DescribedCommand::$initCounter);
154154
}
155155

156+
public function testEscapesDefaultFromPhp()
157+
{
158+
$container = new ContainerBuilder();
159+
$container
160+
->register('to-escape', EscapedDefaultsFromPhpCommand::class)
161+
->addTag('console.command')
162+
;
163+
164+
$pass = new AddConsoleCommandPass();
165+
$pass->process($container);
166+
167+
$commandLoader = $container->getDefinition('console.command_loader');
168+
$commandLocator = $container->getDefinition((string) $commandLoader->getArgument(0));
169+
170+
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
171+
$this->assertSame(['%%cmd%%' => 'to-escape', '%%cmdalias%%' => 'to-escape'], $commandLoader->getArgument(1));
172+
$this->assertEquals([['to-escape' => new ServiceClosureArgument(new Reference('.to-escape.lazy'))]], $commandLocator->getArguments());
173+
$this->assertSame([], $container->getParameter('console.command.ids'));
174+
175+
$command = $container->get('console.command_loader')->get('%%cmd%%');
176+
177+
$this->assertInstanceOf(LazyCommand::class, $command);
178+
$this->assertSame('%cmd%', $command->getName());
179+
$this->assertSame(['%cmdalias%'], $command->getAliases());
180+
$this->assertSame('Creates a 80% discount', $command->getDescription());
181+
}
182+
156183
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
157184
{
158185
$this->expectException(\InvalidArgumentException::class);
@@ -286,6 +313,12 @@ class NamedCommand extends Command
286313
protected static $defaultName = 'default';
287314
}
288315

316+
class EscapedDefaultsFromPhpCommand extends Command
317+
{
318+
protected static $defaultName = '%cmd%|%cmdalias%';
319+
protected static $defaultDescription = 'Creates a 80% discount';
320+
}
321+
289322
class DescribedCommand extends Command
290323
{
291324
public static $initCounter = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</trans-unit>
1313
<trans-unit id="30">
1414
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
15-
<target>Der CSRF-Token ist ungültig. Versuchen Sie bitte das Formular erneut zu senden.</target>
15+
<target>Der CSRF-Token ist ungültig. Versuchen Sie bitte, das Formular erneut zu senden.</target>
1616
</trans-unit>
1717
<trans-unit id="99">
1818
<source>This value is not a valid HTML5 color.</source>

src/Symfony/Component/Mailer/Exception/UnsupportedSchemeException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class UnsupportedSchemeException extends LogicException
3636
'class' => Bridge\Mailchimp\Transport\MandrillTransportFactory::class,
3737
'package' => 'symfony/mailchimp-mailer',
3838
],
39+
'ohmysmtp' => [
40+
'class' => Bridge\OhMySmtp\Transport\OhMySmtpTransportFactory::class,
41+
'package' => 'symfony/oh-my-smtp-mailer',
42+
],
3943
'postmark' => [
4044
'class' => Bridge\Postmark\Transport\PostmarkTransportFactory::class,
4145
'package' => 'symfony/postmark-mailer',
@@ -52,10 +56,6 @@ class UnsupportedSchemeException extends LogicException
5256
'class' => Bridge\Amazon\Transport\SesTransportFactory::class,
5357
'package' => 'symfony/amazon-mailer',
5458
],
55-
'ohmysmtp' => [
56-
'class' => Bridge\OhMySmtp\Transport\OhMySmtpTransportFactory::class,
57-
'package' => 'symfony/oh-my-smtp-mailer',
58-
],
5959
];
6060

6161
public function __construct(Dsn $dsn, string $name = null, array $supported = [])

src/Symfony/Component/Mailer/Tests/Exception/UnsupportedSchemeExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public static function setUpBeforeClass(): void
3838
MailgunTransportFactory::class => false,
3939
MailjetTransportFactory::class => false,
4040
MandrillTransportFactory::class => false,
41+
OhMySmtpTransportFactory::class => false,
4142
PostmarkTransportFactory::class => false,
4243
SendgridTransportFactory::class => false,
4344
SendinblueTransportFactory::class => false,
44-
OhMySmtpTransportFactory::class => false,
4545
SesTransportFactory::class => false,
4646
]);
4747
}
@@ -65,10 +65,10 @@ public function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generat
6565
yield ['mailgun', 'symfony/mailgun-mailer'];
6666
yield ['mailjet', 'symfony/mailjet-mailer'];
6767
yield ['mandrill', 'symfony/mailchimp-mailer'];
68+
yield ['ohmysmtp', 'symfony/oh-my-smtp-mailer'];
6869
yield ['postmark', 'symfony/postmark-mailer'];
6970
yield ['sendgrid', 'symfony/sendgrid-mailer'];
7071
yield ['sendinblue', 'symfony/sendinblue-mailer'];
71-
yield ['ohmysmtp', 'symfony/oh-my-smtp-mailer'];
7272
yield ['ses', 'symfony/amazon-mailer'];
7373
}
7474

src/Symfony/Component/Mailer/Transport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ final class Transport
4747
MailgunTransportFactory::class,
4848
MailjetTransportFactory::class,
4949
MandrillTransportFactory::class,
50+
OhMySmtpTransportFactory::class,
5051
PostmarkTransportFactory::class,
5152
SendgridTransportFactory::class,
5253
SendinblueTransportFactory::class,
53-
OhMySmtpTransportFactory::class,
5454
SesTransportFactory::class,
5555
];
5656

src/Symfony/Component/Mime/Part/DataPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function fromPath(string $path, string $name = null, string $conte
6161
$contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
6262
}
6363

64-
if (false === is_readable($path)) {
64+
if (!is_file($path) || !is_readable($path)) {
6565
throw new InvalidArgumentException(sprintf('Path "%s" is not readable.', $path));
6666
}
6767

0 commit comments

Comments
 (0)
0