fix(heartbeat): only send heartbeat for primary domain, not aliases
Universal: Build & Release / Build & Release Pipeline (pull_request) Has been skipped
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 3s
Joomla: Extension CI / Lint & Validate (pull_request) Failing after 4s
Joomla: Extension CI / Release Readiness Check (pull_request) Successful in 4s
Joomla: Extension CI / Tests (PHP 8.2) (pull_request) Has been skipped
Joomla: Extension CI / Tests (PHP 8.3) (pull_request) Has been skipped
Joomla: Extension CI / PHPStan Analysis (pull_request) Has been skipped
Universal: PR Check / Validate PR (pull_request) Failing after 3s
Universal: PR Check / Changelog Updated (pull_request) Successful in 3s

Alias domains were creating separate Grafana datasources with unique
UIDs, causing provisioning failures (duplicate UID) when Grafana
restarts. Only the primary domain should be registered.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-23 18:34:57 -05:00
parent 5360c641e9
commit cc907a5aa2
+3 -29
View File
@@ -2711,8 +2711,9 @@ class MokoWaaS extends CMSPlugin
/**
* Send heartbeat to the MokoWaaS monitoring receiver.
*
* Registers this site (and any aliases) with the Grafana provisioning system.
* Registers this site's primary domain with the Grafana provisioning system.
* The receiver writes a datasource YAML file and restarts Grafana.
* Alias domains are not registered to avoid duplicate datasource UIDs.
*
* @param \Joomla\Registry\Registry $params Plugin params
* @param \Joomla\CMS\Application\CMSApplication $app Application
@@ -2733,35 +2734,8 @@ class MokoWaaS extends CMSPlugin
$siteUrl = rtrim(Uri::root(), '/');
$siteName = Factory::getConfig()->get('sitename', 'Joomla');
// Register primary domain
// Register primary domain only — aliases should not get separate datasources
$this->sendHeartbeat($siteUrl, $siteName, $healthToken, $app);
// Register any alias domains (subform format: array of objects with domain key)
$aliases = $params->get('site_aliases', '');
if (!empty($aliases))
{
if (is_string($aliases))
{
$aliases = json_decode($aliases, false);
}
if (is_array($aliases))
{
foreach ($aliases as $alias)
{
$alias = (object) $alias;
if (!empty($alias->domain))
{
$domain = trim($alias->domain);
$aliasUrl = 'https://' . preg_replace('#^https?://#i', '', $domain);
$aliasUrl = rtrim($aliasUrl, '/');
$this->sendHeartbeat($aliasUrl, $siteName, $healthToken, $app);
}
}
}
}
}
/**