diff --git a/cli/updates_xml_build.php b/cli/updates_xml_build.php index bfebc69..76ba235 100644 --- a/cli/updates_xml_build.php +++ b/cli/updates_xml_build.php @@ -316,6 +316,32 @@ for ($i = 0; $i <= $stabilityIndex; $i++) { ); } +// -- Preserve existing entries for channels not being updated ----------------- +$dest = $outputFile ?? "{$root}/updates.xml"; +$preservedEntries = []; + +if (file_exists($dest)) { + $existingXml = @simplexml_load_file($dest); + if ($existingXml) { + // Channels we're writing — don't preserve these + $writtenChannels = []; + for ($i = 0; $i <= $stabilityIndex; $i++) { + $writtenChannels[] = $allChannels[$i]; + } + + foreach ($existingXml->update as $existingUpdate) { + $existingTag = ''; + if (isset($existingUpdate->tags->tag)) { + $existingTag = (string) $existingUpdate->tags->tag; + } + // Keep entries for channels we're NOT overwriting + if (!empty($existingTag) && !in_array($existingTag, $writtenChannels, true)) { + $preservedEntries[] = ' ' . trim($existingUpdate->asXML()); + } + } + } +} + // -- Write updates.xml -------------------------------------------------------- $year = date('Y'); $output = << XML; -$output .= "\n" . implode("\n", $entries) . "\n\n"; +$allEntries = array_merge($preservedEntries, $entries); +$output .= "\n" . implode("\n", $allEntries) . "\n\n"; $dest = $outputFile ?? "{$root}/updates.xml"; file_put_contents($dest, $output);