/** * 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(); } }
/** * Process a chunk of items form the queue and respond in JSON. * * @return string * Statistics array encoded as JSON, including a 'widget' HTML snippet. */ public static function pathCallback() { $service = _acquia_purge_service(); $stats = $service->stats(); $stats['error'] = FALSE; $stats['widget'] = ' '; // Deny access when the current user didn't initiate queue processing. if (!self::isUserOwningTheQueue($service)) { $stats['running'] = FALSE; return drupal_json_output($stats); } // Test for blocking diagnostic issues and report any if found. if (!_acquia_purge_are_we_allowed_to_purge()) { $err = current(_acquia_purge_get_diagnosis(ACQUIA_PURGE_SEVLEVEL_ERROR)); _acquia_purge_get_diagnosis_logged($err); $stats['error'] = $err['description']; return drupal_json_output($stats); } // Attempt to process a chunk from the queue. if ($service->lockAcquire()) { $service->process(); foreach ($service->stats() as $key => $value) { $stats[$key] = $value; } // When processing stalled, the history breadcrumb often stays empty and // this is a clear indication that errors occurred. if (empty($stats['purgehistory'])) { $stats['error'] = t("The system seems to be having difficulties\r\n refreshing recent content changes. Your work won't be lost, but please\r\n do ask your technical administrator to check the logs."); } $service->lockRelease(); } else { $stats['locked'] = TRUE; } // Render the status widget and render as JSON response. if (!$stats['error']) { $stats['widget'] = theme('acquia_purge_status_bar_widget', $stats); } return drupal_json_output($stats); }