Skip to content

[FrameworkBundle] Fix Workflow without a marking store definition uses marking store definition of previously defined workflow #50362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy