fix: avoid stale caches

This commit is contained in:
Björn Fromme
2026-03-16 12:00:55 +01:00
parent ef15772b97
commit bc175ca438
@@ -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);
}