Fix alert audio not rendering: resolve sounds dir from plugin root (#278)

getMonitorSound() used __DIR__ . '/sounds/' after the controller moved to includes/, so the sound file was never found and the audio element was never printed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
TheWitnessandCopilot authored and GitHub committed 2026-10-16 15:20:41 -04:00
1 parent 487f9b3e09
commit bef1ad80a0
3 files changed
+21 -1

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
--- 3.0 ---
* bug: Restore alert audio for down and triggered devices; getMonitorSound() looked for sounds in includes/sounds/ after the controller moved, so the audio element was never rendered
* feature: Replace the single Status column/filter with a multi-select Events filter (additive) and an Events column that shows a short pill per active event (Down, Recovering, Triggered, Down/Triggered M/A, Warn/Alert Ping, Failed Svc), 'None' when clean; the Status scope dropdown now only selects All Monitored / All Devices / Not Monitored / Without Thresholds
* bug: Centre the tile hostname under the glyph and keep it clickable in the Tiles & Time view
* bug: Remove the 'Names only' View option from the dropdown (the renderer is retained for direct ?view=names use)
+1 -1
View File
@@ -259,7 +259,7 @@ function isMonitorAudible(): bool {
function getMonitorSound(): string {
$sound = (string) read_user_setting('monitor_sound', read_config_option('monitor_sound'));
clearstatcache();
$file = __DIR__ . '/sounds/' . $sound;
$file = dirname(__DIR__) . '/sounds/' . $sound;
$exists = file_exists($file);
return $exists ? $sound : '';
@@ -0,0 +1,19 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
*/
it('resolves the alert sound against the plugin sounds directory', function () {
$root = dirname(__DIR__, 2);
$contents = file_get_contents($root . '/includes/controller.php');
expect($contents)->not->toBeFalse();
expect($contents)->toContain("dirname(__DIR__) . '/sounds/'");
expect($contents)->not->toContain("__DIR__ . '/sounds/'");
expect(is_dir($root . '/sounds'))->toBeTrue();
expect(is_dir($root . '/includes/sounds'))->toBeFalse();
});