PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | app/Validators/TripValidator.php +14 -7 3.0.14.2 → 3.0.16 View file →
@@ -525,17 +525,24 @@
525 525 }
526 526
527 527 // Hour-based duration only applies to single-day tours. Clamp to a sane
528 528 // day-length range, and never let a multi-day / flexible trip carry
529 - // hours — otherwise the Google Calendar module would build a short timed
530 - // event instead of the correct multi-day span. Only enforced when both
531 - // fields are present in the payload (the trip form always sends both).
529 + // hours — otherwise the front end would show "8 hours" for a multi-day
530 + // trip and the Google Calendar module would build a short timed event
531 + // instead of the correct multi-day span.
532 + //
533 + // `trip_type` settles it when the payload carries it (the trip form
534 + // always sends both). A partial update that omits `trip_type` is caught
535 + // by the duration_days fallback below, so hours can never be stored
536 + // against a multi-day span.
532 537 if (array_key_exists('duration_hours', $sanitized)) {
533 538 $sanitized['duration_hours'] = max(0, min(24, (int) $sanitized['duration_hours']));
534 - if (
535 - array_key_exists('trip_type', $sanitized)
536 - && $sanitized['trip_type'] !== 'single_day'
537 - ) {
539 + $isMultiDayType = array_key_exists('trip_type', $sanitized)
540 + && $sanitized['trip_type'] !== 'single_day';
541 + $isMultiDaySpan = array_key_exists('duration_days', $sanitized)
542 + && (int) $sanitized['duration_days'] > 1;
543 +
544 + if ($isMultiDayType || $isMultiDaySpan) {
538 545 $sanitized['duration_hours'] = 0;
539 546 }
540 547 }
541 548