diff --git a/Plugin/unraid/include/scheduler.php b/Plugin/unraid/include/scheduler.php index 296f842..01ed508 100644 --- a/Plugin/unraid/include/scheduler.php +++ b/Plugin/unraid/include/scheduler.php @@ -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']); + } } }