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 396e5eb

Browse filesBrowse files
committed
Merge branch '7.2' into 7.3
* 7.2: Use Composer InstalledVersions to check if flex is installed instead of existence of InstallRecipesCommand Improve readability of disallow_search_engine_index condition [DoctrineBridge] Fix UniqueEntityValidator Stringable identifiers [DoctrineBridge] Fix UniqueEntity for non-integer identifiers [Security] Avoid failing when PersistentRememberMeHandler handles a malformed cookie [PropertyAccess] Improve PropertyAccessor::setValue param docs fix asking for the retry option although --force was used [DoctrineBridge] Undefined variable
2 parents b3d4671 + cb229e5 commit 396e5eb
Copy full SHA for 396e5eb

File tree

Expand file treeCollapse file tree

11 files changed

+117
-7
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+117
-7
lines changed
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
13+
14+
use Symfony\Component\Uid\Uuid;
15+
16+
class UserUuidNameDto
17+
{
18+
public function __construct(
19+
public ?Uuid $id,
20+
public ?string $fullName,
21+
public ?string $address,
22+
) {
23+
}
24+
}
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Entity;
16+
use Doctrine\ORM\Mapping\Id;
17+
use Symfony\Component\Uid\Uuid;
18+
19+
#[Entity]
20+
class UserUuidNameEntity
21+
{
22+
public function __construct(
23+
#[Id, Column]
24+
public ?Uuid $id = null,
25+
#[Column(unique: true)]
26+
public ?string $fullName = null,
27+
) {
28+
}
29+
}

‎src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
4141
throw new ConversionException(sprintf('Expected "%s", got "%s"', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', get_debug_type($value)));
4242
}
4343

44-
return $foo->bar;
44+
return $value->bar;
4545
}
4646

4747
public function convertToPHPValue($value, AbstractPlatform $platform): ?Foo

‎src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141
use Symfony\Bridge\Doctrine\Tests\Fixtures\UpdateCompositeIntIdEntity;
4242
use Symfony\Bridge\Doctrine\Tests\Fixtures\UpdateCompositeObjectNoToStringIdEntity;
4343
use Symfony\Bridge\Doctrine\Tests\Fixtures\UpdateEmployeeProfile;
44+
use Symfony\Bridge\Doctrine\Tests\Fixtures\UserUuidNameDto;
45+
use Symfony\Bridge\Doctrine\Tests\Fixtures\UserUuidNameEntity;
4446
use Symfony\Bridge\Doctrine\Tests\TestRepositoryFactory;
4547
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
4648
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
49+
use Symfony\Component\Uid\Uuid;
4750
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
4851
use Symfony\Component\Validator\Exception\UnexpectedValueException;
4952
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -116,6 +119,7 @@ private function createSchema($em)
116119
$em->getClassMetadata(Employee::class),
117120
$em->getClassMetadata(CompositeObjectNoToStringIdEntity::class),
118121
$em->getClassMetadata(SingleIntIdStringWrapperNameEntity::class),
122+
$em->getClassMetadata(UserUuidNameEntity::class),
119123
]);
120124
}
121125

@@ -1423,4 +1427,25 @@ public function testEntityManagerNullObjectWhenDTODoctrineStyle()
14231427

14241428
$this->validator->validate($dto, $constraint);
14251429
}
1430+
1431+
public function testUuidIdentifierWithSameValueDifferentInstanceDoesNotCauseViolation()
1432+
{
1433+
$uuidString = 'ec562e21-1fc8-4e55-8de7-a42389ac75c5';
1434+
$existingPerson = new UserUuidNameEntity(Uuid::fromString($uuidString), 'Foo Bar');
1435+
$this->em->persist($existingPerson);
1436+
$this->em->flush();
1437+
1438+
$dto = new UserUuidNameDto(Uuid::fromString($uuidString), 'Foo Bar', '');
1439+
1440+
$constraint = new UniqueEntity(
1441+
fields: ['fullName'],
1442+
entityClass: UserUuidNameEntity::class,
1443+
identifierFieldNames: ['id'],
1444+
em: self::EM_NAME,
1445+
);
1446+
1447+
$this->validator->validate($dto, $constraint);
1448+
1449+
$this->assertNoViolation();
1450+
}
14261451
}

‎src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ public function validate(mixed $value, Constraint $constraint): void
197197

