diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e6ccb4cd..aa1b9cbf 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1202,7 +1202,7 @@ $request = new SignalExternalWorkflow( $this->getOptions()->namespace, $execution->getID(), - $execution->getRunID(), + null, $name, EncodedValues::fromValues($args), true, diff --git a/src/Workflow/ContinueAsNewOptions.php b/src/Workflow/ContinueAsNewOptions.php index 2bda8709..08af4bfb 100644 --- a/src/Workflow/ContinueAsNewOptions.php +++ b/src/Workflow/ContinueAsNewOptions.php @@ -18,6 +18,7 @@ use Temporal\Internal\Support\DateInterval; use Temporal\Worker\WorkerFactoryInterface; use Temporal\Worker\Worker; +use Temporal\Workflow; /** * @psalm-import-type DateIntervalValue from DateInterval @@ -55,6 +56,12 @@ public function __construct() { $this->workflowRunTimeout = CarbonInterval::seconds(0); $this->workflowTaskTimeout = CarbonInterval::seconds(0); + try { + // Inherit TaskQueue from the current Workflow if possible + $this->taskQueue = Workflow::getInfo()->taskQueue; + } catch (\Throwable) { + // Do nothing + } } /** diff --git a/tests/Fixtures/src/Workflow/ContinuaWithTaskQueueWorkflow.php b/tests/Fixtures/src/Workflow/ContinuaWithTaskQueueWorkflow.php new file mode 100644 index 00000000..eb3beeec --- /dev/null +++ b/tests/Fixtures/src/Workflow/ContinuaWithTaskQueueWorkflow.php @@ -0,0 +1,46 @@ +withStartToCloseTimeout(5) + ); + + if ($generation > 5) { + // complete + return Workflow::getInfo()->taskQueue . $generation; + } + + if ($generation !== 1) { + assert(!empty(Workflow::getInfo()->continuedExecutionRunId)); + } + + for ($i = 0; $i < $generation; $i++) { + yield $simple->echo((string)$generation); + } + + return Workflow::newContinueAsNewStub(self::class)->handler(++$generation); + } +} diff --git a/tests/Functional/NamedArgumentsTestCase.php b/tests/Functional/NamedArgumentsTestCase.php index bcce1bab..58ca9193 100644 --- a/tests/Functional/NamedArgumentsTestCase.php +++ b/tests/Functional/NamedArgumentsTestCase.php @@ -6,6 +6,9 @@ use Temporal\Client\GRPC\ServiceClient; use Temporal\Client\WorkflowClient; +use Temporal\Client\WorkflowOptions; +use Temporal\Tests\Workflow\ContinuableWorkflow; +use Temporal\Tests\Workflow\ContinuaWithTaskQueueWorkflow; use Temporal\Tests\Workflow\NamedArguments\ContinueAsNewNamedArgumentsWorkflow; use Temporal\Tests\Workflow\NamedArguments\ExecuteChildNamedArgumentsWorkflow; use Temporal\Tests\Workflow\NamedArguments\ActivityNamedArgumentsWorkflow; @@ -213,6 +216,24 @@ public function testContinueAsNewNamedArguments() ], $result); } + /** + * TaskQueue must be inherited from the parent workflow + */ + public function testContinueAsNewTaskQueue(): void + { + $workflow = $this->workflowClient->newWorkflowStub( + ContinuaWithTaskQueueWorkflow::class, + WorkflowOptions::new()->withTaskQueue('FooBar'), + ); + + $result = $this->workflowClient->start( + $workflow, + generation: 1, + )->getResult(); + + self::assertSame('FooBar6', $result); + } + public function testExecuteChildNamedArguments() { $this->markTestSkipped(