Skip to content

Commit 2810e72

Browse files
Merge branch '3.2'
* 3.2: (51 commits) [FrameworkBundle] [Workflow] Fix service marking store configuration Fix merge [Validator] add class name to the cache key [Serializer] Remove AbstractObjectNormalizer::isAttributeToNormalize Throw less misleading exception when property access not found [Twig] Fix deprecations with Twig 1.29 [FrameworkBundle] Fix validation cache warmer with failing or missing classes Fixed typo [FrameworkBundle] Removed the kernel.debug parameter from the cache pool namespace seed Fix email address fix the docblock in regard to the role argument [Bridge\Twig] Trigger deprecation when using FormExtension::$renderer Don't use the "app" global variable in the profiler [VarDumper] fix tests when xdebug is enabled Fix merge FIXED NON EXISTING TYPE DECLARATION [Form] Add failing test for data collector bug [Cache] Fix dumping SplDoublyLinkedList iter mode [Form] Fix FormDataCollector Ignore missing 'debug.file_link_formatter' service in Debug and Twig bundles ...
2 parents af9cfe7 + 2309ec5 commit 2810e72

File tree

16 files changed

+117
-16
lines changed

16 files changed

+117
-16
lines changed

CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,19 @@ public function warmUp($cacheDir)
6666

6767
$arrayPool = new ArrayAdapter(0, false);
6868
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayPool));
69-
70-
foreach ($annotatedClasses as $class) {
71-
$this->readAllComponents($reader, $class);
69+
$throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); };
70+
spl_autoload_register($throwingAutoloader);
71+
72+
try {
73+
foreach ($annotatedClasses as $class) {
74+
try {
75+
$this->readAllComponents($reader, $class);
76+
} catch (\ReflectionException $e) {
77+
// ignore failing reflection
78+
}
79+
}
80+
} finally {
81+
spl_autoload_unregister($throwingAutoloader);
7282
}
7383

7484
$values = $arrayPool->getValues();

CacheWarmer/ValidatorCacheWarmer.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,23 @@ public function warmUp($cacheDir)
6666
$loaders = $this->validatorBuilder->getLoaders();
6767
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayPool));
6868

69-
foreach ($this->extractSupportedLoaders($loaders) as $loader) {
70-
foreach ($loader->getMappedClasses() as $mappedClass) {
71-
if ($metadataFactory->hasMetadataFor($mappedClass)) {
72-
$metadataFactory->getMetadataFor($mappedClass);
69+
$throwingAutoloader = function ($class) { throw new \ReflectionException(sprintf('Class %s does not exist', $class)); };
70+
spl_autoload_register($throwingAutoloader);
71+
72+
try {
73+
foreach ($this->extractSupportedLoaders($loaders) as $loader) {
74+
foreach ($loader->getMappedClasses() as $mappedClass) {
75+
try {
76+
if ($metadataFactory->hasMetadataFor($mappedClass)) {
77+
$metadataFactory->getMetadataFor($mappedClass);
78+
}
79+
} catch (\ReflectionException $e) {
80+
// ignore failing reflection
81+
}
7382
}
7483
}
84+
} finally {
85+
spl_autoload_unregister($throwingAutoloader);
7586
}
7687

7788
$values = $arrayPool->getValues();

Command/ConfigDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080

8181
$this->validateConfiguration($extension, $configuration);
8282

83-
$configs = $container->getParameterBag()->resolveValue($configs);
83+
$configs = $container->resolveEnvPlaceholders($container->getParameterBag()->resolveValue($configs));
8484

8585
$processor = new Processor();
8686
$config = $processor->processConfiguration($configuration, $configs);

Command/ContainerDebugCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Style\SymfonyStyle;
2020
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2121
use Symfony\Component\DependencyInjection\ContainerBuilder;
22+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
2223
use Symfony\Component\Config\FileLocator;
2324

2425
/**
@@ -96,7 +97,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
9697
$object = $this->getContainerBuilder();
9798

9899
if ($input->getOption('parameters')) {
99-
$object = $object->getParameterBag();
100+
$parameters = array();
101+
foreach ($object->getParameterBag()->all() as $k => $v) {
102+
$parameters[$k] = $object->resolveEnvPlaceholders($v);
103+
}
104+
$object = new ParameterBag($parameters);
100105
$options = array();
101106
} elseif ($parameter = $input->getOption('parameter')) {
102107
$options = array('parameter' => $parameter);

Console/Descriptor/Descriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function describe(OutputInterface $output, $object, array $options = arra
5757
$this->describeContainerService($this->resolveServiceDefinition($object, $options['id']), $options);
5858
break;
5959
case $object instanceof ContainerBuilder && isset($options['parameter']):
60-
$this->describeContainerParameter($object->getParameter($options['parameter']), $options);
60+
$this->describeContainerParameter($object->resolveEnvPlaceholders($object->getParameter($options['parameter'])), $options);
6161
break;
6262
case $object instanceof ContainerBuilder:
6363
$this->describeContainerServices($object, $options);

DependencyInjection/Compiler/CachePoolPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function process(ContainerBuilder $container)
3434
} else {
3535
$seed = '_'.$container->getParameter('kernel.root_dir');
3636
}
37-
$seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
37+
$seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment');
3838

3939
$aliases = $container->getAliases();
4040
$attributes = array(

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
268268
->thenInvalid('"type" and "service" cannot be used together.')
269269
->end()
270270
->validate()
271-
->ifTrue(function ($v) { return isset($v['arguments']) && isset($v['service']); })
271+
->ifTrue(function ($v) { return !empty($v['arguments']) && isset($v['service']); })
272272
->thenInvalid('"arguments" and "service" cannot be used together.')
273273
->end()
274274
->end()

Routing/Router.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ private function resolve($value)
146146
return '%%';
147147
}
148148

149+
if (preg_match('/^env\(\w+\)$/', $match[1])) {
150+
throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1]));
151+
}
152+
149153
$resolved = $container->getParameter($match[1]);
150154

151155
if (is_string($resolved) || is_numeric($resolved)) {

Tests/DependencyInjection/Compiler/CachePoolPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testNamespaceArgumentIsReplaced()
4545

4646
$this->cachePoolPass->process($container);
4747

48-
$this->assertSame('C42Pcl9VBJ', $cachePool->getArgument(0));
48+
$this->assertSame('D07rhFx97S', $cachePool->getArgument(0));
4949
}
5050

5151
public function testArgsAreReplaced()
@@ -69,7 +69,7 @@ public function testArgsAreReplaced()
6969

7070
$this->assertInstanceOf(Reference::class, $cachePool->getArgument(0));
7171
$this->assertSame('foobar', (string) $cachePool->getArgument(0));
72-
$this->assertSame('KO3xHaFEZU', $cachePool->getArgument(1));
72+
$this->assertSame('itantF+pIq', $cachePool->getArgument(1));
7373
$this->assertSame(3, $cachePool->getArgument(2));
7474
}
7575

Tests/DependencyInjection/Fixtures/php/workflows.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,23 @@
8888
),
8989
),
9090
),
91+
'service_marking_store_workflow' => array(
92+
'marking_store' => array(
93+
'service' => 'workflow_service',
94+
),
95+
'supports' => array(
96+
FrameworkExtensionTest::class,
97+
),
98+
'places' => array(
99+
'first',
100+
'last',
101+
),
102+
'transitions' => array(
103+
'go' => array(
104+
'from' => 'first',
105+
'to' => 'last',
106+
),
107+
),
108+
),
91109
),
92110
));

Tests/DependencyInjection/Fixtures/xml/workflows.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,16 @@
7979
<framework:to>review</framework:to>
8080
</framework:transition>
8181
</framework:workflow>
82+
83+
<framework:workflow name="service_marking_store_workflow">
84+
<framework:marking-store service="workflow_service"/>
85+
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
86+
<framework:place>first</framework:place>
87+
<framework:place>last</framework:place>
88+
<framework:transition name="go">
89+
<framework:from>first</framework:from>
90+
<framework:to>last</framework:to>
91+
</framework:transition>
92+
</framework:workflow>
8293
</framework:config>
8394
</container>

Tests/DependencyInjection/Fixtures/yml/workflows.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,17 @@ framework:
6363
reopen:
6464
from: closed
6565
to: review
66+
service_marking_store_workflow:
67+
marking_store:
68+
service: workflow_service
69+
supports:
70+
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
71+
places:
72+
- first
73+
- last
74+
transitions:
75+
go:
76+
from:
77+
- first
78+
to:
79+
- last

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ public function testWorkflows()
165165
$this->assertSame(array('workflow.definition' => array(array('name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state'))), $stateMachineDefinition->getTags());
166166
$this->assertCount(9, $stateMachineDefinition->getArgument(1));
167167
$this->assertSame('start', $stateMachineDefinition->getArgument(2));
168+
169+
$serviceMarkingStoreWorkflowDefinition = $container->getDefinition('workflow.service_marking_store_workflow');
170+
/** @var Reference $markingStoreRef */
171+
$markingStoreRef = $serviceMarkingStoreWorkflowDefinition->getArgument(1);
172+
$this->assertInstanceOf(Reference::class, $markingStoreRef);
173+
$this->assertEquals('workflow_service', (string) $markingStoreRef);
168174
}
169175

170176
/**

Tests/Fixtures/Validation/Article.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation;
4+
5+
class Article implements NotExistingInterface
6+
{
7+
public $category;
8+
}

Tests/Fixtures/Validation/Resources/person.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
</property>
1717
</class>
1818

19-
<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\NonExistentClass">
20-
<property name="gender">
19+
<class name="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Article">
20+
<property name="category">
2121
<constraint name="Choice">
2222
<option name="choices">
2323
<value>other</value>

Tests/Routing/RouterTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ public function testPatternPlaceholders()
131131
);
132132
}
133133

134+
/**
135+
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
136+
* @expectedExceptionMessage Using "%env(FOO)%" is not allowed in routing configuration.
137+
*/
138+
public function testEnvPlaceholders()
139+
{
140+
$routes = new RouteCollection();
141+
142+
$routes->add('foo', new Route('/%env(FOO)%'));
143+
144+
$router = new Router($this->getServiceContainer($routes), 'foo');
145+
$router->getRouteCollection();
146+
}
147+
134148
public function testHostPlaceholders()
135149
{
136150
$routes = new RouteCollection();

0 commit comments

Comments
 (0)