Loading dropfort_update.module +27 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use GuzzleHttp\Exception\RequestException; use Drupal\Component\Utility\UrlHelper; use Drupal\update\UpdateFetcherInterface; /** * Implements hook_cron(). Loading @@ -19,6 +20,19 @@ function dropfort_update_cron() { } } /** * Implements hook_module_implements_alter(). */ function dropfort_update_module_implements_alter(&$implementations, $hook) { // Lower Dropfort Update's weight so it runs after the update module. // Reduces the chance of not getting update data. if ($hook == 'cron' && array_key_exists('dropfort_update', $implementations)) { $cron_config = $implementations['dropfort_update']; unset($implementations['dropfort_update']); $implementations['dropfort_update'] = $cron_config; } } /** * Send updates and status data to Dropfort. * Loading Loading @@ -79,10 +93,22 @@ function dropfort_update_send_status(array $options = NULL) { return; } // Sometimes Drupal hasn't fetched the module info recently. // If that's the case, have Dropfort Update try again sooner. $last_status = time(); foreach ($data['update_status'] as $item) { if (in_array($item['status'], [UpdateFetcherInterface::NOT_FETCHED, UpdateFetcherInterface::FETCH_PENDING])) { // Set the last status to an hour ago since we didn't get a full // status run. We'll take the existing data but we treat this // as if it hadn't run so it gets run again next cron. $last_status = time() - 3600; } } try { $client = \Drupal::httpClient(); $request = $client->request('POST', $status_url, $options); \Drupal::state()->set('dropfort_update.last_status', time()); \Drupal::state()->set('dropfort_update.last_status', $last_status); return $request; } Loading Loading
dropfort_update.module +27 −1 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use GuzzleHttp\Exception\RequestException; use Drupal\Component\Utility\UrlHelper; use Drupal\update\UpdateFetcherInterface; /** * Implements hook_cron(). Loading @@ -19,6 +20,19 @@ function dropfort_update_cron() { } } /** * Implements hook_module_implements_alter(). */ function dropfort_update_module_implements_alter(&$implementations, $hook) { // Lower Dropfort Update's weight so it runs after the update module. // Reduces the chance of not getting update data. if ($hook == 'cron' && array_key_exists('dropfort_update', $implementations)) { $cron_config = $implementations['dropfort_update']; unset($implementations['dropfort_update']); $implementations['dropfort_update'] = $cron_config; } } /** * Send updates and status data to Dropfort. * Loading Loading @@ -79,10 +93,22 @@ function dropfort_update_send_status(array $options = NULL) { return; } // Sometimes Drupal hasn't fetched the module info recently. // If that's the case, have Dropfort Update try again sooner. $last_status = time(); foreach ($data['update_status'] as $item) { if (in_array($item['status'], [UpdateFetcherInterface::NOT_FETCHED, UpdateFetcherInterface::FETCH_PENDING])) { // Set the last status to an hour ago since we didn't get a full // status run. We'll take the existing data but we treat this // as if it hadn't run so it gets run again next cron. $last_status = time() - 3600; } } try { $client = \Drupal::httpClient(); $request = $client->request('POST', $status_url, $options); \Drupal::state()->set('dropfort_update.last_status', time()); \Drupal::state()->set('dropfort_update.last_status', $last_status); return $request; } Loading