Issue #1492188 by Berdir, catch: Fixed Update module creates duplicate queue items.
parent
768de00260
commit
d690e71b08
|
@ -809,14 +809,19 @@ function _update_get_cache_multiple($cid_prefix) {
|
||||||
*
|
*
|
||||||
* @param $cid
|
* @param $cid
|
||||||
* Optional cache ID of the record to clear from the private update module
|
* Optional cache ID of the record to clear from the private update module
|
||||||
* cache. If empty, all records will be cleared from the table.
|
* cache. If empty, all records will be cleared from the table except
|
||||||
|
* fetch tasks.
|
||||||
* @param $wildcard
|
* @param $wildcard
|
||||||
* If $wildcard is TRUE, cache IDs starting with $cid are deleted in
|
* If $wildcard is TRUE, cache IDs starting with $cid are deleted in
|
||||||
* addition to the exact cache ID specified by $cid.
|
* addition to the exact cache ID specified by $cid.
|
||||||
*/
|
*/
|
||||||
function _update_cache_clear($cid = NULL, $wildcard = FALSE) {
|
function _update_cache_clear($cid = NULL, $wildcard = FALSE) {
|
||||||
if (empty($cid)) {
|
if (empty($cid)) {
|
||||||
db_truncate('cache_update')->execute();
|
db_delete('cache_update')
|
||||||
|
// Clear everything except fetch task information because these are used
|
||||||
|
// to ensure that the fetch task queue items are not added multiple times.
|
||||||
|
->condition('cid', 'fetch_task::%', 'NOT LIKE')
|
||||||
|
->execute();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$query = db_delete('cache_update');
|
$query = db_delete('cache_update');
|
||||||
|
|
|
@ -225,6 +225,33 @@ class UpdateCoreTestCase extends UpdateTestHelper {
|
||||||
$this->assertUniqueText(t('Failed to get available update data for one project.'));
|
$this->assertUniqueText(t('Failed to get available update data for one project.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = DrupalQueue::get('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 cache and try again.
|
||||||
|
_update_cache_clear();
|
||||||
|
drupal_static_reset('_update_create_fetch_task');
|
||||||
|
update_create_fetch_task($projecta);
|
||||||
|
$this->assertEqual($queue->numberOfItems(), 2, 'Queue contains two items');
|
||||||
|
}
|
||||||
|
|
||||||
protected function setSystemInfo7_0() {
|
protected function setSystemInfo7_0() {
|
||||||
$setting = array(
|
$setting = array(
|
||||||
'#all' => array(
|
'#all' => array(
|
||||||
|
|
Loading…
Reference in New Issue