From 7a7e7f689922518b7a331c99f77d5aeb40362969 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 23 Apr 2026 01:04:07 +0200 Subject: [PATCH] Fix silent no-op in Queue::addJob when task does not queue a job MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AddInterface::add() returns void and may silently skip queuing a job when required configuration is missing — most notably EmailTask, which does nothing when Config.adminEmail is not set. Previously the controller showed a green success flash regardless, making it look like the admin UI had queued a job when it hadn't. Now we count QueuedJobs before/after invoking the task. If the count did not increase, we show an error flash pointing the operator at the likely config gap, instead of falsely reporting success. --- src/Controller/Admin/QueueController.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Controller/Admin/QueueController.php b/src/Controller/Admin/QueueController.php index fd7bb282..8b23beee 100644 --- a/src/Controller/Admin/QueueController.php +++ b/src/Controller/Admin/QueueController.php @@ -133,13 +133,27 @@ public function addJob() { } $object = new $className(); + // Measure the QueuedJobs count before invoking the task so we can + // tell whether the task actually queued a job. AddInterface::add() + // returns void and may silently no-op when required config is + // missing (e.g. EmailTask without Config.adminEmail). Without this + // check the controller would falsely report success. + $before = $this->QueuedJobs->find()->count(); if ($object instanceof AddInterface) { $object->add(null); } else { $this->QueuedJobs->createJob($job); } + $after = $this->QueuedJobs->find()->count(); - $this->Flash->success('Job ' . $job . ' added'); + if ($after > $before) { + $this->Flash->success('Job ' . $job . ' added'); + } else { + $this->Flash->error( + 'Job ' . $job . ' could not be added — the task did not create a job. ' + . 'Check configuration (e.g. Config.adminEmail for Queue.Email) and server logs.', + ); + } return $this->refererRedirect(['action' => 'index']); }