fix: avoid stale caches
This commit is contained in:
@@ -34,11 +34,20 @@ class BookingEditDataLoaderService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads booking data from session or initializes from API on first load.
|
* 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
|
public function loadFormData(Request $request, int $bookingId, string $email, string $password): ?BookingDto
|
||||||
{
|
{
|
||||||
$formData = $this->bookingService->getBookingDto($request, BookingDto::MODE_EDIT);
|
$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) {
|
if (null === $formData) {
|
||||||
return $this->initializeFromApi($request, $bookingId, $email, $password);
|
return $this->initializeFromApi($request, $bookingId, $email, $password);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user