@@ -57,6 +57,11 @@ public function getFormId(): string {
5757 */
5858 public function getQuestion (): TranslatableMarkup {
5959 $ job = $ this ->helper ->getJobFromId ((string ) $ this ->jobId );
60+
61+ if (empty ($ job )) {
62+ return $ this ->t ('Job not found ' );
63+ }
64+
6065 $ webformId = $ this ->helper ->getWebformIdFromQueue ($ job ->getId ());
6166
6267 return $ this ->t ('Are you sure you want to retry queue job related to Webform: @webformId, Submission id: @serialId ' , [
@@ -94,22 +99,22 @@ public function buildForm(array $form, FormStateInterface $form_state, int $job_
9499 */
95100 public function submitForm (array &$ form , FormStateInterface $ form_state ): void {
96101 $ job = $ this ->helper ->getJobFromId ((string ) $ this ->jobId );
97- $ queue_id = $ job ->getQueueId ();
102+ if (!empty ($ job )) {
103+ $ queue_id = $ job ->getQueueId ();
98104
99- $ queue_storage = $ this ->entityTypeManager ->getStorage ('advancedqueue_queue ' );
100- /** @var \Drupal\advancedqueue\Entity\QueueInterface $queue */
101- $ queue = $ queue_storage ->load ($ queue_id );
105+ $ queue_storage = $ this ->entityTypeManager ->getStorage ('advancedqueue_queue ' );
106+ /** @var \Drupal\advancedqueue\Entity\QueueInterface $queue */
107+ $ queue = $ queue_storage ->load ($ queue_id );
102108
103- $ queue_backend = $ queue ->getBackend ();
104- if ($ queue_backend instanceof Database) {
105- $ job = $ this ->helper ->getJobFromId ((string ) $ this ->jobId );
109+ $ queue_backend = $ queue ->getBackend ();
110+ if ($ queue_backend instanceof Database) {
111+ if ($ job ->getState () != Job::STATE_FAILURE ) {
112+ throw new \InvalidArgumentException ('Only failed jobs can be retried. ' );
113+ }
106114
107- if ( $ job -> getState () != Job:: STATE_FAILURE ) {
108- throw new \ InvalidArgumentException ( ' Only failed jobs can be retried. ' );
115+ $ queue_backend -> retryJob ( $ job );
116+ $ form_state -> setRedirectUrl ( $ this -> getCancelUrl () );
109117 }
110-
111- $ queue_backend ->retryJob ($ job );
112- $ form_state ->setRedirectUrl ($ this ->getCancelUrl ());
113118 }
114119 }
115120
0 commit comments