mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
[dashboard] Fix memory exhaustion on system counts (#6844)
Getting all rows from the database caused PHP to exhaust the memory on systems with a huge amount of VM messages. This was fixed by querying from the database just the total counts.
This commit is contained in:
committed by
GitHub
parent
9f204a7cac
commit
e050827598
@@ -227,16 +227,27 @@
|
||||
$stats['system']['messages']['new'] = 0;
|
||||
$stats['domain']['messages']['total'] = 0;
|
||||
$stats['domain']['messages']['new'] = 0;
|
||||
$sql = "select domain_uuid, message_status from v_voicemail_messages";
|
||||
$result = $database->select($sql, null, 'all');
|
||||
$sql = "SELECT count(*) total, count(*) FILTER(WHERE message_status IS DISTINCT FROM 'saved') AS new ";
|
||||
$sql .= "FROM v_voicemail_messages WHERE domain_uuid = :domain_uuid ";
|
||||
$parameters["domain_uuid"] = $_SESSION['domain_uuid'];
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
|
||||
if (is_array($result) && sizeof($result) != 0) {
|
||||
$stats['system']['messages']['total'] = sizeof($result);
|
||||
foreach ($result as $row) {
|
||||
$stats['system']['messages']['new'] += ($row['message_status'] != 'saved') ? 1 : 0;
|
||||
if ($row['domain_uuid'] == $_SESSION['domain_uuid']) {
|
||||
$stats['domain']['messages']['total']++;
|
||||
$stats['domain']['messages']['new'] += ($row['message_status'] != 'saved') ? 1 : 0;
|
||||
}
|
||||
$stats['domain']['messages']['total'] = $row['total'];
|
||||
$stats['domain']['messages']['new'] = $row['new'];
|
||||
}
|
||||
}
|
||||
unset($sql, $result, $parameters);
|
||||
|
||||
$sql = "SELECT count(*) total, count(*) FILTER(WHERE message_status IS DISTINCT FROM 'saved') AS new ";
|
||||
$sql .= "FROM v_voicemail_messages ";
|
||||
$result = $database->select($sql, null, 'all');
|
||||
|
||||
if (is_array($result) && sizeof($result) != 0) {
|
||||
foreach ($result as $row) {
|
||||
$stats['system']['messages']['total'] = $row['total'];
|
||||
$stats['system']['messages']['new'] = $row['new'];
|
||||
}
|
||||
}
|
||||
unset($sql, $result);
|
||||
@@ -476,4 +487,4 @@
|
||||
|
||||
echo "<span class='hud_expander' onclick=\"$('#hud_system_counts_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>\n";
|
||||
echo "</div>\n";
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user