Skip to content

Commit

Permalink
42614: BookingPool: Cloning of schedules does not work correctly, ID …
Browse files Browse the repository at this point in the history
…1 seems to be stored for the booking object
  • Loading branch information
alex40724 committed Nov 10, 2024
1 parent 63e54fc commit 85388b1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions components/ILIAS/BookingManager/classes/Setup/class.Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ protected function getObjectives(): array
// db update steps
$objectives[] = new \ilDatabaseUpdateStepsExecutedObjective(new ilBookingManagerDBUpdateSteps());

$objectives[] = new \ilDatabaseUpdateStepsExecutedObjective(new ilBookingManager8HotfixDBUpdateSteps());

return $objectives;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\BookingManager\Setup;

class ilBookingManager8HotfixDBUpdateSteps implements \ilDatabaseUpdateSteps
{
protected \ilDBInterface $db;

public function prepare(\ilDBInterface $db): void
{
$this->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"]]
]
);
}
}
}
}
}

0 comments on commit 85388b1

Please sign in to comment.