From ca3cd1580fc9de619abbcfde69a1fd117b2d0533 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 14 Jul 2023 18:48:46 +0200 Subject: [PATCH] Journeys->get_latest: Fix uninitialized value warning --- lib/Travelynx/Model/Journeys.pm | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/Travelynx/Model/Journeys.pm b/lib/Travelynx/Model/Journeys.pm index a811a7c..a4fe12c 100755 --- a/lib/Travelynx/Model/Journeys.pm +++ b/lib/Travelynx/Model/Journeys.pm @@ -709,12 +709,14 @@ sub get_latest { } )->expand->hash; - $latest_successful->{visibility_str} - = $latest_successful->{visibility} - ? $visibility_itoa{ $latest_successful->{visibility} } - : 'default'; - $latest_successful->{effective_visibility_str} - = $visibility_itoa{ $latest_successful->{effective_visibility} }; + if ($latest_successful) { + $latest_successful->{visibility_str} + = $latest_successful->{visibility} + ? $visibility_itoa{ $latest_successful->{visibility} } + : 'default'; + $latest_successful->{effective_visibility_str} + = $visibility_itoa{ $latest_successful->{effective_visibility} }; + } my $latest = $db->select( 'journeys_str', @@ -728,12 +730,14 @@ sub get_latest { } )->expand->hash; - $latest->{visibility_str} - = $latest->{visibility} - ? $visibility_itoa{ $latest->{visibility} } - : 'default'; - $latest->{effective_visibility_str} - = $visibility_itoa{ $latest->{effective_visibility} }; + if ($latest) { + $latest->{visibility_str} + = $latest->{visibility} + ? $visibility_itoa{ $latest->{visibility} } + : 'default'; + $latest->{effective_visibility_str} + = $visibility_itoa{ $latest->{effective_visibility} }; + } return ( $latest_successful, $latest ); }