@@ -201,12 +201,6 @@ public function start(string $workflowType, ?string $instanceId = null, array $o
201201 'last_history_sequence ' => 0 ,
202202 ]);
203203
204- $ this ->seedTypedVisibilityMetadata (
205- $ run ,
206- is_array ($ memo ) ? $ memo : null ,
207- is_array ($ searchAttributes ) ? $ searchAttributes : null ,
208- );
209-
210204 $ command = WorkflowCommand::record ($ instance , $ run , $ this ->commandAttributes ($ commandContext , [
211205 'command_type ' => CommandType::Start->value ,
212206 'target_scope ' => 'instance ' ,
@@ -228,9 +222,6 @@ public function start(string $workflowType, ?string $instanceId = null, array $o
228222 'run_count ' => $ run ->run_number ,
229223 ])->save ();
230224
231- $ memoPayload = self ::visibilityMetadataPayload ($ memo );
232- $ searchAttributesPayload = self ::visibilityMetadataPayload ($ searchAttributes );
233-
234225 WorkflowHistoryEvent::record ($ run , HistoryEventType::StartAccepted, [
235226 'workflow_command_id ' => $ command ->id ,
236227 'workflow_instance_id ' => $ instance ->id ,
@@ -239,8 +230,8 @@ public function start(string $workflowType, ?string $instanceId = null, array $o
239230 'workflow_type ' => $ run ->workflow_type ,
240231 'business_key ' => $ run ->business_key ,
241232 'visibility_labels ' => $ run ->visibility_labels ,
242- 'memo ' => $ memoPayload ,
243- 'search_attributes ' => $ searchAttributesPayload ,
233+ 'memo ' => $ run -> memo ,
234+ 'search_attributes ' => $ run -> search_attributes ,
244235 'outcome ' => $ command ->outcome ?->value,
245236 ], null , $ command );
246237
@@ -252,8 +243,8 @@ public function start(string $workflowType, ?string $instanceId = null, array $o
252243 'workflow_command_id ' => $ command ->id ,
253244 'business_key ' => $ run ->business_key ,
254245 'visibility_labels ' => $ run ->visibility_labels ,
255- 'memo ' => $ memoPayload ,
256- 'search_attributes ' => $ searchAttributesPayload ,
246+ 'memo ' => $ run -> memo ,
247+ 'search_attributes ' => $ run -> search_attributes ,
257248 'execution_timeout_seconds ' => $ executionTimeoutSeconds ,
258249 'run_timeout_seconds ' => $ runTimeoutSeconds ,
259250 'execution_deadline_at ' => $ executionDeadlineAt ?->toIso8601String(),
@@ -989,35 +980,4 @@ private function taskQuery(): \Illuminate\Database\Eloquent\Builder
989980 {
990981 return ConfiguredV2Models::query ('task_model ' , WorkflowTask::class);
991982 }
992-
993- /**
994- * @param array<string, mixed>|null $memo
995- * @param array<string, scalar|null>|null $searchAttributes
996- */
997- private function seedTypedVisibilityMetadata (WorkflowRun $ run , ?array $ memo , ?array $ searchAttributes ): void
998- {
999- if (is_array ($ memo ) && $ memo !== []) {
1000- app (MemoUpsertService::class)->upsert ($ run , new UpsertMemosCall ($ memo ), 0 );
1001- $ run ->unsetRelation ('memos ' );
1002- }
1003-
1004- if (is_array ($ searchAttributes ) && $ searchAttributes !== []) {
1005- app (SearchAttributeUpsertService::class)->upsert (
1006- $ run ,
1007- new UpsertSearchAttributesCall ($ searchAttributes ),
1008- 0 ,
1009- );
1010- $ run ->unsetRelation ('searchAttributes ' );
1011- }
1012- }
1013-
1014- /**
1015- * @param array<string, mixed>|null $values
1016- *
1017- * @return array<string, mixed>|null
1018- */
1019- private static function visibilityMetadataPayload (?array $ values ): ?array
1020- {
1021- return is_array ($ values ) && $ values !== [] ? $ values : null ;
1022- }
1023983}
0 commit comments