diff options
Diffstat (limited to '')
-rw-r--r-- | admin/batch_manager_global.php | 6 | ||||
-rw-r--r-- | include/dblayer/functions_mysql.inc.php | 10 | ||||
-rw-r--r-- | include/functions_user.inc.php | 10 |
3 files changed, 16 insertions, 10 deletions
diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index ce1b2f745..befbf2d48 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -42,12 +42,6 @@ foreach ($upload_form_config as $param_shortname => $param) $form_values[$param_shortname] = $conf[$param_name]; } -// User cache must not be regenerated during simultaneous ajax requests -if (!isset($user['need_update']) or !$user['need_update']) -{ - getuserdata($user['id'], true); -} - // +-----------------------------------------------------------------------+ // | Check Access and exit when user status is not ok | // +-----------------------------------------------------------------------+ diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php index dbc66d503..785e588e0 100644 --- a/include/dblayer/functions_mysql.inc.php +++ b/include/dblayer/functions_mysql.inc.php @@ -416,8 +416,14 @@ UPDATE '.$tablename.' * @param array inserts * @return void */ -function mass_inserts($table_name, $dbfields, $datas) +function mass_inserts($table_name, $dbfields, $datas, $options=array()) { + $ignore = ''; + if (isset($options['ignore']) and $options['ignore']) + { + $ignore = 'IGNORE'; + } + if (count($datas) != 0) { $first = true; @@ -438,7 +444,7 @@ function mass_inserts($table_name, $dbfields, $datas) if ($first) { $query = ' -INSERT INTO '.$table_name.' +INSERT '.$ignore.' INTO '.$table_name.' ('.implode(',', $dbfields).') VALUES'; $first = false; diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 63925cfd8..eedd53af5 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -446,6 +446,9 @@ DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.' WHERE user_id = '.$userdata['id']; pwg_query($query); + // Due to concurrency issues, we ask MySQL to ignore errors on + // insert. This may happen when cache needs refresh and that Piwigo is + // called "very simultaneously". mass_inserts ( USER_CACHE_CATEGORIES_TABLE, @@ -454,7 +457,8 @@ DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.' 'user_id', 'cat_id', 'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories' ), - $user_cache_cats + $user_cache_cats, + array('ignore' => true) ); @@ -464,8 +468,10 @@ DELETE FROM '.USER_CACHE_TABLE.' WHERE user_id = '.$userdata['id']; pwg_query($query); + // for the same reason as user_cache_categories, we ignore error on + // this insert $query = ' -INSERT INTO '.USER_CACHE_TABLE.' +INSERT IGNORE INTO '.USER_CACHE_TABLE.' (user_id, need_update, cache_update_time, forbidden_categories, nb_total_images, image_access_type, image_access_list) VALUES |