mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[ticket/9874] view_log() performs unneeded count query over all log entries.
PHPBB3-9874
This commit is contained in:
@@ -2506,6 +2506,7 @@ function cache_moderators()
|
||||
|
||||
/**
|
||||
* 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 = '')
|
||||
{
|
||||
@@ -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
|
||||
FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
|
||||
WHERE l.log_type = $log_type
|
||||
AND l.user_id = u.user_id
|
||||
AND l.log_time >= $limit_days
|
||||
$sql_keywords
|
||||
$sql_forum";
|
||||
$result = $db->sql_query($sql);
|
||||
$log_count = (int) $db->sql_fetchfield('total_entries');
|
||||
$db->sql_freeresult($result);
|
||||
if ($log_count !== false)
|
||||
{
|
||||
$sql = 'SELECT COUNT(l.log_id) AS total_entries
|
||||
FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
|
||||
WHERE l.log_type = $log_type
|
||||
AND l.user_id = u.user_id
|
||||
AND l.log_time >= $limit_days
|
||||
$sql_keywords
|
||||
$sql_forum";
|
||||
$result = $db->sql_query($sql);
|
||||
$log_count = (int) $db->sql_fetchfield('total_entries');
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user