Skip to content

Commit 2cbffec

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [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 742c3c2 + 3fe88b2 commit 2cbffec

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
@@ -2430,11 +2430,11 @@ private function registerMailerConfiguration(array $config, ContainerBuilder $co
24302430
MailgunTransportFactory::class => 'mailer.transport_factory.mailgun',
24312431
MailjetTransportFactory::class => 'mailer.transport_factory.mailjet',
24322432
MandrillTransportFactory::class => 'mailer.transport_factory.mailchimp',
2433+
OhMySmtpTransportFactory::class => 'mailer.transport_factory.ohmysmtp',
24332434
PostmarkTransportFactory::class => 'mailer.transport_factory.postmark',
24342435
SendgridTransportFactory::class => 'mailer.transport_factory.sendgrid',
24352436
SendinblueTransportFactory::class => 'mailer.transport_factory.sendinblue',
24362437
SesTransportFactory::class => 'mailer.transport_factory.amazon',
2437-
OhMySmtpTransportFactory::class => 'mailer.transport_factory.ohmysmtp',
24382438
];
24392439

24402440
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
@@ -388,7 +388,7 @@ protected function doClear(string $namespace): bool
388388
{
389389
if ($this->redis instanceof \Predis\ClientInterface) {
390390
$prefix = $this->redis->getOptions()->prefix ? $this->redis->getOptions()->prefix->getPrefix() : '';
391-
$prefixLen = \strlen($prefix);
391+
$prefixLen = \strlen($prefix ?? '');
392392
}
393393

394394
$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
@@ -154,6 +154,33 @@ public function testProcessFallsBackToDefaultDescription()
154154
$this->assertSame(1 + $initCounter, DescribedCommand::$initCounter);
155155
}
156156

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

317+
class EscapedDefaultsFromPhpCommand extends Command
318+
{
319+
protected static $defaultName = '%cmd%|%cmdalias%';
320+
protected static $defaultDescription = 'Creates a 80% discount';
321+
}
322+
290323
#[AsCommand(name: '|cmdname|cmdalias', description: 'Just testing')]
291324
class DescribedCommand extends Command
292325
{

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

src/Symfony/Component/Mime/Tests/Part/DataPartTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Mime\Tests\Part;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mime\Exception\InvalidArgumentException;
1516
use Symfony\Component\Mime\Header\Headers;
1617
use Symfony\Component\Mime\Header\IdentificationHeader;
1718
use Symfony\Component\Mime\Header\ParameterizedHeader;
@@ -127,6 +128,12 @@ public function testFromPathWithMeta()
127128
), $p->getPreparedHeaders());
128129
}
129130

131+
public function testFromPathWithNotAFile()
132+
{
133+
$this->expectException(InvalidArgumentException::class);
134+
DataPart::fromPath(__DIR__.'/../Fixtures/mimetypes/');
135+
}
136+
130137
public function testHasContentId()
131138
{
132139
$p = new DataPart('content');

src/Symfony/Component/Security/Http/Authenticator/Passport/Credentials/PasswordCredentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Implements password credentials.
1818
*
19-
* These plaintext passwords are checked by the UserPasswordEncoder during
19+
* These plaintext passwords are checked by the UserPasswordHasher during
2020
* authentication.
2121
*
2222
* @author Wouter de Jong <[email protected]>

src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\CredentialsInterface;
1818

1919
/**
20-
* The default implementation for passports.
20+
* A Passport contains all security-related information that needs to be
21+
* validated during authentication.
22+
*
23+
* A passport badge can be used to add any additional information to the
24+
* passport.
2125
*
2226
* @author Wouter de Jong <[email protected]>
2327
*/
@@ -55,7 +59,16 @@ public function getUser(): UserInterface
5559
return $this->user;
5660
}
5761

58-
public function addBadge(BadgeInterface $badge): static
62+
/**
63+
* Adds a new security badge.
64+
*
65+
* A passport can hold only one instance of the same security badge.
66+
* This method replaces the current badge if it is already set on this
67+
* passport.
68+
*
69+
* @return $this
70+
*/
71+
public function addBadge(BadgeInterface $badge): PassportInterface
5972
{
6073
$this->badges[\get_class($badge)] = $badge;
6174

src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
7272
}
7373

7474
if (isset($attribute['ignore'])) {
75-
$attributeMetadata->setIgnore((bool) $attribute['ignore']);
75+
$attributeMetadata->setIgnore(XmlUtils::phpize($attribute['ignore']));
7676
}
7777

