mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/9874] view_log() performs unneeded count query over all log entries.
PHPBB3-9874
This commit is contained in:
parent
5e2bbdb22b
commit
a25238e0c1
4 changed files with 18 additions and 14 deletions
|
@ -529,7 +529,7 @@ class acp_main
|
||||||
);
|
);
|
||||||
|
|
||||||
$log_data = array();
|
$log_data = array();
|
||||||
$log_count = 0;
|
$log_count = false;
|
||||||
|
|
||||||
if ($auth->acl_get('a_viewlogs'))
|
if ($auth->acl_get('a_viewlogs'))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2506,6 +2506,7 @@ function cache_moderators()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View log
|
* View log
|
||||||
|
* If $log_count is set to false, we will skip counting all entries in the database.
|
||||||
*/
|
*/
|
||||||
function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '')
|
function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '')
|
||||||
{
|
{
|
||||||
|
@ -2761,16 +2762,19 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT COUNT(l.log_id) AS total_entries
|
if ($log_count !== false)
|
||||||
FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
|
{
|
||||||
WHERE l.log_type = $log_type
|
$sql = 'SELECT COUNT(l.log_id) AS total_entries
|
||||||
AND l.user_id = u.user_id
|
FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
|
||||||
AND l.log_time >= $limit_days
|
WHERE l.log_type = $log_type
|
||||||
$sql_keywords
|
AND l.user_id = u.user_id
|
||||||
$sql_forum";
|
AND l.log_time >= $limit_days
|
||||||
$result = $db->sql_query($sql);
|
$sql_keywords
|
||||||
$log_count = (int) $db->sql_fetchfield('total_entries');
|
$sql_forum";
|
||||||
$db->sql_freeresult($result);
|
$result = $db->sql_query($sql);
|
||||||
|
$log_count = (int) $db->sql_fetchfield('total_entries');
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,7 +350,7 @@ function mcp_front_view($id, $mode, $action)
|
||||||
// Add forum_id 0 for global announcements
|
// Add forum_id 0 for global announcements
|
||||||
$forum_list[] = 0;
|
$forum_list[] = 0;
|
||||||
|
|
||||||
$log_count = 0;
|
$log_count = false;
|
||||||
$log = array();
|
$log = array();
|
||||||
view_log('mod', $log, $log_count, 5, 0, $forum_list);
|
view_log('mod', $log, $log_count, 5, 0, $forum_list);
|
||||||
|
|
||||||
|
|
|
@ -227,10 +227,10 @@ function mcp_post_details($id, $mode, $action)
|
||||||
|
|
||||||
// Get User Notes
|
// Get User Notes
|
||||||
$log_data = array();
|
$log_data = array();
|
||||||
$log_count = 0;
|
$log_count = false;
|
||||||
view_log('user', $log_data, $log_count, $config['posts_per_page'], 0, 0, 0, $post_info['user_id']);
|
view_log('user', $log_data, $log_count, $config['posts_per_page'], 0, 0, 0, $post_info['user_id']);
|
||||||
|
|
||||||
if ($log_count)
|
if (!empty($log_data))
|
||||||
{
|
{
|
||||||
$template->assign_var('S_USER_NOTES', true);
|
$template->assign_var('S_USER_NOTES', true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue