You are here

function _akamai_update_status in Akamai 7.3

Checks the status of a purge request and updates its record.

1 call to _akamai_update_status()
akamai_cron_check_status in ./akamai.cron.inc
Checks the status of pending purge requests.

File

./akamai.cron.inc, line 96
Contains functions for running cron tasks.

Code

function _akamai_update_status($progress_uri, $purge_id) {
  try {
    $time = time();
    $client = akamai_get_client();
    $response = $client
      ->checkProgress($progress_uri);
    $record = [
      'purge_id' => $purge_id,
      'last_checked' => $time,
      'status' => $response->purgeStatus,
    ];
    if (empty($response->completionTime)) {
      $record['check_after'] = $time + $response->pingAfterSeconds;
    }
    else {
      $record['completion_time'] = strtotime($response->completionTime);
    }
    return drupal_write_record('akamai_purge_requests', $record, 'purge_id');
  } catch (Exception $e) {
    watchdog_exception('akamai', $e);
  }
  return FALSE;
}