From 87027c8a9adc08da482af5bf765e629c2aa8be45 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Tue, 15 Nov 2022 09:58:43 +0000 Subject: [PATCH] remove unused column repeat_quantity from table resource_bookings, fixes #1142 Closes #1142 Merge request studip/studip!1158 --- app/controllers/resources/booking.php | 2 +- app/controllers/room_management/planning.php | 1 - .../5.3.5_remove_bookings_repeat_quantity.php | 21 +++++++++++++++++++ lib/models/resources/Resource.class.php | 4 +--- .../resources/ResourceBooking.class.php | 11 +++++----- lib/raumzeit/SingleDate.class.php | 1 - .../lib/models/resources/ResourceTest.php | 5 ----- 7 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 db/migrations/5.3.5_remove_bookings_repeat_quantity.php diff --git a/app/controllers/resources/booking.php b/app/controllers/resources/booking.php index d05862d7877..63d126168d6 100644 --- a/app/controllers/resources/booking.php +++ b/app/controllers/resources/booking.php @@ -1598,7 +1598,7 @@ class Resources_BookingController extends AuthenticatedController ] ], $this->booking->getRepetitionInterval(), - $this->booking->repeat_quantity, + 0, $this->booking->repeat_end, $this->booking->preparation_time, $this->booking->description, diff --git a/app/controllers/room_management/planning.php b/app/controllers/room_management/planning.php index d30d23c90ca..7f01e864792 100644 --- a/app/controllers/room_management/planning.php +++ b/app/controllers/room_management/planning.php @@ -934,7 +934,6 @@ class RoomManagement_PlanningController extends AuthenticatedController $copy->preparation_time = $booking->preparation_time; $copy->booking_type = $booking->booking_type; $copy->repeat_end = $target_repeat_end->getTimestamp(); - $copy->repeat_quantity = $booking->repeat_quantity; $copy->repetition_interval = $booking->repetition_interval; $copy->internal_comment = $booking->internal_comment; if ($this->step == 3) { diff --git a/db/migrations/5.3.5_remove_bookings_repeat_quantity.php b/db/migrations/5.3.5_remove_bookings_repeat_quantity.php new file mode 100644 index 00000000000..d112906af81 --- /dev/null +++ b/db/migrations/5.3.5_remove_bookings_repeat_quantity.php @@ -0,0 +1,21 @@ +<?php + +class RemoveBookingsRepeatQuantity extends Migration +{ + public function description() + { + return 'Remove unused column repeat_quantity from table resource_bookings'; + } + + protected function up() + { + $query = 'ALTER TABLE resource_bookings DROP COLUMN repeat_quantity'; + DBManager::get()->exec($query); + } + + protected function down() + { + $query = 'ALTER TABLE resource_bookings ADD COLUMN repeat_quantity int(2) AFTER repeat_end'; + DBManager::get()->exec($query); + } +} diff --git a/lib/models/resources/Resource.class.php b/lib/models/resources/Resource.class.php index 99d335f3357..0a04dc51a69 100644 --- a/lib/models/resources/Resource.class.php +++ b/lib/models/resources/Resource.class.php @@ -645,7 +645,7 @@ class Resource extends SimpleORMap implements StudipItem * DateInterval object. * In case repetitions are specified by their amount set this * parameter to null. - * @param int $repetition_amount + * @param int $repetition_amount (obsolete, has no effect) * @param int $preparation_time The preparation time which is needed before * the real start time. This will be substracted * from the begin timestamp and stored in an extra column of the @@ -841,8 +841,6 @@ class Resource extends SimpleORMap implements StudipItem } else { $booking->repeat_end = $repetition_end_date; } - } elseif ($repetition_amount) { - $booking->repeat_quantity = $repetition_amount; } $booking->repetition_interval = $repetition_interval->format('P%YY%MM%DD'); diff --git a/lib/models/resources/ResourceBooking.class.php b/lib/models/resources/ResourceBooking.class.php index a8e65dd07e4..3d8ec289916 100644 --- a/lib/models/resources/ResourceBooking.class.php +++ b/lib/models/resources/ResourceBooking.class.php @@ -41,7 +41,6 @@ * 3 = planned booking (reservation from external tools) * * @property int repeat_end database column - * @property int repeat_quantity database column * @property string repetition_interval database column * The repetition_interval column contains a date interval string in a * format that is accepted by the DateInterval class constructor. @@ -469,12 +468,12 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen } if ($this->repetition_interval) { - if (!($this->repeat_quantity || $this->repeat_end)) { + if (!$this->repeat_end) { throw new InvalidArgumentException( _('Es wurde ein Wiederholungsintervall ohne Begrenzung angegeben!') ); } - if ((!$this->repeat_quantity) && ($this->real_begin > $this->repeat_end)) { + if ($this->real_begin > $this->repeat_end) { throw new InvalidArgumentException( _('Der Startzeitpunkt darf nicht hinter dem Ende der Wiederholungen liegen!') ); @@ -717,12 +716,12 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen if ($this->repetition_interval) { $repetition_interval = $this->getRepetitionInterval(); - if (!($this->repeat_quantity || $this->repeat_end)) { + if (!$this->repeat_end) { throw new InvalidArgumentException( _('Es wurde ein Wiederholungsintervall ohne Begrenzung angegeben!') ); } - if ((!$this->repeat_quantity) && ($this->real_begin > $this->repeat_end)) { + if ($this->real_begin > $this->repeat_end) { throw new InvalidArgumentException( _('Der Startzeitpunkt darf nicht hinter dem Ende der Wiederholungen liegen!') ); @@ -1208,7 +1207,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen ) ]; - if (($this->repeat_quantity > 0) || $this->repeat_end) { + if ($this->repeat_end) { //Repetition: we must check which repetition interval has been //selected and then create entries for each repetition. //Repetition starts with the begin date and ends with the diff --git a/lib/raumzeit/SingleDate.class.php b/lib/raumzeit/SingleDate.class.php index d5f1d00423e..289187fd58d 100644 --- a/lib/raumzeit/SingleDate.class.php +++ b/lib/raumzeit/SingleDate.class.php @@ -645,7 +645,6 @@ class SingleDate $changeAssign->begin = $this->date; $changeAssign->end = $this->end_time; $changeAssign->repeat_end = $this->end_time; - $changeAssign->repeat_quantity = 0; $changeAssign->repetition_interval = ''; if ($preparation_time > 0) { $changeAssign->preparation_time = $preparation_time * 60; diff --git a/tests/functional/lib/models/resources/ResourceTest.php b/tests/functional/lib/models/resources/ResourceTest.php index 66eae5583bb..75a082a0fb6 100644 --- a/tests/functional/lib/models/resources/ResourceTest.php +++ b/tests/functional/lib/models/resources/ResourceTest.php @@ -253,11 +253,6 @@ class ResourceTest extends \Codeception\Test\Unit $this->booking->repeat_end ); - $this->assertEquals( - null, - $this->booking->repeat_quantity - ); - $this->assertEquals( 'P00Y00M02D', $this->booking->repetition_interval -- GitLab