Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting multiple reservation does not work when a reservation spans multiple resources #437

Open
GuillaumeV-cemea opened this issue Oct 11, 2024 · 0 comments

Comments

@GuillaumeV-cemea
Copy link

Reproductions steps :

Search for reservations using the admin/manage_reservations.php page.
Select all reservations, then delete them using the delete button at the bottom, accept the warning

Expected result :

All reservations are deleted

Actual result :
Only some reservations are deleted, it stops at the first reservation spanning multiple resources.

Looking at the log, I can see that delete multiple tries to delete one reservation ID two times ; the first time works fine, but the second one errors out, which stops further deletion :

[2024-10-11T12:06:19.217747+00:00] app.INFO: [User=Admin ([email protected])] Reservation multiple delete. Ids=2127,2127,2032,1504,1488,2009,1964,1939,1742,1944,1976,1392,1392,1957,2101,1710,1776,1743,1940,1489,2110,1958,2049,2045,1945,2010,2130,2074,2069,2122,2111,1983,1983,1959,1977,1490,1980,1980,2046,2125,2066,2075,1921,2011,2029,2076,1960,1965,1515,1926 [File=/var/www/librebooking/Presenters/Admin/ManageReservationsPresenter.php,Line=494] [] []
[2024-10-11T12:06:19.217793+00:00] app.INFO: [User=Admin ([email protected])] ReservationRepository::LoadById() - ReservationID: 2127 [File=/var/www/librebooking/Domain/Access/ReservationRepository.php,Line=9] [] []
[2024-10-11T12:06:19.233461+00:00] app.INFO: [User=Admin ([email protected])] Removing series 2138 [File=/var/www/librebooking/Domain/ExistingReservationSeries.php,Line=347] [] []
[2024-10-11T12:06:19.234772+00:00] app.INFO: [User=Admin ([email protected])] ReservationRepository::LoadById() - ReservationID: 2127 [File=/var/www/librebooking/Domain/Access/ReservationRepository.php,Line=9] [] []
[2024-10-11T12:06:19.235877+00:00] app.INFO: [User=Admin ([email protected])] Reservation not found [File=/var/www/librebooking/Domain/Access/ReservationRepository.php,Line=26] [] []

I've made a quick fix by removing duplicate from the deletemultiple action, but it's probably not the best way to do it :

diff --git a/Presenters/Admin/ManageReservationsPresenter.php b/Presenters/Admin/ManageReservationsPresenter.php
index c9efca290..ab0172284 100644
--- a/Presenters/Admin/ManageReservationsPresenter.php
+++ b/Presenters/Admin/ManageReservationsPresenter.php
@@ -490,7 +490,7 @@ class ManageReservationsPresenter extends ActionPresenter
 
     public function DeleteMultiple()
     {
-        $ids = $this->page->GetDeletedReservationIds();
+        $ids = array_unique($this->page->GetDeletedReservationIds());
         Log::Debug('Reservation multiple delete. Ids=%s', implode(',', $ids));
         foreach ($ids as $id) {
             $this->manageReservationsService->UnsafeDelete($id, ServiceLocator::GetServer()->GetUserSession());

If this seems sufficient, I can provide a MR for the fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant