Report a child's state from the list it was rendered from

Only the array name was taken from the orchestrator; the enabled flag still came
from the first-match map, so every orchestrator showed the first list's state.
This commit is contained in:
Gmer4Lfe
2026-08-11 20:11:14 -04:00
parent dfe4c0d495
commit 24b526db93
+12 -6
View File
@@ -688,7 +688,7 @@ function vv_script_children(string $orchPath, array $schedule): array {
// first it meets, so the map would label the monthly child DAILY_MAINTENANCE_SCRIPTS. Every
// consumer of conf_array then acts on the wrong line: the toggle disabled daily when monthly
// was clicked, and the drag reorder read the wrong list.
$addChild = function(string $rel, ?string $fromArray = null)
$addChild = function(string $rel, ?string $fromArray = null, ?bool $fromEnabled = null)
use ($scriptsDir, $schedule, $confMap, &$children, &$seen) {
if (isset($seen[$rel]) || !file_exists("$scriptsDir/$rel")) return;
$seen[$rel] = true;
@@ -703,10 +703,14 @@ function vv_script_children(string $orchPath, array $schedule): array {
'enabled' => (bool)($entry['enabled'] ?? false),
'cron' => $entry['cron'] ?? '',
'log_enabled' => (bool)($entry['log_enabled'] ?? false),
'conf_managed' => $conf['managed'],
'conf_enabled' => $conf['enabled'], // null if not in any *_SCRIPTS array
// The array this orchestrator reads, when we know it. Falling back to the map is only
// for children found as static paths, which are not array members at all.
// All three come from the array this orchestrator actually iterates whenever we know
// it, and only fall back to the map for children found as static paths, which are not
// array members at all. Taking any one of them from the map instead is the same bug:
// the map keeps the first array a script appears in, so a script in three lists would
// report one list's name, one list's state, and act on one list's line — whichever
// master.conf happens to declare first, in every orchestrator that shows it.
'conf_managed' => $fromArray !== null ? true : $conf['managed'],
'conf_enabled' => $fromArray !== null ? $fromEnabled : $conf['enabled'],
'conf_array' => $fromArray ?? $conf['array'],
'suggested_cron' => $suggested['cron'],
'suggested_label' => $suggested['label'],
@@ -725,7 +729,9 @@ function vv_script_children(string $orchPath, array $schedule): array {
if (!empty($refs[1])) {
$confRaw = file_get_contents(CONF_DIR . '/master.conf') ?: '';
foreach (array_unique($refs[1]) as $varName) {
foreach (vv_parse_conf_array_full($confRaw, $varName) as $item) $addChild($item['path'], $varName);
foreach (vv_parse_conf_array_full($confRaw, $varName) as $item) {
$addChild($item['path'], $varName, $item['enabled']);
}
}
}