8000 bug #51078 [FrameworkBundle][Workflow] Throw exception is workflow.xx… · symfony/symfony@fdf441d · GitHub
[go: up one dir, main page]

Skip to content

Commit fdf441d

Browse files
bug #51078 [FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array (lyrixx)
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | --- The following code raises a fatal error: ```yaml framework: workflows: articles: transitions: ``` <details> ``` ErrorException: Warning: foreach() argument must be of type array|object, null given at /home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/framework-bundle/DependencyInjection/Configuration.php:522 at Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration->Symfony\Bundle\FrameworkBundle\DependencyInjection\{closure}() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/Builder/ExprBuilder.php:246) at Symfony\Component\Config\Definition\Builder\ExprBuilder::Symfony\Component\Config\Definition\Builder\{closure}() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/BaseNode.php:357) at Symfony\Component\Config\Definition\BaseNode->normalize() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/ArrayNode.php:292) at Symfony\Component\Config\Definition\ArrayNode->normalizeValue() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/BaseNode.php:385) at Symfony\Component\Config\Definition\BaseNode->normalize() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/PrototypedArrayNode.php:251) at Symfony\Component\Config\Definition\PrototypedArrayNode->normalizeValue() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/BaseNode.php:385) at Symfony\Component\Config\Definition\BaseNode->normalize() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/ArrayNode.php:292) at Symfony\Component\Config\Definition\ArrayNode->normalizeValue() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/BaseNode.php:385) at Symfony\Component\Config\Definition\BaseNode->normalize() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/ArrayNode.php:292) at Symfony\Component\Config\Definition\ArrayNode->normalizeValue() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/BaseNode.php:385) at Symfony\Component\Config\Definition\BaseNode->normalize() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/Processor.php:32) at Symfony\Component\Config\Definition\Processor->process() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/config/Definition/Processor.php:46) at Symfony\Component\Config\Definition\Processor->processConfiguration() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/dependency-injection/Extension/Extension.php:109) at Symfony\Component\DependencyInjection\Extension\Extension->processConfiguration() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/framework-bundle/DependencyInjection/FrameworkExtension.php:259) at Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension->load() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php:76) at Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass->process() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php:45) at Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass->process() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/dependency-injection/Compiler/Compiler.php:80) at Symfony\Component\DependencyInjection\Compiler\Compiler->compile() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/dependency-injection/ContainerBuilder.php:767) at Symfony\Component\DependencyInjection\ContainerBuilder->compile() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/http-kernel/Kernel.php:506) at Symfony\Component\HttpKernel\Kernel->initializeContainer() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/http-kernel/Kernel.php:757) at Symfony\Component\HttpKernel\Kernel->preBoot() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/http-kernel/Kernel.php:185) at Symfony\Component\HttpKernel\Kernel->handle() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/autoload_runtime.php:29) at require_once('/home/gregoire/dev/github.com/Faume-co/modules-shopify/vendor/autoload_runtime.php') (/home/gregoire/dev/github.co 8000 m/Faume-co/modules-shopify/public/index.php:5) ``` </details> Commits ------- f585930 [FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array
2 parents b69cde8 + f585930 commit fdf441d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
446446
->beforeNormalization()
447447
->always()
448448
->then(function ($places) {
449+
if (!\is_array($places)) {
450+
throw new InvalidConfigurationException('The "places" option must be an array in workflow configuration.');
451+
}
452+
449453
// It's an indexed array of shape ['place1', 'place2']
450454
if (isset($places[0]) && \is_string($places[0])) {
451455
return array_map(function (string $place) {
@@ -491,6 +495,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
491495
->beforeNormalization()
492496
->always()
493497
->then(function ($transitions) {
498+
if (!\is_array($transitions)) {
499+
throw new InvalidConfigurationException('The "transitions" option must be an array in workflow configuration.');
500+
}
501+
494502
// It's an indexed array, we let the validation occur
495503
if (isset($transitions[0]) && \is_array($transitions[0])) {
496504
return $transitions;

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
1313

14+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1415
use Symfony\Component\Config\FileLocator;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Exception\LogicException;
@@ -56,6 +57,36 @@ public function testAssetPackageCannotHavePathAndUrl()
5657
});
5758
}
5859

60+
public function testWorkflowValidationPlacesIsArray()
61+
{
62+
$this->expectException(InvalidConfigurationException::class);
63+
$this->expectExceptionMessage('The "places" option must be an array in workflow configuration.');
64+
$this->createContainerFromClosure(function ($container) {
65+
$container->loadFromExtension('framework', [
66+
'workflows' => [
67+
'article' => [
68+
'places' => null,
69+
],
70+
],
71+
]);
72+
});
73+
}
74+
75+
public function testWorkflowValidationTransitonsIsArray()
76+
{
77+
$this->expectException(InvalidConfigurationException::class);
78+
$this->expectExceptionMessage('The "transitions" option must be an array in workflow configuration.');
79+
$this->createContainerFromClosure(function ($container) {
80+
$container->loadFromExtension('framework', [
81+
'workflows' => [
82+
'article' => [
83+
'transitions' => null,
84+
],
85+
],
86+
]);
87+
});
88+
}
89+
5990
public function testWorkflowValidationStateMachine()
6091
{
6192
$this->expectException(InvalidDefinitionException::class);

0 commit comments

Comments
 (0)
0