Merge pull request #6195 from singhharsh1708/fix/api-zone-add-website

fix: stop the zones API starting zmc for a WebSite monitor when a zone is added
This commit is contained in:
Isaac Connor authored and GitHub committed 2026-11-15 20:40:57 -05:00
commit 3d5cfa85cd
2 files changed
+33 -1

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
<?php
// zmc fatals on a WebSite monitor ("Bogus monitor type"), so the zones API
// must not start or restart one when a zone of such a monitor is added, edited
// or deleted. Every zmcControl() call in ZonesController has to skip them.
//
// Pure source scan:
// php tests/php/test_api_zone_website_zmc.php
$path = __DIR__.'/../../web/api/app/Controller/ZonesController.php';
$passes = 0;
$failures = 0;
foreach (file($path) as $n => $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);
?>
+1 -1
View File
@@ -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 {