Queue - Extract method getStatus()
authorTim Otten <totten@civicrm.org>
Tue, 3 Oct 2023 01:44:04 +0000 (18:44 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 3 Oct 2023 01:44:04 +0000 (18:44 -0700)
CRM/Queue/Queue.php

index 8637957b8ed74c395daa89feea31d8553912b922..a7774f20d9a29b6a4528de8718649fd3ca8d8f50 100644 (file)
@@ -59,6 +59,15 @@ abstract class CRM_Queue_Queue {
    * @throws \CRM_Core_Exception
    */
   public function isActive(): bool {
+    return ($this->getStatus() === 'active');
+  }
+
+  /**
+   * @return string|null
+   * @throws \CRM_Core_Exception
+   * @see \CRM_Queue_BAO_Queue::getStatuses()
+   */
+  public function getStatus() {
     // Queues work with concurrent processes. We want to make sure status info is up-to-date (never cached).
     $status = CRM_Core_DAO::getFieldValue('CRM_Queue_DAO_Queue', $this->_name, 'status', 'name', TRUE);
     if ($status === 'active') {
@@ -72,7 +81,7 @@ abstract class CRM_Queue_Queue {
     CRM_Utils_Hook::queueActive($status, $this->getName(), $this->queueSpec);
     // Note in future we might want to consider whether an upgrade is in progress.
     // Should we set the setting at that point?
-    return ($status === 'active');
+    return $status;
   }
 
   /**