Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70f7d05

Browse files
Merge branch '5.4' into 6.4
* 5.4: Issue symfony#58821: [DependencyInjection] Support interfaces in ContainerBuilder::getReflectionClass(). Dynamically fix compatibility with doctrine/data-fixtures v2 [HttpKernel] Ensure HttpCache::getTraceKey() does not throw exception don't call EntityManager::initializeObject() with scalar values [Validator] review italian translations Update PR template
2 parents 9bc0a8e + cf20e09 commit 70f7d05

File tree

9 files changed

+60
-10
lines changed

9 files changed

+60
-10
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| Q | A
22
| ------------- | ---
3-
| Branch? | 7.2 for features / 5.4, 6.4, and 7.1 for bug fixes <!-- see below -->
3+
| Branch? | 7.3 for features / 5.4, 6.4, 7.1, and 7.2 for bug fixes <!-- see below -->
44
| Bug fix? | yes/no
55
| New feature? | yes/no <!-- please update src/**/CHANGELOG.md files -->
66
| Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"cache/integration-tests": "dev-master",
133133
"doctrine/annotations": "^1.13.1|^2",
134134
"doctrine/collections": "^1.0|^2.0",
135-
"doctrine/data-fixtures": "^1.1",
135+
"doctrine/data-fixtures": "^1.1|^2",
136136
"doctrine/dbal": "^2.13.1|^3.0",
137137
"doctrine/orm": "^2.15|^3",
138138
"dragonmantank/cron-expression": "^3.1",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\DataFixtures;
13+
14+
use Doctrine\Common\DataFixtures\FixtureInterface;
15+
use Doctrine\Common\DataFixtures\ReferenceRepository;
16+
17+
if (method_exists(ReferenceRepository::class, 'getReferences')) {
18+
/** @internal */
19+
trait AddFixtureImplementation
20+
{
21+
public function addFixture(FixtureInterface $fixture)
22+
{
23+
$this->doAddFixture($fixture);
24+
}
25+
}
26+
} else {
27+
/** @internal */
28+
trait AddFixtureImplementation
29+
{
30+
public function addFixture(FixtureInterface $fixture): void
31+
{
32+
$this->doAddFixture($fixture);
33+
}
34+
}
35+
}

src/Symfony/Bridge/Doctrine/DataFixtures/ContainerAwareLoader.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@
2929
*/
3030
class ContainerAwareLoader extends Loader
3131
{
32+
use AddFixtureImplementation;
33+
3234
public function __construct(
3335
private readonly ContainerInterface $container,
3436
) {
3537
}
3638

37-
/**
38-
* @return void
39-
*/
40-
public function addFixture(FixtureInterface $fixture)
39+
private function doAddFixture(FixtureInterface $fixture): void
4140
{
4241
if ($fixture instanceof ContainerAwareInterface) {
4342
$fixture->setContainer($this->container);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function validate(mixed $entity, Constraint $constraint)
102102

103103
$criteria[$fieldName] = $fieldValue;
104104

105-
if (null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) {
105+
if (\is_object($criteria[$fieldName]) && $class->hasAssociation($fieldName)) {
106106
/* Ensure the Proxy is initialized before using reflection to
107107
* read its identifiers. This is necessary because the wrapped
108108
* getter methods in the Proxy are being bypassed.

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"symfony/validator": "^6.4|^7.0",
4545
"symfony/var-dumper": "^5.4|^6.0|^7.0",
4646
"doctrine/collections": "^1.0|^2.0",
47-
"doctrine/data-fixtures": "^1.1",
47+
"doctrine/data-fixtures": "^1.1|^2",
4848
"doctrine/dbal": "^2.13.1|^3|^4",
4949
"doctrine/orm": "^2.15|^3",
5050
"psr/log": "^1|^2|^3"

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
360360
$resource = new ClassExistenceResource($class, false);
361361
$classReflector = $resource->isFresh(0) ? false : new \ReflectionClass($class);
362362
} else {
363-
$classReflector = class_exists($class) ? new \ReflectionClass($class) : false;
363+
$classReflector = class_exists($class) || interface_exists($class, false) ? new \ReflectionClass($class) : false;
364364
}
365365
} catch (\ReflectionException $e) {
366366
if ($throw) {

src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace Symfony\Component\HttpKernel\HttpCache;
1919

20+
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
2021
use Symfony\Component\HttpFoundation\Request;
2122
use Symfony\Component\HttpFoundation\Response;
2223
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -725,7 +726,11 @@ private function getTraceKey(Request $request): string
725726
$path .= '?'.$qs;
726727
}
727728

728-
return $request->getMethod().' '.$path;
729+
try {
730+
return $request->getMethod().' '.$path;
731+
} catch (SuspiciousOperationException $e) {
732+
return '_BAD_METHOD_ '.$path;
733+
}
729734
}
730735

731736
/**

src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ public function testPassesOnNonGetHeadRequests()
163163
$this->assertFalse($this->response->headers->has('Age'));
164164
}
165165

166+
public function testPassesSuspiciousMethodRequests()
167+
{
168+
$this->setNextResponse(200);
169+
$this->request('POST', '/', ['HTTP_X-HTTP-Method-Override' => '__CONSTRUCT']);
170+
$this->assertHttpKernelIsCalled();
171+
$this->assertResponseOk();
172+
$this->assertTraceNotContains('stale');
173+
$this->assertTraceNotContains('invalid');
174+
$this->assertFalse($this->response->headers->has('Age'));
175+
}
176+
166177
public function testInvalidatesOnPostPutDeleteRequests()
167178
{
168179
foreach (['post', 'put', 'delete'] as $method) {

0 commit comments

Comments
 (0)