fix: avoid stale caches

This commit is contained in:
Björn Fromme
2025-12-09 10:25:11 +01:00
parent f21f4a0385
commit 0239aee89a
@@ -34,11 +34,20 @@ class BookingEditDataLoaderService
/**
* Loads booking data from session or initializes from API on first load.
*
* Validates that any cached session data matches the requested booking ID.
* If a different booking is in session, it is cleared and fresh data is loaded.
*/
public function loadFormData(Request $request, int $bookingId, string $email, string $password): ?BookingDto
{
$formData = $this->bookingService->getBookingDto($request, BookingDto::MODE_EDIT);
// Validate session data matches requested booking - clear stale data if mismatched
if (null !== $formData && $formData->booking?->id !== $bookingId) {
$this->bookingService->clearBookingDto($request, BookingDto::MODE_EDIT);
$formData = null;
}
if (null === $formData) {
return $this->initializeFromApi($request, $bookingId, $email, $password);
}