|
8 | 8 | use Cake\Http\Exception\NotFoundException; |
9 | 9 | use Cake\I18n\DateTime; |
10 | 10 | use Cake\View\JsonView; |
| 11 | +use InvalidArgumentException; |
11 | 12 | use Queue\Queue\TaskFinder; |
12 | 13 | use RuntimeException; |
13 | 14 |
|
@@ -304,14 +305,21 @@ public function data(?int $id = null) { |
304 | 305 | } |
305 | 306 |
|
306 | 307 | if ($this->request->is(['patch', 'post', 'put'])) { |
307 | | - $queuedJob = $this->QueuedJobs->patchEntity($queuedJob, $this->request->getData()); |
308 | | - if ($this->QueuedJobs->save($queuedJob)) { |
309 | | - $this->Flash->success(__d('queue', 'The queued job has been saved.')); |
| 308 | + try { |
| 309 | + $queuedJob = $this->QueuedJobs->patchEntity($queuedJob, $this->request->getData()); |
| 310 | + if ($this->QueuedJobs->save($queuedJob)) { |
| 311 | + $this->Flash->success(__d('queue', 'The queued job has been saved.')); |
310 | 312 |
|
311 | | - return $this->redirect(['action' => 'view', $id]); |
312 | | - } |
| 313 | + return $this->redirect(['action' => 'view', $id]); |
| 314 | + } |
313 | 315 |
|
314 | | - $this->Flash->error(__d('queue', 'The queued job could not be saved. Please try again.')); |
| 316 | + $this->Flash->error(__d('queue', 'The queued job could not be saved. Please try again.')); |
| 317 | + } catch (InvalidArgumentException $e) { |
| 318 | + $this->Flash->error($e->getMessage()); |
| 319 | + |
| 320 | + // Preserve the user's invalid input so they can fix it |
| 321 | + $queuedJob->data_string = $this->request->getData('data_string'); |
| 322 | + } |
315 | 323 | } |
316 | 324 |
|
317 | 325 | $this->set(compact('queuedJob')); |
|
0 commit comments