8000 Merge branch '6.4' into 7.1 · symfony/symfony@597e48c · GitHub
[go: up one dir, main page]

Skip to content

Commit 597e48c

Browse files
Merge branch '6.4' into 7.1
* 6.4: fix: ignore missing directory in isVendor() [OptionsResolver] Allow Union/Intersection Types in Resolved Closures Issue #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 37fa43f + 10be4d6 commit 597e48c

File tree

11 files changed

+58
-10
lines changed

11 files changed

+58
-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
@@ -130,7 +130,7 @@
130130
"async-aws/sns": "^1.0",
131131
"cache/integration-tests": "dev-master",
132132
"doctrine/collections": "^1.0|^2.0",
133-
"doctrine/data-fixtures": "^1.1",
133+
"doctrine/data-fixtures": "^1.1|^2",
134134
"doctrine/dbal": "^3.6|^4",
135135
"doctrine/orm": "^2.15|^3",
136136
"dragonmantank/cron-expression": "^3.1",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function validate(mixed $value, Constraint $constraint): void
105105

106106
$criteria[$fieldName] = $fieldValue;
107107

108-
if (null !== $criteria[$fieldName] && $class->hasAssociation($fieldName)) {
108+
if (\is_object($criteria[$fieldName]) && $class->hasAssociation($fieldName)) {
109109
/* Ensure the Proxy is initialized before using reflection to
110110
* read its identifiers. This is necessary because the wrapped
111111
* 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": "^6.4|^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": "^3.6|^4",
4949
"doctrine/orm": "^2.15|^3",
5050
"psr/log": "^1|^2|^3"

src/Symfony/Component/AssetMapper/Factory/MappedAssetFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ private function isVendor(string $sourcePath): bool
129129
$sourcePath = realpath($sourcePath);
130130
$vendorDir = realpath($this->vendorDir);
131131

132-
return $sourcePath && str_starts_with($sourcePath, $vendorDir);
132+
return $sourcePath && $vendorDir && str_starts_with($sourcePath, $vendorDir);
133133
}
134134
}

src/Symfony/Component/AssetMapper/Tests/Factory/MappedAssetFactoryTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
class MappedAssetFactoryTest extends TestCase
2828
{
29+
private const DEFAULT_FIXTURES = __DIR__.'/../Fixtures/assets/vendor';
30+
2931
private AssetMapperInterface&MockObject $assetMapper;
3032

3133
public function testCreateMappedAsset()
@@ -137,7 +139,15 @@ public function testCreateMappedAssetInVendor()
137139
$this->assertTrue($asset->isVendor);
138140
}
139141

140-
private function createFactory(?AssetCompilerInterface $extraCompiler = null): MappedAssetFactory
142+
public function testCreateMappedAssetInMissingVendor()
143+
{
144+
$assetMapper = $this->createFactory(null, '/this-path-does-not-exist/');
145+
$asset = $assetMapper->createMappedAsset('lodash.js', __DIR__.'/../Fixtures/assets/vendor/lodash/lodash.index.js');
146+
$this->assertSame('lodash.js', $asset->logicalPath);
147+
$this->assertFalse($asset->isVendor);
148+
}
149+
150+
private function createFactory(?AssetCompilerInterface $extraCompiler = null, ?string $vendorDir = self::DEFAULT_FIXTURES): MappedAssetFactory
141151
{
142152
$compilers = [
143153
new JavaScriptImportPathCompiler($this->createMock(ImportMapConfigReader::class)),
@@ -162,7 +172,7 @@ private function createFactory(?AssetCompilerInterface $extraCompiler = null): M
162172
$factory = new MappedAssetFactory(
163173
$pathResolver,
164174
$compiler,
165-
__DIR__.'/../Fixtures/assets/vendor',
175+
$vendorDir,
166176
);
167177

168178
// mock the AssetMapper to behave like normal: by calling back to the factory

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
353353
$resource = new ClassExistenceResource($class, false);
354354
$classReflector = $resource->isFresh(0) ? false : new \ReflectionClass($class);
355355
} else {
356-
$classReflector = class_exists($class) ? new \ReflectionClass($class) : false;
356+
$classReflector = class_exists($class) || interface_exists($class, false) ? new \ReflectionClass($class) : false;
357357
}
358358
} catch (\ReflectionException $e) {
359359
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;
@@ -705,7 +706,11 @@ private function getTraceKey(Request $request): string
705706
$path .= '?'.$qs;
706707
}
707708

708-
return $request->getMethod().' '.$path;
709+
try {
710+
return $request->getMethod().' '.$path;
711+
} catch (SuspiciousOperationException) {
712+
return '_BAD_METHOD_ '.$path;
713+
}
709714
}
710715

711716
/**

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

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

111+
public function testPassesSuspiciousMethodRequests()
112+
{
113+
$this->setNextResponse(200);
114+
$this->request('POST', '/', ['HTTP_X-HTTP-Method-Override' => '__CONSTRUCT']);
115+
$this->assertHttpKernelIsCalled();
116+
$this->assertResponseOk();
117+
$this->assertTraceNotContains('stale');
118+
$this->assertTraceNotContains('invalid');
119+
$this->assertFalse($this->response->headers->has('Age'));
120+
}
121+
111122
public function testInvalidatesOnPostPutDeleteRequests()
112123
{
113124
foreach (['post', 'put', 'delete'] as $method) {

src/Symfony/Component/OptionsResolver/OptionsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function setDefault(string $option, mixed $value): static
232232
return $this;
233233
}
234234

235-
if (isset($params[0]) && null !== ($type = $params[0]->getType()) && self::class === $type->getName() && (!isset($params[1]) || (($type = $params[1]->getType()) instanceof \ReflectionNamedType && Options::class === $type->getName()))) {
235+
if (isset($params[0]) && ($type = $params[0]->getType()) instanceof \ReflectionNamedType && self::class === $type->getName() && (!isset($params[1]) || (($type = $params[1]->getType()) instanceof \ReflectionNamedType && Options::class === $type->getName()))) {
236236
// Store closure for later evaluation
237237
$this->nested[$option][] = $value;
238238
$this->defaults[$option] = [];

src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,28 @@ public function testClosureWithoutParametersNotInvoked()
159159
$this->assertSame(['foo' => $closure], $this->resolver->resolve());
160160
}
161161

162+
public function testClosureWithUnionTypesNotInvoked()
163+
{
164+
$closure = function (int|string|null $value) {
165+
Assert::fail('Should not be called');
166+
};
167+
168+
$this->resolver->setDefault('foo', $closure);
169+
170+
$this->assertSame(['foo' => $closure], $this->resolver->resolve());
171+
}
172+
173+
public function testClosureWithIntersectionTypesNotInvoked()
174+
{
175+
$closure = function (\Stringable&\JsonSerializable $value) {
176+
Assert::fail('Should not be called');
177+
};
178+
179+
$this->resolver->setDefault('foo', $closure);
180+
181+
$this->assertSame(['foo' => $closure], $this->resolver->resolve());
182+
}
183+
162184
public function testAccessPreviousDefaultValue()
163185
{
164186
// defined by superclass

0 commit comments

Comments
 (0)
0