function UpdateProcessor::processFetchTask
Same name in other branches
- 8.9.x core/modules/update/src/UpdateProcessor.php \Drupal\update\UpdateProcessor::processFetchTask()
- 10 core/modules/update/src/UpdateProcessor.php \Drupal\update\UpdateProcessor::processFetchTask()
- 11.x core/modules/update/src/UpdateProcessor.php \Drupal\update\UpdateProcessor::processFetchTask()
Overrides UpdateProcessorInterface::processFetchTask
1 call to UpdateProcessor::processFetchTask()
- UpdateProcessor::fetchData in core/
modules/ update/ src/ UpdateProcessor.php - Attempts to drain the queue of tasks for release history data to fetch.
File
-
core/
modules/ update/ src/ UpdateProcessor.php, line 150
Class
- UpdateProcessor
- Process project update information.
Namespace
Drupal\updateCode
public function processFetchTask($project) {
global $base_url;
// This can be in the middle of a long-running batch, so REQUEST_TIME won't
// necessarily be valid.
$request_time_difference = time() - REQUEST_TIME;
if (empty($this->failed)) {
// If we have valid data about release history XML servers that we have
// failed to fetch from on previous attempts, load that.
$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);
// @todo Purge release data we don't need. See
// https://www.drupal.org/node/238950.
if (!empty($available)) {
// Only if we fetched and parsed something sane do we return success.
$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);
// Stash the $this->failed data back in the DB for the next 5 minutes.
$this->tempStore
->setWithExpire('fetch_failures', $this->failed, $request_time_difference + 60 * 5);
// Whether this worked or not, we did just (try to) check for updates.
$this->stateStore
->set('update.last_check', REQUEST_TIME + $request_time_difference);
// Now that we processed the fetch task for this project, clear out the
// record for this task so we're willing to fetch again.
$this->fetchTaskStore
->delete($project_name);
return $success;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.