chore: remove debug statements

This commit is contained in:
Björn Fromme
2025-10-16 09:35:12 +02:00
parent 8225d4e92d
commit e76170b6dd
6 changed files with 5 additions and 113 deletions
@@ -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);
@@ -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;
}
/**
@@ -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);
}
/**
@@ -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));
}
}
+2 -53
View File
@@ -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)));
}
}
}
+1 -21
View File
@@ -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);
}
/**