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) git-svn-id: http://piwigo.org/svn/branches/2.1@6312 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
0786ff3b79
commit
b7ed5e6af4
1 changed files with 18 additions and 14 deletions
|
@ -267,6 +267,7 @@ function getuserdata($user_id, $use_cache)
|
||||||
|
|
||||||
$userdata = array();
|
$userdata = array();
|
||||||
|
|
||||||
|
// retrieve basic user data
|
||||||
$query = '
|
$query = '
|
||||||
SELECT ';
|
SELECT ';
|
||||||
$is_first = true;
|
$is_first = true;
|
||||||
|
@ -289,26 +290,29 @@ SELECT ';
|
||||||
|
|
||||||
$row = pwg_db_fetch_assoc(pwg_query($query));
|
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
|
||||||
while (true)
|
// retrieve additional user data
|
||||||
{
|
$query = '
|
||||||
$query = '
|
SELECT
|
||||||
SELECT ui.*, uc.*, t.name AS theme_name
|
COUNT(1) AS counter,
|
||||||
|
ui.*,
|
||||||
|
uc.*,
|
||||||
|
t.name AS theme_name
|
||||||
FROM '.USER_INFOS_TABLE.' AS ui
|
FROM '.USER_INFOS_TABLE.' AS ui
|
||||||
LEFT JOIN '.USER_CACHE_TABLE.' AS uc ON ui.user_id = uc.user_id
|
LEFT JOIN '.USER_CACHE_TABLE.' AS uc ON ui.user_id = uc.user_id
|
||||||
LEFT JOIN '.THEMES_TABLE.' AS t ON t.id = ui.theme
|
LEFT JOIN '.THEMES_TABLE.' AS t ON t.id = ui.theme
|
||||||
WHERE ui.user_id = \''.$user_id.'\'';
|
WHERE ui.user_id = \''.$user_id.'\'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
$user_infos_row = pwg_db_fetch_assoc($result);
|
||||||
|
if (0 == $user_infos_row['counter']) {
|
||||||
|
create_user_infos($user_id);
|
||||||
|
|
||||||
$result = pwg_query($query);
|
$result = pwg_query($query);
|
||||||
if ($result)
|
$user_infos_row = pwg_db_fetch_assoc($result);
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
create_user_infos($user_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = array_merge($row, pwg_db_fetch_assoc($result));
|
// then merge basic + additional user data
|
||||||
|
$row = array_merge($row, $user_infos_row);
|
||||||
|
|
||||||
foreach ($row as $key => $value)
|
foreach ($row as $key => $value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue