From d690447cdbdf7f07de9a539ef752dab69a205390 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 3 Aug 2025 20:01:55 +0300 Subject: [PATCH] fix(ACP): A non-numeric value encountered for stats (#2073) --- admin/index.php | 8 ++++---- index.php | 6 +++--- library/includes/datastore/build_stats.php | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/admin/index.php b/admin/index.php index 1b42b53fa..1f7bbd491 100644 --- a/admin/index.php +++ b/admin/index.php @@ -128,14 +128,14 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') { $topics_per_day = $total_topics; } - if ($users_per_day > $total_users) { + if ((int)$users_per_day > $total_users) { $users_per_day = $total_users; } $template->assign_vars([ - 'NUMBER_OF_POSTS' => $total_posts, - 'NUMBER_OF_TOPICS' => $total_topics, - 'NUMBER_OF_USERS' => $total_users, + 'NUMBER_OF_POSTS' => commify($total_posts), + 'NUMBER_OF_TOPICS' => commify($total_topics), + 'NUMBER_OF_USERS' => commify($total_users), 'START_DATE' => $start_date, 'POSTS_PER_DAY' => $posts_per_day, 'TOPICS_PER_DAY' => $topics_per_day, diff --git a/index.php b/index.php index 2c752341c..589b061ae 100644 --- a/index.php +++ b/index.php @@ -272,9 +272,9 @@ $template->assign_vars([ 'PAGE_TITLE' => $viewcat ? $cat_title_html[$viewcat] : $lang['HOME'], 'NO_FORUMS_MSG' => $only_new ? $lang['NO_NEW_POSTS'] : $lang['NO_FORUMS'], - 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], $stats['topiccount']), - 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], $stats['postcount']), - 'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], $stats['usercount']), + 'TOTAL_TOPICS' => sprintf($lang['POSTED_TOPICS_TOTAL'], commify($stats['topiccount'])), + 'TOTAL_POSTS' => sprintf($lang['POSTED_ARTICLES_TOTAL'], commify($stats['postcount'])), + 'TOTAL_USERS' => sprintf($lang['REGISTERED_USERS_TOTAL'], commify($stats['usercount'])), 'TOTAL_GENDER' => $bb_cfg['gender'] ? sprintf( $lang['USERS_TOTAL_GENDER'], $stats['male'], diff --git a/library/includes/datastore/build_stats.php b/library/includes/datastore/build_stats.php index e25d8e085..1b4ffbe98 100644 --- a/library/includes/datastore/build_stats.php +++ b/library/includes/datastore/build_stats.php @@ -17,7 +17,7 @@ $data = []; // usercount $row = DB()->fetch_row("SELECT COUNT(*) AS usercount FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")"); -$data['usercount'] = commify($row['usercount']); +$data['usercount'] = (int)$row['usercount']; // newestuser $row = DB()->fetch_row("SELECT user_id, username, user_rank FROM " . BB_USERS . " WHERE user_active = 1 AND user_id NOT IN(" . EXCLUDED_USERS . ") ORDER BY user_id DESC LIMIT 1"); @@ -25,8 +25,8 @@ $data['newestuser'] = $row; // post/topic count $row = DB()->fetch_row("SELECT SUM(forum_topics) AS topiccount, SUM(forum_posts) AS postcount FROM " . BB_FORUMS); -$data['postcount'] = commify($row['postcount']); -$data['topiccount'] = commify($row['topiccount']); +$data['postcount'] = (int)$row['postcount']; +$data['topiccount'] = (int)$row['topiccount']; // Tracker stats if ($bb_cfg['tor_stats']) {