public UpdateProcessor::processFetchTask($project)
Processes a task to fetch available update data for a single project.
Once the release history XML data is downloaded, it is parsed and saved in an entry just for that project.
Parameters
array $project: Associative array of information about the project to fetch data for.
Return value
bool TRUE if we fetched parsable XML, otherwise FALSE.
Overrides UpdateProcessorInterface::processFetchTask
File
- core/modules/update/src/UpdateProcessor.php, line 139
Class
- UpdateProcessor
- Process project update information.
Namespace
Drupal\update
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 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 = array (); $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 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 ; } |
Please login to continue.