From 43cc08e19806fd5fc72f3cf146bdaa28a8983004 Mon Sep 17 00:00:00 2001 From: singhharsh1708 Date: Mon, 16 Nov 2026 03:03:04 +0530 Subject: [PATCH] fix: stop the zones API starting zmc for a WebSite monitor when a zone is added --- tests/php/test_api_zone_website_zmc.php | 32 ++++++++++++++++++++++ web/api/app/Controller/ZonesController.php | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/php/test_api_zone_website_zmc.php diff --git a/tests/php/test_api_zone_website_zmc.php b/tests/php/test_api_zone_website_zmc.php new file mode 100644 index 0000000000..543d7983f0 --- /dev/null +++ b/tests/php/test_api_zone_website_zmc.php @@ -0,0 +1,32 @@ + $line) { + if (strpos($line, '->zmcControl(') === false) continue; + if (strpos($line, "Type() != 'WebSite'") !== false) { + $passes++; + echo 'ok - line '.($n+1)." skips WebSite monitors\n"; + } else { + $failures++; + echo 'not ok - line '.($n+1).' calls zmcControl() for WebSite monitors: '.trim($line)."\n"; + } +} + +if (!$passes and !$failures) { + $failures++; + echo "not ok - no zmcControl() calls found\n"; +} + +echo "\n$passes passed, $failures failed\n"; +exit($failures ? 1 : 0); +?> diff --git a/web/api/app/Controller/ZonesController.php b/web/api/app/Controller/ZonesController.php index f59b2b7b8a..0ede9b2187 100644 --- a/web/api/app/Controller/ZonesController.php +++ b/web/api/app/Controller/ZonesController.php @@ -138,7 +138,7 @@ class ZonesController extends AppController { if ( $zone ) { require_once __DIR__ .'/../../../includes/Monitor.php'; $monitor = new ZM\Monitor($zone['Zone']['MonitorId']); - $monitor->zmcControl('restart'); + if ($monitor->Type() != 'WebSite') $monitor->zmcControl('restart'); $message = 'Saved'; //$zone = $this->Zone->find('first', array('conditions' => array( array('Zone.' . $this->Zone->primaryKey => $this->Zone), } else {