From ea312b9986663e1ab604fd8fca04eeb08a02f1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 16 Oct 2025 09:35:12 +0200 Subject: [PATCH] chore: remove debug statements --- .../Booking/Edit/IndexController.php | 1 - .../DateOfBirthProvidedCondition.php | 9 +-- ...ticipantAdditionalServicesFieldHandler.php | 26 +-------- .../ParticipantFieldHandlerRegistry.php | 5 -- src/Service/BookingFingerprintService.php | 55 +------------------ src/Service/InsuranceMatchingService.php | 22 +------- 6 files changed, 5 insertions(+), 113 deletions(-) diff --git a/src/Controller/Booking/Edit/IndexController.php b/src/Controller/Booking/Edit/IndexController.php index 373e4c0..da4ab10 100644 --- a/src/Controller/Booking/Edit/IndexController.php +++ b/src/Controller/Booking/Edit/IndexController.php @@ -488,7 +488,6 @@ class IndexController extends AbstractController $formData = $this->bookingDataProcessor->createBookingDtoFromBooking($bookingData, $travelData); // Set original fingerprint for dirty state detection - error_log('[Fingerprint] === GENERATING ORIGINAL FINGERPRINT ==='); $formData->originalFingerprint = $this->fingerprintService->generateFingerprint($formData, true); $this->bookingService->saveBookingDto($request, $formData, BookingDto::MODE_EDIT); diff --git a/src/Form/Service/Condition/DateOfBirthProvidedCondition.php b/src/Form/Service/Condition/DateOfBirthProvidedCondition.php index ed48a39..60b820e 100644 --- a/src/Form/Service/Condition/DateOfBirthProvidedCondition.php +++ b/src/Form/Service/Condition/DateOfBirthProvidedCondition.php @@ -36,15 +36,8 @@ class DateOfBirthProvidedCondition implements FieldConditionInterface public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool { $participant = $bookingDto->getParticipant($participantIndex); - $result = null !== $participant && null !== $participant->dateOfBirth; - error_log(sprintf('[DOB Condition] Participant %d: dateOfBirth=%s, result=%s', - $participantIndex, - $participant?->dateOfBirth?->format('Y-m-d') ?? 'NULL', - $result ? 'TRUE' : 'FALSE' - )); - - return $result; + return null !== $participant && null !== $participant->dateOfBirth; } /** diff --git a/src/Form/Service/ParticipantAdditionalServicesFieldHandler.php b/src/Form/Service/ParticipantAdditionalServicesFieldHandler.php index c400430..93f709a 100644 --- a/src/Form/Service/ParticipantAdditionalServicesFieldHandler.php +++ b/src/Form/Service/ParticipantAdditionalServicesFieldHandler.php @@ -100,10 +100,6 @@ class ParticipantAdditionalServicesFieldHandler extends AbstractParticipantField // Extract current service selections from submitted data $selectedServices = $this->getFieldValue($submittedData, $this->getFieldName()) ?? []; - // Debug: Log what was submitted - $submittedIds = array_map(fn($s) => is_object($s) ? $s->id : $s, $selectedServices); - error_log(sprintf('[AdditionalServices] Participant %d: Submitted service IDs: [%s]', $participantIndex, implode(', ', $submittedIds))); - // Get available additional services from travel data $availableServices = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_ADDITIONAL); @@ -115,10 +111,6 @@ class ParticipantAdditionalServicesFieldHandler extends AbstractParticipantField $participantIndex ); - // Debug: Log what passed validation - $validIds = array_map(fn($s) => $s->id, $validSelections); - error_log(sprintf('[AdditionalServices] Participant %d: Valid service IDs after filtering: [%s]', $participantIndex, implode(', ', $validIds))); - // Update participant with validated selections $participant->additionalServices = $validSelections; } @@ -181,33 +173,17 @@ class ParticipantAdditionalServicesFieldHandler extends AbstractParticipantField $service = $this->findServiceInAvailableServices($selectedService, $availableServices); if (null === $service) { - error_log(sprintf('[AdditionalServices] Participant %d: Service %s NOT FOUND in available services', $participantIndex, is_object($selectedService) ? $selectedService->id : $selectedService)); return false; // Service not found in available services } // Check if service has age constraints $ageEvaluator = new ServiceAgeEvaluator(); if (false === $ageEvaluator->canEvaluate($service)) { - error_log(sprintf('[AdditionalServices] Participant %d: Service %d (%s) has NO age constraints - VALID', $participantIndex, $service->id, $service->label)); return true; // No age restrictions, service is valid } // Validate service against participant's age - $isValid = $ageEvaluator->isServiceAvailableForParticipant($service, $bookingDto, $participantIndex); - $participant = $bookingDto->getParticipant($participantIndex); - $age = $participant?->getAge($bookingDto->travel->dateFrom); - - error_log(sprintf( - '[AdditionalServices] Participant %d (age %s): Service %d (%s) age validation = %s. Constraints: %s', - $participantIndex, - $age ?? 'unknown', - $service->id, - $service->label, - $isValid ? 'VALID' : 'INVALID', - $ageEvaluator->getConstraintDescription($service) - )); - - return $isValid; + return $ageEvaluator->isServiceAvailableForParticipant($service, $bookingDto, $participantIndex); } /** diff --git a/src/Form/Service/ParticipantFieldHandlerRegistry.php b/src/Form/Service/ParticipantFieldHandlerRegistry.php index e7bd203..ce775d2 100644 --- a/src/Form/Service/ParticipantFieldHandlerRegistry.php +++ b/src/Form/Service/ParticipantFieldHandlerRegistry.php @@ -82,8 +82,6 @@ class ParticipantFieldHandlerRegistry */ public function processFieldsAndSync(array $submittedData, BookingDto $bookingDto): array { - error_log(sprintf('[ProcessFieldsAndSync] Mode: %s', $bookingDto->getMode())); - // Process all field handlers to clean the DTO $this->processFields($submittedData, $bookingDto); @@ -332,8 +330,6 @@ class ParticipantFieldHandlerRegistry */ private function syncParticipantData(array $participantData, ParticipantDto $participant, int $index, BookingDto $bookingDto): array { - error_log(sprintf('[Sync] Participant %d fields in submission: %s', $participant->index ?? -1, implode(', ', array_keys($participantData)))); - // Sync fields for all registered handlers foreach ($this->handlers as $fieldName => $handler) { // Only sync fields that were in the original submission @@ -341,7 +337,6 @@ class ParticipantFieldHandlerRegistry if (property_exists($participant, $fieldName) && array_key_exists($fieldName, $participantData)) { $dtoValue = $participant->{$fieldName}; $participantData[$fieldName] = $this->convertDtoValueToSubmittedFormat($dtoValue); - error_log(sprintf('[Sync] Participant %d: synced %s', $participant->index ?? -1, $fieldName)); } } diff --git a/src/Service/BookingFingerprintService.php b/src/Service/BookingFingerprintService.php index 1102201..64e67ba 100644 --- a/src/Service/BookingFingerprintService.php +++ b/src/Service/BookingFingerprintService.php @@ -75,14 +75,7 @@ class BookingFingerprintService ]; } - $fingerprint = hash('sha256', serialize($data)); - - if ($logData) { - error_log(sprintf('[Fingerprint] Generated fingerprint: %s', $fingerprint)); - error_log(sprintf('[Fingerprint] Serialized data: %s', serialize($data))); - } - - return $fingerprint; + return hash('sha256', serialize($data)); } /** @@ -121,52 +114,8 @@ class BookingFingerprintService } $currentFingerprint = $this->generateFingerprint($bookingDto); - $isDirty = $bookingDto->originalFingerprint !== $currentFingerprint; - // Debug logging to identify what changed - if ($isDirty) { - error_log(sprintf('[Fingerprint] DIRTY DETECTED! Original: %s, Current: %s', $bookingDto->originalFingerprint, $currentFingerprint)); - $this->logFingerprintDiff($bookingDto); - } - - return $isDirty; + return $bookingDto->originalFingerprint !== $currentFingerprint; } - /** - * Logs detailed fingerprint data for debugging dirty state issues. - */ - private function logFingerprintDiff(BookingDto $bookingDto): void - { - foreach ($bookingDto->participants as $index => $participant) { - $participantData = [ - 'firstName' => $participant->firstName, - 'lastName' => $participant->lastName, - 'dateOfBirth' => $participant->dateOfBirth?->format('Y-m-d'), - 'email' => $participant->email, - 'mobile' => $participant->mobile, - 'gender' => $participant->gender, - 'nationality' => $participant->nationality, - 'address' => [ - 'street' => $participant->address?->street, - 'postCode' => $participant->address?->postCode, - 'city' => $participant->address?->city, - 'country' => $participant->address?->country, - ], - 'services' => [ - 'skiPass' => $participant->skiPass?->id, - 'courses' => $this->normalizeServiceArray($participant->courses), - 'board' => $this->normalizeServiceArray($participant->board), - 'rentals' => $this->normalizeServiceArray($participant->rentals), - 'rentalInsurance' => $participant->rentalInsurance?->id, - 'additionalServices' => $this->normalizeServiceArray($participant->additionalServices), - 'transportationOutbound' => $participant->transportationOutbound?->id, - 'transportationInbound' => $participant->transportationInbound?->id, - 'pickup' => $participant->pickup?->id, - 'parking' => $participant->parking, - ], - ]; - - error_log(sprintf('[Fingerprint] Participant %d data: %s', $index, json_encode($participantData))); - } - } } diff --git a/src/Service/InsuranceMatchingService.php b/src/Service/InsuranceMatchingService.php index 61d904d..c9a7d7f 100644 --- a/src/Service/InsuranceMatchingService.php +++ b/src/Service/InsuranceMatchingService.php @@ -321,28 +321,8 @@ class InsuranceMatchingService */ private function calculateTravelPrice(BookingDto $booking, int $participantIndex): float { - $participant = $booking->getParticipant($participantIndex); - - // Debug logging to understand price calculation - if (null !== $participant && null !== $participant->insurance) { - error_log(sprintf( - '[InsuranceMatching] Participant %d: calculating travel price WITH insurance=%d (€%.2f) currently selected', - $participantIndex, - $participant->insurance->id, - $participant->insurance->price ?? 0.0 - )); - } - // Use the price calculator to get the participant's individual price excluding insurance - $travelPrice = $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($booking, $participantIndex); - - error_log(sprintf( - '[InsuranceMatching] Participant %d: calculated travel price (excluding insurance) = €%.2f', - $participantIndex, - $travelPrice - )); - - return $travelPrice; + return $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($booking, $participantIndex); } /**