Changeset 6312


Ignore:
Timestamp:
May 24, 2010, 1:31:58 AM (10 years ago)
Author:
plg
Message:

bug 1684 fixed: the test to check availability of the user_infos line was
wrong. I had changed the old db_num_rows > 0 because it was not working with
SQLite. As suggested by nicolas, let's use a simpler trick "count(1)" in the
query itself, this way it should work with any database engine.

I've also removed the while (true) (ugly infinite loop, with a condition for
exit) that was producing an infinite loop for Piwigo installations with 2.0
database model and 2.1 code (before launching upgrade.php)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/include/functions_user.inc.php

    r6311 r6312  
    268268  $userdata = array();
    269269
     270  // retrieve basic user data
    270271  $query = '
    271272SELECT ';
     
    290291  $row = pwg_db_fetch_assoc(pwg_query($query));
    291292
    292   while (true)
    293   {
    294     $query = '
    295 SELECT ui.*, uc.*, t.name AS theme_name
     293  // retrieve additional user data
     294  $query = '
     295SELECT
     296    COUNT(1) AS counter,
     297    ui.*,
     298    uc.*,
     299    t.name AS theme_name
    296300  FROM '.USER_INFOS_TABLE.' AS ui
    297301    LEFT JOIN '.USER_CACHE_TABLE.' AS uc ON ui.user_id = uc.user_id
    298302    LEFT JOIN '.THEMES_TABLE.' AS t ON t.id = ui.theme
    299   WHERE ui.user_id = \''.$user_id.'\'';
     303  WHERE ui.user_id = \''.$user_id.'\'
     304;';
     305  $result = pwg_query($query);
     306  $user_infos_row = pwg_db_fetch_assoc($result);
     307  if (0 == $user_infos_row['counter']) {
     308    create_user_infos($user_id);
     309   
    300310    $result = pwg_query($query);
    301     if ($result)
    302     {
    303       break;
    304     }
    305     else
    306     {
    307       create_user_infos($user_id);
    308     }
    309   }
    310 
    311   $row = array_merge($row, pwg_db_fetch_assoc($result));
     311    $user_infos_row = pwg_db_fetch_assoc($result);
     312  }
     313
     314  // then merge basic + additional user data
     315  $row = array_merge($row, $user_infos_row);
    312316
    313317  foreach ($row as $key => $value)
Note: See TracChangeset for help on using the changeset viewer.