summaryrefslogtreecommitdiff
path: root/modules/update
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-04-28 13:42:42 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2012-04-28 13:42:42 -0700
commit00caaed22268b95d909c6a9fcce51e92a709f79b (patch)
tree18c1a738ce54136a86b2e632a77cd5750bd551cc /modules/update
parent8f9ee9ec688b7956a19d5c749dc201333b23e428 (diff)
downloadbrdo-00caaed22268b95d909c6a9fcce51e92a709f79b.tar.gz
brdo-00caaed22268b95d909c6a9fcce51e92a709f79b.tar.bz2
Issue #1484216 by catch, Berdir, beejeebus, tim.plunkett: Fixed Race condition in _update_create_fetch_task() (PDO Exceptions).
Diffstat (limited to 'modules/update')
-rw-r--r--modules/update/update.fetch.inc22
1 files changed, 16 insertions, 6 deletions
diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc
index 7ac0dbefb..88132cec3 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;
}
}