Remove deprecated function _update_create_fetch_task and its usage
Usages:
1. update.module
/**
* Creates a new fetch task after loading the necessary include file.
*
* @param $project
* Associative array of information about a project. See update_get_projects()
* for the keys used.
*
* @see _update_create_fetch_task()
*/
function update_create_fetch_task($project) {
module_load_include('inc', 'update', 'update.fetch');
_update_create_fetch_task($project);
}2. UpdateCoreTest.php
/**
* Tests that exactly one fetch task per project is created and not more.
*/
function testFetchTasks() {
$projecta = array(
'name' => 'aaa_update_test',
);
$projectb = array(
'name' => 'bbb_update_test',
);
$queue = \Drupal::queue('update_fetch_tasks');
$this->assertEqual($queue->numberOfItems(), 0, 'Queue is empty');
update_create_fetch_task($projecta);
$this->assertEqual($queue->numberOfItems(), 1, 'Queue contains one item');
update_create_fetch_task($projectb);
$this->assertEqual($queue->numberOfItems(), 2, 'Queue contains two items');
// Try to add project a again.
update_create_fetch_task($projecta);
$this->assertEqual($queue->numberOfItems(), 2, 'Queue still contains two items');
// Clear storage and try again.
update_storage_clear();
drupal_static_reset('_update_create_fetch_task');
update_create_fetch_task($projecta);
$this->assertEqual($queue->numberOfItems(), 2, 'Queue contains two items');
}
Function
update.fetch.inc
/**
* 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).
*
* @param $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 \Drupal\update\UpdateFetcher::createFetchTask()
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal::service('update.processor')->createFetchTask().
*/
function _update_create_fetch_task($project) {
\Drupal::service('update.processor')->createFetchTask($project);
}| Comment | File | Size | Author |
|---|---|---|---|
| #9 | update-remove-deprecated-function-update_fetch_data-and-its-usage-2384009-9.patch | 2.99 KB | arpitr |
Comments
Comment #1
arpitr commentedComment #2
arpitr commentedComment #4
benjy commentedIf you're going to remove _update_create_fetch_task() then you'll need to also update update_create_fetch_task() not to call it. Something like this:
EDIT: the module_load_include could also be removed.
Comment #5
arpitr commentedComment #6
arpitr commentedComment #7
arpitr commentedComment #8
benjy commentedThis looks good to me if the docs on update_create_fetch_task() suitably replace the docs we're removing on _update_create_fetch_task().
Comment #9
arpitr commentedUpdated the docs for update_create_fetch_task(), thanks @benjy :).
Comment #10
benjy commented@arpitr, usually it's customary to create an interdiff when posting new patches: https://www.drupal.org/documentation/git/interdiff
Looks fine with me.
Comment #11
alexpottThis issue is a prioritized change (deprecated code) as per https://www.drupal.org/core/beta-changes and it's benefits outweigh any disruption. Committed c7245b0 and pushed to 8.0.x. Thanks!
Normally we would commit the removal of usages in a separate patch from the removal of the function. Also this function
_update_create_fetch_task()is prefixed by an underscore so was marked as private in D7 - therefore no need for a CR.