/**
  * Attempt to process a chunk from the queue.
  *
  * @param bool $log
  *   (optional) Whether diagnostic failure should be logged or not.
  */
 protected function processQueueChunk($log = TRUE)
 {
     // Test if the diagnostic tests prohibit purging the queue.
     if (!_acquia_purge_are_we_allowed_to_purge()) {
         if ($log) {
             $err = _acquia_purge_get_diagnosis(ACQUIA_PURGE_SEVLEVEL_ERROR);
             _acquia_purge_get_diagnosis_logged($err);
         }
         return;
     }
     // Acquire a lock and process a chunk from the queue.
     if ($this->service->lockAcquire()) {
         $this->service->process();
         $this->service->lockRelease();
     }
 }
 /**
  * Determine if the processor should run.
  *
  * @param AcquiaPurgeService $service
  *   The Acquia Purge service object.
  *
  * @return bool
  *   Either TRUE or FALSE.
  */
 public static function isUserOwningTheQueue(AcquiaPurgeService $service)
 {
     // Anonymous users can never process the queue.
     if (!user_is_logged_in()) {
         return FALSE;
     }
     // Retrieve the list of user names owning an ongoing purge process.
     $uiusers = $service->state()->get('uiusers', array())->get();
     // If the uiusers list is empty, that means no active purges are ongoing.
     if (!count($uiusers)) {
         return FALSE;
     }
     // Is the current user one of the uiusers of the actively ongoing purge?
     global $user;
     if (!in_array($user->name, $uiusers)) {
         return FALSE;
     }
     // Are we running on a Acquia Cloud environment?
     if (!_acquia_purge_are_we_on_acquiacloud()) {
         return FALSE;
     }
     // All tests passed, this user can process the queue.
     return TRUE;
 }