+ unset($this->queueSpec['status']);
+ // Status may be meaningfully + independently toggled (eg when using type=SqlParallel,error=abort).
+ // Retaining a copy of 'status' in here would be misleading.
+ }
+
+ /**
+ * Determine whether this queue is currently active.
+ *
+ * @return bool
+ * TRUE if runners should continue claiming new tasks from this queue
+ * @throws \CRM_Core_Exception
+ */
+ public function isActive(): bool {
+ $status = CRM_Core_DAO::getFieldValue('CRM_Queue_DAO_Queue', $this->_name, 'status', 'name', TRUE);
+ // Note: In the future, we may want to incorporate other data (like maintenance-mode or upgrade-status) in deciding active queues.
+ return ($status === 'active');
+ }
+
+ /**
+ * Change the status of the queue.
+ *
+ * @param string $status
+ * Ex: 'active', 'draft', 'aborted'
+ */
+ public function setStatus(string $status): void {
+ $result = CRM_Core_DAO::executeQuery('UPDATE civicrm_queue SET status = %1 WHERE name = %2', [
+ 1 => [$status, 'String'],
+ 2 => [$this->getName(), 'String'],
+ ]);
+ // If multiple workers try to setStatus('completed') at roughly the same time, only one will fire an event.
+ if ($result->affectedRows() > 0) {
+ CRM_Utils_Hook::queueStatus($this, $status);
+ }