Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commita19d1e5

Browse files
bug#25160 [DI] Prevent a ReflectionException during cache:clear when the parent class doesn't exist (dunglas)
This PR was squashed before being merged into the 3.4 branch (closes#25160).Discussion----------[DI] Prevent a ReflectionException during cache:clear when the parent class doesn't exist| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks? | no| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->| Tests pass? | yes| Fixed tickets | n/a| License | MIT| Doc PR | n/aCurrently, if you just run the following commands:```composer create-project -s beta symfony/skeleton:^3.4 testcomposer req orm```You get the following error:```In UniqueEntityValidator.php line 27: [ReflectionException] Class Symfony\Component\Validator\ConstraintValidator not found````UniqueEntityValidator` is in the bridge, but it's parent class is in the validator (that is not installed by default). The hot path optimization feature (enabled by default) uses reflection, and the reflection API throws an exception in this specific case.This PR fixes the error.Commits-------6e622c6 [DI] Prevent a ReflectionException during cache:clear when the parent class doesn't exist
2 parentsd954af5 +6e622c6 commita19d1e5

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

‎src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private function collectLineage($class, array &$lineage)
378378
if (isset($lineage[$class])) {
379379
return;
380380
}
381-
if (!$r =$this->container->getReflectionClass($class)) {
381+
if (!$r =$this->container->getReflectionClass($class,false)) {
382382
return;
383383
}
384384
if ($this->containerinstanceof$class) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespaceSymfony\Component\DependencyInjection\Tests\Fixtures;
4+
5+
class ParentNotExistsextends \NotExists
6+
{
7+
}

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container_inline_requires.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
useSymfony\Component\DependencyInjection\Dumper\PhpDumper;
88
useSymfony\Component\DependencyInjection\Reference;
99
useSymfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath;
10+
useSymfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists;
1011

1112
$container =newContainerBuilder();
1213

1314
$container->register(HotPath\C1::class)->addTag('container.hot_path')->setPublic(true);
1415
$container->register(HotPath\C2::class)->addArgument(newReference(HotPath\C3::class))->setPublic(true);
1516
$container->register(HotPath\C3::class);
17+
$container->register(ParentNotExists::class)->setPublic(true);
1618

1719
return$container;

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/container_inline_requires.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public function __construct()
3232
'symfony\\component\\dependencyinjection\\tests\\fixtures\\includes\\hotpath\\c1' =>'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C1',
3333
'symfony\\component\\dependencyinjection\\tests\\fixtures\\includes\\hotpath\\c2' =>'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2',
3434
'symfony\\component\\dependencyinjection\\tests\\fixtures\\includes\\hotpath\\c3' =>'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C3',
35+
'symfony\\component\\dependencyinjection\\tests\\fixtures\\parentnotexists' =>'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\ParentNotExists',
3536
);
3637
$this->methodMap =array(
38+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\ParentNotExists' =>'getParentNotExistsService',
3739
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C1' =>'getC1Service',
3840
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2' =>'getC2Service',
3941
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C3' =>'getC3Service',
@@ -75,6 +77,16 @@ public function isFrozen()
7577
returntrue;
7678
}
7779

80+
/**
81+
* Gets the public 'Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists' shared service.
82+
*
83+
* @return \Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists
84+
*/
85+
protectedfunctiongetParentNotExistsService()
86+
{
87+
return$this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists'] =new \Symfony\Component\DependencyInjection\Tests\Fixtures\ParentNotExists();
88+
}
89+
7890
/**
7991
* Gets the public 'Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C1' shared service.
8092
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp