@@ -142,7 +142,7 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
142142 // Laravel 7+ jobs have a uuid, but Laravel 6 doesn't have it.
143143 // Since we are using and expecting the uuid in some places
144144 // we will add it manually here if it's not present yet.
145- [$ payload , $ uuid ] = $ this ->withUuid ($ payload );
145+ [$ payload , $ uuid, $ displayName ] = $ this ->extractPayload ($ payload );
146146
147147 // Since 3.x tasks are released back onto the queue after an exception has
148148 // been thrown. This means we lose the native [X-CloudTasks-TaskRetryCount] header
@@ -152,6 +152,7 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
152152 $ httpRequest ->setBody ($ payload );
153153
154154 $ task = $ this ->createTask ();
155+ $ task ->setName ($ this ->taskName ($ uuid , $ displayName ));
155156 $ task ->setHttpRequest ($ httpRequest );
156157
157158 // The deadline for requests sent to the app. If the app does not respond by
@@ -172,12 +173,17 @@ protected function pushToCloudTasks($queue, $payload, $delay = 0)
172173
173174 $ createdTask = CloudTasksApi::createTask ($ queueName , $ task );
174175
175- event ((new TaskCreated )->queue ($ queue )->task ($ task ));
176+ event ((new TaskCreated )->queue ($ queue )->task ($ createdTask ));
176177
177178 return $ uuid ;
178179 }
179180
180- private function withUuid (string $ payload ): array
181+ private function taskName (string $ uuid , string $ displayName ) {
182+ $ displayName = str_replace ("\\" , "- " , $ displayName );
183+ return sprintf ('%s-%s ' , $ uuid , $ displayName );
184+ }
185+
186+ private function extractPayload (string $ payload ): array
181187 {
182188 /** @var array $decoded */
183189 $ decoded = json_decode ($ payload , true );
@@ -189,6 +195,7 @@ private function withUuid(string $payload): array
189195 return [
190196 json_encode ($ decoded ),
191197 $ decoded ['uuid ' ],
198+ $ decoded ['displayName ' ]
192199 ];
193200 }
194201
0 commit comments