Fix "total_count" type on some WS methods

This commit is contained in:
mistic100 2024-08-30 19:23:15 +02:00 committed by Pierrick Le Gall
parent 8fc3c9cd0e
commit 3f07808d7f
3 changed files with 8 additions and 4 deletions

View file

@ -2087,12 +2087,12 @@ function update_user_list() {
// console.log(data.message); // console.log(data.message);
return; return;
} }
total_users = data.result.total_count; total_users = data.result.paging.total_count;
if (first_update) { if (first_update) {
$("h1").append(`<span class='badge-number'>${total_users}</span>`); $("h1").append(`<span class='badge-number'>${total_users}</span>`);
first_update = false; first_update = false;
} }
nb_filtered_users = data.result.total_count; nb_filtered_users = data.result.paging.total_count;
update_pagination_menu(); update_pagination_menu();
current_users = data.result.users; current_users = data.result.users;
generate_user_list(); generate_user_list();

View file

@ -137,6 +137,7 @@ SELECT SQL_CALC_FOUND_ROWS i.*
} }
list($total_images) = pwg_db_fetch_row(pwg_query('SELECT FOUND_ROWS()')); list($total_images) = pwg_db_fetch_row(pwg_query('SELECT FOUND_ROWS()'));
$total_images = (int)$total_images;
// let's take care of adding the related albums to each photo // let's take care of adding the related albums to each photo
if (count($image_ids) > 0) if (count($image_ids) > 0)

View file

@ -243,6 +243,7 @@ SELECT DISTINCT ';
if (isset($params['display']['total_count'])) { if (isset($params['display']['total_count'])) {
$total_count_query_result = pwg_query('SELECT FOUND_ROWS();'); $total_count_query_result = pwg_query('SELECT FOUND_ROWS();');
list($total_count) = pwg_db_fetch_row($total_count_query_result); list($total_count) = pwg_db_fetch_row($total_count_query_result);
$total_count = (int)$total_count;
} }
while ($row = pwg_db_fetch_assoc($result)) while ($row = pwg_db_fetch_assoc($result))
{ {
@ -351,12 +352,14 @@ SELECT DISTINCT ';
array( array(
'page' => $params['page'], 'page' => $params['page'],
'per_page' => $params['per_page'], 'per_page' => $params['per_page'],
'count' => count($users) 'count' => count($users),
'total_count' => $total_count,
) )
), ),
'users' => new PwgNamedArray(array_values($users), 'user') 'users' => new PwgNamedArray(array_values($users), 'user')
); );
} }
// deprecated: kept for retrocompatibility
if (isset($params['display']['total_count'])) { if (isset($params['display']['total_count'])) {
$method_result['total_count'] = $total_count; $method_result['total_count'] = $total_count;
} }