function _upgrade_status_create_fetch_task in Upgrade Status 7
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 'upgrade_status_fetch_task::' entries in the {cache_update} table).
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 file for the project.
See also
_upgrade_status_process_fetch_task()
1 call to _upgrade_status_create_fetch_task()
- upgrade_status_create_fetch_task in ./
upgrade_status.module - Creates a new fetch task after loading the necessary include file.
File
- ./
upgrade_status.fetch.inc, line 232
Code
function _upgrade_status_create_fetch_task($project) {
$fetch_tasks =& drupal_static(__FUNCTION__, array());
if (empty($fetch_tasks)) {
$fetch_tasks = _update_get_cache_multiple('upgrade_status_fetch_task');
}
$cid = 'upgrade_status_fetch_task::' . $project['name'];
if (empty($fetch_tasks[$cid])) {
$queue = DrupalQueue::get('upgrade_status_fetch_tasks');
$queue
->createItem($project);
// Due to race conditions, it is possible that another process already
// inserted a row into the {cache_update} table and the following query will
// throw an exception.
// @todo: Remove the need for the manual check by relying on a queue that
// enforces unique items.
try {
db_insert('cache_update')
->fields(array(
'cid' => $cid,
'created' => REQUEST_TIME,
))
->execute();
} catch (Exception $e) {
// The exception can be ignored safely.
}
$fetch_tasks[$cid] = REQUEST_TIME;
}
}