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 4166a07

Browse filesBrowse files
committed
added checks for public services on compiler passes that use service id and not references
1 parent 418944b commit 4166a07
Copy full SHA for 4166a07

File tree

3 files changed

+23
-3
lines changed
Filter options

3 files changed

+23
-3
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConstraintValidatorsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConstraintValidatorsPass.php
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ public function process(ContainerBuilder $container)
2828
$validators[$attributes[0]['alias']] = $id;
2929
}
3030

31-
$validators[$container->getDefinition($id)->getClass()] = $id;
31+
$definition = $container->getDefinition($id);
32+
33+
if (!$definition->isPublic()) {
34+
throw new InvalidArgumentException(sprintf('The service "%s" must be public as it can be lazy-loaded.', $id));
35+
}
36+
37+
if ($definition->isAbstract()) {
38+
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as it can be lazy-loaded.', $id));
39+
}
40+
41+
$validators[$definition->getClass()] = $id;
3242
}
3343

3444
$container->getDefinition('validator.validator_factory')->replaceArgument(1, $validators);

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function build(ContainerBuilder $container)
7676
// but as late as possible to get resolved parameters
7777
$container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
7878
$container->addCompilerPass(new TemplatingPass());
79-
$container->addCompilerPass(new AddConstraintValidatorsPass());
79+
$container->addCompilerPass(new AddConstraintValidatorsPass(), PassConfig::TYPE_BEFORE_REMOVING);
8080
$container->addCompilerPass(new AddValidatorInitializersPass());
8181
$container->addCompilerPass(new AddConsoleCommandPass());
8282
$container->addCompilerPass(new FormPass());

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ public function process(ContainerBuilder $container)
2828
$definition = $container->getDefinition('twig.runtime_loader');
2929
$mapping = array();
3030
foreach ($container->findTaggedServiceIds('twig.runtime') as $id => $attributes) {
31-
$mapping[$container->getDefinition($id)->getClass()] = $id;
31+
$def = $container->getDefinition($id);
32+
33+
if (!$def->isPublic()) {
34+
throw new InvalidArgumentException(sprintf('The service "%s" must be public as it can be lazy-loaded.', $id));
35+
}
36+
37+
if ($def->isAbstract()) {
38+
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as it can be lazy-loaded.', $id));
39+
}
40+
41+
$mapping[$def->getClass()] = $id;
3242
}
3343

3444
$definition->replaceArgument(1, $mapping);

0 commit comments

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