From bef1ad80a05c81e71a56a9405a1b078a62885ca8 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Fri, 16 Oct 2026 15:20:41 -0400 Subject: [PATCH] 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> --- CHANGELOG.md | 1 + includes/controller.php | 2 +- tests/Integration/MonitorSoundPathTest.php | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/Integration/MonitorSoundPathTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index dcaaa8d..6042140 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/includes/controller.php b/includes/controller.php index 8c2d431..1aa669b 100644 --- a/includes/controller.php +++ b/includes/controller.php @@ -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 : ''; diff --git a/tests/Integration/MonitorSoundPathTest.php b/tests/Integration/MonitorSoundPathTest.php new file mode 100644 index 0000000..733f712 --- /dev/null +++ b/tests/Integration/MonitorSoundPathTest.php @@ -0,0 +1,19 @@ +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(); +});