Changeset 12748


Ignore:
Timestamp:
Dec 16, 2011, 2:53:24 PM (12 years ago)
Author:
plg
Message:

merge r12747 from branch 2.3 to trunk

bug 2534 fixed: clean (as clean as possible with MySQL+MyISAM) handle of
concurrency on user cache refresh. No more error when regenerating several
thumbnails at once.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r12474 r12748  
    4141  $param_name = 'upload_form_'.$param_shortname;
    4242  $form_values[$param_shortname] = $conf[$param_name];
    43 }
    44 
    45 // User cache must not be regenerated during simultaneous ajax requests
    46 if (!isset($user['need_update']) or !$user['need_update'])
    47 {
    48   getuserdata($user['id'], true);
    4943}
    5044
  • trunk/include/dblayer/functions_mysql.inc.php

    r12010 r12748  
    417417 * @return void
    418418 */
    419 function mass_inserts($table_name, $dbfields, $datas)
    420 {
     419function mass_inserts($table_name, $dbfields, $datas, $options=array())
     420{
     421  $ignore = '';
     422  if (isset($options['ignore']) and $options['ignore'])
     423  {
     424    $ignore = 'IGNORE';
     425  }
     426 
    421427  if (count($datas) != 0)
    422428  {
     
    439445      {
    440446        $query = '
    441 INSERT INTO '.$table_name.'
     447INSERT '.$ignore.' INTO '.$table_name.'
    442448  ('.implode(',', $dbfields).')
    443449  VALUES';
  • trunk/include/functions_user.inc.php

    r12670 r12748  
    447447      pwg_query($query);
    448448
     449      // Due to concurrency issues, we ask MySQL to ignore errors on
     450      // insert. This may happen when cache needs refresh and that Piwigo is
     451      // called "very simultaneously".
    449452      mass_inserts
    450453      (
     
    455458          'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories'
    456459        ),
    457         $user_cache_cats
     460        $user_cache_cats,
     461        array('ignore' => true)
    458462      );
    459463
     
    465469      pwg_query($query);
    466470
     471      // for the same reason as user_cache_categories, we ignore error on
     472      // this insert
    467473      $query = '
    468 INSERT INTO '.USER_CACHE_TABLE.'
     474INSERT IGNORE INTO '.USER_CACHE_TABLE.'
    469475  (user_id, need_update, cache_update_time, forbidden_categories, nb_total_images,
    470476    image_access_type, image_access_list)
Note: See TracChangeset for help on using the changeset viewer.