You are here

protected static function InPlaceUpdate::doGetResource in Automatic Updates 7

Perform retrieval of archive, with delay if archive is still being created.

Parameters

string $url: The URL to retrieve.

string $destination: The destination to download the archive.

null|int $delay: The delay, defaults to NULL.

1 call to InPlaceUpdate::doGetResource()
InPlaceUpdate::getArchive in ./InPlaceUpdate.php
Get an archive with the quasi-patch contents.

File

./InPlaceUpdate.php, line 186

Class

InPlaceUpdate
Class to apply in-place updates.

Code

protected static function doGetResource($url, $destination, $delay = 0) {
  sleep($delay);
  $result = drupal_http_request($url);

  // Have to check for header directly as Core doesn't know HTTP 429.
  if ($result->code === '429' || isset($result->headers['retry-after'])) {
    $delay = $result->headers['retry-after'];
    self::doGetResource($url, $destination, $delay);
  }
  elseif ($result->code !== '200') {
    watchdog('automatic_updates', 'Retrieval of "@url" failed with: @message', [
      '@url' => $url,
      '@message' => $result->data,
    ], WATCHDOG_ERROR);
  }
  else {
    file_unmanaged_save_data($result->data, $destination, FILE_EXISTS_REPLACE);
  }
}