diff --git a/components/ILIAS/BookingManager/Schedule/class.ilBookingSchedule.php b/components/ILIAS/BookingManager/Schedule/class.ilBookingSchedule.php index bd27fd512d81..9ebb8874d6f2 100755 --- a/components/ILIAS/BookingManager/Schedule/class.ilBookingSchedule.php +++ b/components/ILIAS/BookingManager/Schedule/class.ilBookingSchedule.php @@ -202,12 +202,12 @@ protected function read(): void } } - public function save(): bool + public function save(): ?int { $ilDB = $this->db; if ($this->id) { - return false; + return null; } $this->id = $ilDB->nextId('booking_schedule'); @@ -264,7 +264,7 @@ public function update(): bool return true; } - public function doClone(int $a_pool_id): bool + public function doClone(int $a_pool_id): int { $new_obj = new self(); $new_obj->setPoolId($a_pool_id); diff --git a/components/ILIAS/BookingManager/classes/Setup/class.Agent.php b/components/ILIAS/BookingManager/classes/Setup/class.Agent.php index a97e4f9dab25..f5a25275eab9 100755 --- a/components/ILIAS/BookingManager/classes/Setup/class.Agent.php +++ b/components/ILIAS/BookingManager/classes/Setup/class.Agent.php @@ -71,6 +71,8 @@ protected function getObjectives(): array // db update steps $objectives[] = new \ilDatabaseUpdateStepsExecutedObjective(new ilBookingManagerDBUpdateSteps()); + $objectives[] = new \ilDatabaseUpdateStepsExecutedObjective(new ilBookingManager8HotfixDBUpdateSteps()); + return $objectives; } diff --git a/components/ILIAS/BookingManager/classes/Setup/class.ilBookingManager8HotfixDBUpdateSteps.php b/components/ILIAS/BookingManager/classes/Setup/class.ilBookingManager8HotfixDBUpdateSteps.php new file mode 100644 index 000000000000..fd751b4933b9 --- /dev/null +++ b/components/ILIAS/BookingManager/classes/Setup/class.ilBookingManager8HotfixDBUpdateSteps.php @@ -0,0 +1,63 @@ +db = $db; + } + + public function step_1(): void + { + $db = $this->db; + $set1 = $db->queryF( + "SELECT * FROM booking_object " . + " WHERE schedule_id = %s ", + ["integer"], + [1] + ); + while ($rec1 = $db->fetchAssoc($set1)) { + $set2 = $db->queryF( + "SELECT * FROM booking_schedule " . + " WHERE pool_id = %s ORDER BY booking_schedule_id ASC LIMIT 1", + ["integer"], + [$rec1["pool_id"]] + ); + if ($rec2 = $db->fetchAssoc($set2)) { + if ((int) $rec2["booking_schedule_id"] !== 1) { + $db->update( + "booking_object", + [ + "schedule_id" => ["intger", $rec2["booking_schedule_id"]] + ], + [ // where + "booking_object_id" => ["integer", $rec1["booking_object_id"]] + ] + ); + } + } + } + } +}