public function UpdateProcessor::processFetchTask in Drupal 10
Same name and namespace in other branches
- 8 core/modules/update/src/UpdateProcessor.php \Drupal\update\UpdateProcessor::processFetchTask()
- 9 core/modules/update/src/UpdateProcessor.php \Drupal\update\UpdateProcessor::processFetchTask()
File
- core/modules/update/src/UpdateProcessor.php, line 145
Class
- UpdateProcessor
- Process project update information.
Namespace
Drupal\update
Code
public function processFetchTask($project) {
global $base_url;
$request_time_difference = time() - REQUEST_TIME;
if (empty($this->failed)) {
$this->failed = $this->tempStore
->get('fetch_failures');
}
$max_fetch_attempts = $this->updateSettings
->get('fetch.max_attempts');
$success = FALSE;
$available = [];
$site_key = Crypt::hmacBase64($base_url, $this->privateKey
->get());
$fetch_url_base = $this->updateFetcher
->getFetchBaseUrl($project);
$project_name = $project['name'];
if (empty($this->failed[$fetch_url_base]) || $this->failed[$fetch_url_base] < $max_fetch_attempts) {
$data = $this->updateFetcher
->fetchProjectData($project, $site_key);
}
if (!empty($data)) {
$available = $this
->parseXml($data);
if (!empty($available)) {
$success = TRUE;
}
}
else {
$available['project_status'] = 'not-fetched';
if (empty($this->failed[$fetch_url_base])) {
$this->failed[$fetch_url_base] = 1;
}
else {
$this->failed[$fetch_url_base]++;
}
}
$frequency = $this->updateSettings
->get('check.interval_days');
$available['last_fetch'] = REQUEST_TIME + $request_time_difference;
$this->availableReleasesTempStore
->setWithExpire($project_name, $available, $request_time_difference + 60 * 60 * 24 * $frequency);
$this->tempStore
->setWithExpire('fetch_failures', $this->failed, $request_time_difference + 60 * 5);
$this->stateStore
->set('update.last_check', REQUEST_TIME + $request_time_difference);
$this->fetchTaskStore
->delete($project_name);
return $success;
}