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 23d2574

Browse filesBrowse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Security] Replace message data in JSON security error response [Security] Replace message data in JSON security error response [DI] Skip deprecated definitions in CheckTypeDeclarationsPass [Messenger][AmazonSqs] Fix auto-setup for fifo queue [DoctrineBridge] Take into account that indexBy="person_id" could be a db column name, for a referenced entity
2 parents fa87194 + c702c47 commit 23d2574
Copy full SHA for 23d2574

File tree

12 files changed

+94
-7
lines changed
Filter options

12 files changed

+94
-7
lines changed

‎src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ public function getTypes(string $class, string $property, array $context = [])
104104
/** @var ClassMetadataInfo $subMetadata */
105105
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($fieldName);
106106
$subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
107-
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
107+
108+
//Not a property, maybe a column name?
109+
if (null === ($typeOfField = $subMetadata->getTypeOfField($indexProperty))) {
110+
$fieldName = $subMetadata->getFieldForColumn($indexProperty);
111+
$typeOfField = $subMetadata->getTypeOfField($fieldName);
112+
}
108113
}
109114
}
110115

‎src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function testGetProperties()
7171
'indexedByDt',
7272
'indexedByCustomType',
7373
'indexedBuz',
74+
'dummyGeneratedValueList',
7475
]);
7576

7677
$this->assertEquals(
@@ -198,6 +199,14 @@ public function typesProvider()
198199
new Type(Type::BUILTIN_TYPE_STRING),
199200
new Type(Type::BUILTIN_TYPE_OBJECT, false, DoctrineRelation::class)
200201
)]],
202+
['dummyGeneratedValueList', [new Type(
203+
Type::BUILTIN_TYPE_OBJECT,
204+
false,
205+
'Doctrine\Common\Collections\Collection',
206+
true,
207+
new Type(Type::BUILTIN_TYPE_INT),
208+
new Type(Type::BUILTIN_TYPE_OBJECT, false, DoctrineRelation::class)
209+
)]],
201210
['json', null],
202211
];
203212

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,9 @@ class DoctrineDummy
142142
* @Column(type="json", nullable=true)
143143
*/
144144
private $json;
145+
146+
/**
147+
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="dummyRelation", indexBy="gen_value_col_id", orphanRemoval=true)
148+
*/
149+
protected $dummyGeneratedValueList;
145150
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineGeneratedValue.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\ORM\Mapping\Entity;
1616
use Doctrine\ORM\Mapping\GeneratedValue;
1717
use Doctrine\ORM\Mapping\Id;
18+
use Doctrine\ORM\Mapping\OneToMany;
1819

1920
/**
2021
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -34,4 +35,15 @@ class DoctrineGeneratedValue
3435
* @Column
3536
*/
3637
public $foo;
38+
39+
/**
40+
* @var int
41+
* @Column(type="integer", name="gen_value_col_id")
42+
*/
43+
public $valueId;
44+
45+
/**
46+
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="generatedValueRelation", indexBy="rguid_column", orphanRemoval=true)
47+
*/
48+
protected $relationList;
3749
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\ORM\Mapping\Entity;
1616
use Doctrine\ORM\Mapping\Id;
1717
use Doctrine\ORM\Mapping\ManyToOne;
18+
use Doctrine\ORM\Mapping\JoinColumn;
1819

1920
/**
2021
* @Entity
@@ -60,4 +61,15 @@ class DoctrineRelation
6061
* @ManyToOne(targetEntity="DoctrineDummy", inversedBy="indexedBuz")
6162
*/
6263
protected $buzField;
64+
65+
/**
66+
* @ManyToOne(targetEntity="DoctrineDummy", inversedBy="dummyGeneratedValueList")
67+
*/
68+
private $dummyRelation;
69+
70+
/**
71+
* @ManyToOne(targetEntity="DoctrineGeneratedValue", inversedBy="relationList")
72+
* @JoinColumn(name="gen_value_col_id", referencedColumnName="gen_value_col_id")
73+
*/
74+
private $generatedValueRelation;
6375
}

‎src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function processValue($value, $isRoot = false)
8484
return $value;
8585
}
8686

87-
if (!$value instanceof Definition || $value->hasErrors()) {
87+
if (!$value instanceof Definition || $value->hasErrors() || $value->isDeprecated()) {
8888
return parent::processValue($value, $isRoot);
8989
}
9090

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarMethodCall;
2525
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgument;
2626
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgumentNotNull;
27+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Deprecated;
2728
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo;
2829
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
2930
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructor;
@@ -720,6 +721,19 @@ public function testProcessSkipSkippedIds()
720721
$this->addToAssertionCount(1);
721722
}
722723

724+
public function testProcessSkipsDeprecatedDefinitions()
725+
{
726+
$container = new ContainerBuilder();
727+
$container
728+
->register('foobar', Deprecated::class)
729+
->setDeprecated(true)
730+
;
731+
732+
(new CheckTypeDeclarationsPass(true))->process($container);
733+
734+
$this->addToAssertionCount(1);
735+
}
736+
723737
public function testProcessHandleClosureForCallable()
724738
{
725739
$closureDefinition = new Definition(\Closure::class);
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
trigger_deprecation('foo/bar', '1.2.3', 'Deprecated class.');
6+
7+
class Deprecated
8+
{
9+
}

‎src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ public function setup(): void
276276
$parameters = ['QueueName' => $this->configuration['queue_name']];
277277

278278
if (self::isFifoQueue($this->configuration['queue_name'])) {
279-
$parameters['FifoQueue'] = true;
279+
$parameters['Attributes'] = [
280+
'FifoQueue' => 'true',
281+
];
280282
}
281283

282284
$this->client->createQueue($parameters);

‎src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
126126
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
127127
{
128128
if (null === $this->failureHandler) {
129-
$errorMessage = $exception->getMessageKey();
130-
131129
if (null !== $this->translator) {
132130
$errorMessage = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(), 'security');
131+
} else {
132+
$errorMessage = strtr($exception->getMessageKey(), $exception->getMessageData());
133133
}
134134

135135
return new JsonResponse(['error' => $errorMessage], JsonResponse::HTTP_UNAUTHORIZED);

‎src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ private function onFailure(Request $request, AuthenticationException $failed): R
188188
}
189189

190190
if (!$this->failureHandler) {
191-
$errorMessage = $failed->getMessageKey();
192-
193191
if (null !== $this->translator) {
194192
$errorMessage = $this->translator->trans($failed->getMessageKey(), $failed->getMessageData(), 'security');
193+
} else {
194+
$errorMessage = strtr($failed->getMessageKey(), $failed->getMessageData());
195195
}
196196

197197
return new JsonResponse(['error' => $errorMessage], 401);

‎src/Symfony/Component/Security/Http/Tests/Authenticator/JsonLoginAuthenticatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Authenticator/JsonLoginAuthenticatorTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,25 @@ public function testAuthenticationFailureWithTranslator()
147147
$this->assertSame(['error' => 'foo'], json_decode($response->getContent(), true));
148148
}
149149

150+
public function testOnFailureReplacesMessageDataWithoutTranslator()
151+
{
152+
$this->setUpAuthenticator();
153+
154+
$response = $this->authenticator->onAuthenticationFailure(new Request(), new class() extends AuthenticationException {
155+
public function getMessageData(): array
156+
{
157+
return ['%failed_attempts%' => 3];
158+
}
159+
160+
public function getMessageKey(): string
161+
{
162+
return 'Session locked after %failed_attempts% failed attempts.';
163+
}
164+
});
165+
166+
$this->assertSame(['error' => 'Session locked after 3 failed attempts.'], json_decode($response->getContent(), true));
167+
}
168+
150169
private function setUpAuthenticator(array $options = [])
151170
{
152171
$this->authenticator = new JsonLoginAuthenticator(new HttpUtils(), $this->userProvider, null, null, $options);

0 commit comments

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