Skip to content
Snippets Groups Projects
Commit 62c2f724 authored by Lucas Hedding's avatar Lucas Hedding Committed by Lucas Hedding
Browse files

Issue #3095416 by heddn: HTTP error 429 not handled appropriately

parent 81823dc6
No related branches found
No related tags found
No related merge requests found
...@@ -74,7 +74,7 @@ function automatic_updates_page_top(array &$page_top) { ...@@ -74,7 +74,7 @@ function automatic_updates_page_top(array &$page_top) {
function automatic_updates_cron() { function automatic_updates_cron() {
$state = \Drupal::state(); $state = \Drupal::state();
$request_time = \Drupal::time()->getRequestTime(); $request_time = \Drupal::time()->getRequestTime();
$last_check = $state->get('automatic_updates.last_check', 0); $last_check = $state->get('automatic_updates.cron_last_check', 0);
// Only allow cron to run once every hour. // Only allow cron to run once every hour.
if (($request_time - $last_check) < 3600) { if (($request_time - $last_check) < 3600) {
return; return;
...@@ -115,7 +115,7 @@ function automatic_updates_cron() { ...@@ -115,7 +115,7 @@ function automatic_updates_cron() {
foreach ($checker->getCategories() as $category) { foreach ($checker->getCategories() as $category) {
$checker->run($category); $checker->run($category);
} }
$state->set('automatic_updates.last_check', \Drupal::time()->getCurrentTime()); $state->set('automatic_updates.cron_last_check', \Drupal::time()->getCurrentTime());
} }
/** /**
......
...@@ -252,12 +252,15 @@ class InPlaceUpdate implements UpdateInterface { ...@@ -252,12 +252,15 @@ class InPlaceUpdate implements UpdateInterface {
$this->httpClient->get($url, [ $this->httpClient->get($url, [
'sink' => $destination, 'sink' => $destination,
'delay' => $delay, 'delay' => $delay,
// Some of the core quasi-patch zip files are large, increase timeout.
'timeout' => 120,
]); ]);
} }
catch (RequestException $exception) { catch (RequestException $exception) {
$response = $exception->getResponse(); $response = $exception->getResponse();
if (!$response || ($retry = $response->getHeader('Retry-After'))) { if ($response && $response->getStatusCode() === 429) {
$this->doGetResource($url, $destination, !empty($retry[0]) ? $retry[0] : 10 * 1000); $delay = 1000 * (isset($response->getHeader('Retry-After')[0]) ? $response->getHeader('Retry-After')[0] : 10);
$this->doGetResource($url, $destination, $delay);
} }
else { else {
$this->logger->error('Retrieval of "@url" failed with: @message', [ $this->logger->error('Retrieval of "@url" failed with: @message', [
......
...@@ -120,9 +120,9 @@ class Notify implements NotifyInterface { ...@@ -120,9 +120,9 @@ class Notify implements NotifyInterface {
$notify_list = $this->configFactory->get('update.settings')->get('notification.emails'); $notify_list = $this->configFactory->get('update.settings')->get('notification.emails');
if (!empty($notify_list)) { if (!empty($notify_list)) {
$frequency = $this->configFactory->get('automatic_updates.settings')->get('check_frequency'); $frequency = $this->configFactory->get('automatic_updates.settings')->get('check_frequency');
$last_check = $this->state->get('automatic_updates.last_check') ?: 0; $last_check = $this->state->get('automatic_updates.notify_last_check') ?: 0;
if (($this->time->getRequestTime() - $last_check) > $frequency) { if (($this->time->getRequestTime() - $last_check) > $frequency) {
$this->state->set('automatic_updates.last_check', $this->time->getRequestTime()); $this->state->set('automatic_updates.notify_last_check', $this->time->getRequestTime());
$params['subject'] = new PluralTranslatableMarkup( $params['subject'] = new PluralTranslatableMarkup(
count($messages), count($messages),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment