diff options
Diffstat (limited to 'modules/update/update.fetch.inc')
-rw-r--r-- | modules/update/update.fetch.inc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc index 7ac0dbefb..ee5d77b16 100644 --- a/modules/update/update.fetch.inc +++ b/modules/update/update.fetch.inc @@ -237,12 +237,22 @@ function _update_create_fetch_task($project) { if (empty($fetch_tasks[$cid])) { $queue = DrupalQueue::get('update_fetch_tasks'); $queue->createItem($project); - db_insert('cache_update') - ->fields(array( - 'cid' => $cid, - 'created' => REQUEST_TIME, - )) - ->execute(); + // 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; } } @@ -271,7 +281,7 @@ function _update_build_fetch_url($project, $site_key = '') { // in the first place, and if this is not a disabled module or theme. We do // not want to record usage statistics for disabled code. if (!empty($site_key) && (strpos($project['project_type'], 'disabled') === FALSE)) { - $url .= (strpos($url, '?') === TRUE) ? '&' : '?'; + $url .= (strpos($url, '?') !== FALSE) ? '&' : '?'; $url .= 'site_key='; $url .= rawurlencode($site_key); if (!empty($project['info']['version'])) { |