Compare only resolved members when planning speaker and instructor changes

Without a member group the import stores an empty speaker list, but the
planner turned every unresolved name into ID 0 and flagged the event as
changed on each upload. With a member group set, the preview now also
reports the change when instructor or speakers will be created on apply.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jürgen MummertandClaude Fable 5.1 committed 2026-09-26 16:29:14 +02:00
1 parent 08aa204ef9
commit d415e9e86b
1 file changed
+14 -4
+14 -4
View File
@@ -126,12 +126,20 @@ class ImportPlanner
$cancelled = WkState::isCancelled($data['wkState']);
// Personen (nur nachschlagen; angelegt wird beim Anwenden)
// Personen (nur nachschlagen; angelegt wird beim Anwenden). Namen ohne Mitglied werden nur dann zu
// Mitgliedern, wenn im Kalender eine Mitgliedergruppe gesetzt ist; sonst speichert der Import sie nicht.
$instructorId = '' !== $row->instructorName ? $this->memberResolver->findId($row->instructorName) : null;
$speakerIds = [];
$unresolvedSpeakers = [];
foreach ($row->speakerNames as $name) {
$speakerIds[] = $this->memberResolver->findId($name);
$id = $this->memberResolver->findId($name);
if (null === $id) {
$unresolvedSpeakers[] = $name;
} else {
$speakerIds[] = $id;
}
}
if (null === $existing) {
@@ -185,14 +193,16 @@ class ImportPlanner
}
$existingInstructor = (int) $existing['wkInstructor'];
$instructorWillBeCreated = $calendar->instructorGroup > 0 && '' !== $row->instructorName && null === $instructorId;
if (('' !== $row->instructorName || $existingInstructor > 0) && $existingInstructor !== (int) $instructorId) {
if ($existingInstructor !== (int) $instructorId || $instructorWillBeCreated) {
$changes['wkInstructor'] = [$this->memberName($existingInstructor), $row->instructorName];
}
$existingSpeakers = array_map(intval(...), StringUtil::deserialize($existing['wkSpeakers'] ?? null, true));
$speakersWillBeCreated = $calendar->speakerGroup > 0 && [] !== $unresolvedSpeakers;
if ($existingSpeakers !== array_map(static fn (int|null $id): int => (int) $id, $speakerIds) && ([] !== $existingSpeakers || [] !== $row->speakerNames)) {
if ($existingSpeakers !== $speakerIds || $speakersWillBeCreated) {
$changes['wkSpeakers'] = [implode(', ', array_values($this->memberResolver->namesByIds($existingSpeakers))), implode(', ', $row->speakerNames)];
}