10BC0 [FrameworkBundle] Fix Workflow without a marking store definition uses marking store definition of previously defined workflow by krciga22 · Pull Request #50362 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits 8000
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Fix Workflow without a marking store definition use…
…s marking store definition of previously defined workflow
  • Loading branch information
krciga22 authored and nicolas-grekas committed May 19, 2023
commit 9cc5cbfd585ed922992aba514c7f1f505593cb59
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
$workflows[$workflowId] = $definitionDefinition;

// Create MarkingStore
$markingStoreDefinition = null;
if (isset($workflow['marking_store']['type'])) {
$markingStoreDefinition = new ChildDefinition('workflow.marking_store.method');
$markingStoreDefinition->setArguments([
Expand All @@ -933,7 +934,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
// Create Workflow
$workflowDefinition = new ChildDefinition(sprintf('%s.abstract', $type));
$workflowDefinition->replaceArgument(0, new Reference(sprintf('%s.definition', $workflowId)));
$workflowDefinition->replaceArgument(1, $markingStoreDefinition ?? null);
$workflowDefinition->replaceArgument(1, $markingStoreDefinition);
$workflowDefinition->replaceArgument(3, $name);
$workflowDefinition->replaceArgument(4, $workflow['events_to_dispatch']);
$workflowDefinition->addTag('container.private', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,62 @@ public function testWorkflowValidationStateMachine()
});
}

public function testWorkflowDefaultMarkingStoreDefinition()
{
$container = $this->createContainerFromClosure(function ($container) {
$container->loadFromExtension('framework', [
'workflows' => [
'workflow_a' => [
'type' => 'state_machine',
'marking_store' => [
'type' => 'method',
'property' => 'status',
],
'supports' => [
__CLASS__,
],
'places' => [
'a',
'b',
],
'transitions' => [
'a_to_b' => [
'from' => ['a'],
'to' => ['b'],
],
],
],
'workflow_b' => [
'type' => 'state_machine',
'supports' => [
__CLASS__,
],
'places' => [
'a',
'b',
],
'transitions' => [
'a_to_b' => [
'from' => ['a'],
'to' => ['b'],
],
],
],
],
]);
});

$workflowA = $container->getDefinition('state_machine.workflow_a');
$argumentsA = $workflowA->getArguments();
$this->assertArrayHasKey('index_1', $argumentsA, 'workflow_a has a marking_store argument');
$this->assertNotNull($argumentsA['index_1'], 'workflow_a marking_store argument is not null');

$workflowB = $container->getDefinition('state_machine.workflow_b');
$argumentsB = $workflowB->getArguments();
$this->assertArrayHasKey('index_1', $argumentsB, 'workflow_b has a marking_store argument');
$this->assertNull($argumentsB['index_1'], 'workflow_b marking_store argument is null');
}

public function testRateLimiterWithLockFactory()
{
try {
Expand Down
0