7878
foreach ($attribute->context as $node) {

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,12 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
364364
$resolvedClass = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object);
365365

366366
foreach ($normalizedData as $attribute => $value) {
367-
$attributeContext = $this->getAttributeDenormalizationContext($resolvedClass, $attribute, $context);
368-
369367
if ($this->nameConverter) {
370-
$attribute = $this->nameConverter->denormalize($attribute, $resolvedClass, $format, $attributeContext);
368+
$attribute = $this->nameConverter->denormalize($attribute, $resolvedClass, $format, $context);
371369
}
372370

371+
$attributeContext = $this->getAttributeDenormalizationContext($resolvedClass, $attribute, $context);
372+
373373
if ((false !== $allowedAttributes && !\in_array($attribute, $allowedAttributes)) || !$this->isAllowedAttribute($resolvedClass, $attribute, $format, $context)) {
374374
if (!($context[self::ALLOW_EXTRA_ATTRIBUTES] ?? $this->defaultContext[self::ALLOW_EXTRA_ATTRIBUTES])) {
375375
$extraAttributes[] = $attribute;

src/Symfony/Component/Serializer/Tests/Fixtures/serialization.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<class name="Symfony\Component\Serializer\Tests\Fixtures\Annotations\IgnoreDummy">
3838
<attribute name="ignored1" ignore="true" />
3939
<attribute name="ignored2" ignore="true" />
40+
<attribute name="notIgnored" ignore="false" />
4041
</class>
4142

4243
<class name="Symfony\Component\Serializer\Tests\Fixtures\Annotations\ContextDummyParent">

src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public function testLoadIgnore()
107107
$attributesMetadata = $classMetadata->getAttributesMetadata();
108108
$this->assertTrue($attributesMetadata['ignored1']->isIgnored());
109109
$this->assertTrue($attributesMetadata['ignored2']->isIgnored());
110+
$this->assertFalse($attributesMetadata['notIgnored']->isIgnored());
110111
}
111112

112113
protected function getLoaderForContextMapping(): LoaderInterface

src/Symfony/Component/Serializer/Tests/Normalizer/Features/ContextMetadataTestTrait.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Serializer\Annotation\Groups;
1818
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1919
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
20+
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
2021
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
2122
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
2223
use Symfony\Component\Serializer\Serializer;
@@ -84,6 +85,17 @@ public function contextMetadataDummyProvider()
8485
[ContextChildMetadataDummy::class],
8586
];
8687
}
88+
89+
public function testContextDenormalizeWithNameConverter()
90+
{
91+
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
92+
$normalizer = new ObjectNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter(), null, new PhpDocExtractor());
93+
new Serializer([new DateTimeNormalizer(), $normalizer]);
94+
95+
/** @var ContextMetadataNamingDummy $dummy */
96+
$dummy = $normalizer->denormalize(['created_at' => '28/07/2011'], ContextMetadataNamingDummy::class);
97+
self::assertEquals('2011-07-28', $dummy->createdAt->format('Y-m-d'));
98+
}
8799
}
88100

89101
class ContextMetadataDummy
@@ -123,3 +135,13 @@ class ContextChildMetadataDummy
123135
*/
124136
public $date;
125137
}
138+
139+
class ContextMetadataNamingDummy
140+
{
141+
/**
142+
* @var \DateTime
143+
*
144+
* @Context({ DateTimeNormalizer::FORMAT_KEY = "d/m/Y" })
145+
*/
146+
public $createdAt;
147+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
</trans-unit>
221221
<trans-unit id="58">
222222
<source>Unsupported card type or invalid card number.</source>
223-
<target>Nicht unterstützer Kartentyp oder ungültige Kartennummer.</target>
223+
<target>Nicht unterstützter Kartentyp oder ungültige Kartennummer.</target>
224224
</trans-unit>
225225
<trans-unit id="59">
226226
<source>This is not a valid International Bank Account Number (IBAN).</source>
@@ -312,7 +312,7 @@
312312
</trans-unit>
313313
<trans-unit id="81">
314314
<source>This is not a valid Business Identifier Code (BIC).</source>
315-
<target>Dieser Wert ist kein gültiger BIC.</target>
315+
<target>Dieser Wert ist keine gültige internationale Bankleitzahl (BIC).</target>
316316
</trans-unit>
317317
<trans-unit id="82">
318318
<source>Error</source>

0 commit comments

Comments
 (0)