function _update_create_fetch_task

Adds a task to the queue for fetching release history data for a project.

We only create a new fetch task if there's no task already in the queue for this particular project (based on 'update_fetch_task' key-value collection).

Parameters

$project: Associative array of information about a project as created by update_get_projects(), including keys such as 'name' (short name), and the 'info' array with data from a .info.yml file for the project.

See also

update_get_projects()

update_get_available()

update_refresh()

update_fetch_data()

_update_process_fetch_task()

1 call to _update_create_fetch_task()
update_create_fetch_task in drupal/core/modules/update/update.module
Creates a new fetch task after loading the necessary include file.
1 string reference to '_update_create_fetch_task'
UpdateCoreTest::testFetchTasks in drupal/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php
Tests that exactly one fetch task per project is created and not more.

File

drupal/core/modules/update/update.fetch.inc, line 245
Code required only when fetching information about available updates.

Code

function _update_create_fetch_task($project) {
  $fetch_tasks =& drupal_static(__FUNCTION__, array());
  if (empty($fetch_tasks)) {
    $fetch_tasks = drupal_container()
      ->get('keyvalue')
      ->get('update_fetch_task')
      ->getAll();
  }
  if (empty($fetch_tasks[$project['name']])) {
    $queue = Drupal::queue('update_fetch_tasks');
    $queue
      ->createItem($project);
    drupal_container()
      ->get('keyvalue')
      ->get('update_fetch_task')
      ->set($project['name'], $project);
    $fetch_tasks[$project['name']] = REQUEST_TIME;
  }
}