198198
foreach ($constraint->identifierFieldNames as $identifierFieldName) {
199199
$propertyValue = $this->getPropertyValue($entityClass, $identifierFieldName, current($result));
200+
if ($fieldValues[$identifierFieldName] instanceof \Stringable) {
201+
$fieldValues[$identifierFieldName] = (string) $fieldValues[$identifierFieldName];
202+
}
203+
if ($propertyValue instanceof \Stringable) {
204+
$propertyValue = (string) $propertyValue;
205+
}
200206
if ($fieldValues[$identifierFieldName] !== $propertyValue) {
201207
$entityMatched = false;
202208
break;

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu
826826
$container->getDefinition('config_cache_factory')->setArguments([]);
827827
}
828828

829-
if (!$config['disallow_search_engine_index'] ?? false) {
829+
if (!$config['disallow_search_engine_index']) {
830830
$container->removeDefinition('disallow_search_engine_index_response_listener');
831831
}
832832

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\DependencyInjection;
1313

14+
use Composer\InstalledVersions;
1415
use Symfony\Bridge\Twig\Extension\LogoutUrlExtension;
1516
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
1617
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface;
@@ -62,7 +63,6 @@
6263
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticator;
6364
use Symfony\Component\Security\Http\Authenticator\Debug\TraceableAuthenticatorManagerListener;
6465
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
65-
use Symfony\Flex\Command\InstallRecipesCommand;
6666

6767
/**
6868
* SecurityExtension.
@@ -93,7 +93,7 @@ public function prepend(ContainerBuilder $container): void
9393
public function load(array $configs, ContainerBuilder $container): void
9494
{
9595
if (!array_filter($configs)) {
96-
$hint = class_exists(InstallRecipesCommand::class) ? 'Try running "composer symfony:recipes:install symfony/security-bundle".' : 'Please define your settings for the "security" config section.';
96+
$hint = class_exists(InstalledVersions::class) && InstalledVersions::isInstalled('symfony/flex') ? 'Try running "composer symfony:recipes:install symfony/security-bundle".' : 'Please define your settings for the "security" config section.';
9797

9898
throw new InvalidConfigurationException('The SecurityBundle is enabled but is not configured. '.$hint);
9999
}

‎src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ private function runWorker(string $failureTransportName, ReceiverInterface $rece
224224

225225
$this->forceExit = true;
226226
try {
227-
$choice = $io->choice('Please select an action', ['retry', 'delete', 'skip'], 'retry');
228-
$shouldHandle = $shouldForce || 'retry' === $choice;
227+
$choice = $shouldForce ? 'retry' : $io->choice('Please select an action', ['retry', 'delete', 'skip'], 'retry');
228+
$shouldHandle = 'retry' === $choice;
229229
} finally {
230230
$this->forceExit = false;
231231
}

‎src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/PropertyAccessor.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public function getValue(object|array $objectOrArray, string|PropertyPathInterfa
109109
return $propertyValues[\count($propertyValues) - 1][self::VALUE];
110110
}
111111

112+
/**
113+
* @template T of object|array
114+
* @param T $objectOrArray
115+
* @param-out ($objectOrArray is array ? array : T) $objectOrArray
116+
*/
112117
public function setValue(object|array &$objectOrArray, string|PropertyPathInterface $propertyPath, mixed $value): void
113118
{
114119
if (\is_object($objectOrArray) && (false === strpbrk((string) $propertyPath, '.[') || $objectOrArray instanceof \stdClass && property_exists($objectOrArray, $propertyPath))) {

‎src/Symfony/Component/Security/Http/RememberMe/PersistentRememberMeHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/RememberMe/PersistentRememberMeHandler.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ public function clearRememberMeCookie(): void
124124
return;
125125
}
126126

127-
$rememberMeDetails = RememberMeDetails::fromRawCookie($cookie);
127+
try {
128+
$rememberMeDetails = RememberMeDetails::fromRawCookie($cookie);
129+
} catch (AuthenticationException) {
130+
// malformed cookie should not fail the response and can be simply ignored
131+
return;
132+
}
128133
[$series] = explode(':', $rememberMeDetails->getValue());
129134
$this->tokenProvider->deleteTokenBySeries($series);
130135
}

‎src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentRememberMeHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentRememberMeHandlerTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ public function testClearRememberMeCookie()
7474
$this->assertNull($cookie->getValue());
7575
}
7676

77+
public function testClearRememberMeCookieMalformedCookie()
78+
{
79+
$this->tokenProvider->expects($this->exactly(0))
80+
->method('deleteTokenBySeries');
81+
82+
$this->request->cookies->set('REMEMBERME', 'malformed');
83+
84+
$this->handler->clearRememberMeCookie();
85+
86+
$this->assertTrue($this->request->attributes->has(ResponseListener::COOKIE_ATTR_NAME));
87+
88+
/** @var Cookie $cookie */
89+
$cookie = $this->request->attributes->get(ResponseListener::COOKIE_ATTR_NAME);
90+
$this->assertNull($cookie->getValue());
91+
}
92+
7793
public function testConsumeRememberMeCookieValid()
7894
{
7995
$this->tokenProvider->expects($this->any())

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.