From 5f3e93c6f5cd7818f53296cf9c4a37c860119970 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 23 Mar 2017 22:13:17 -0300 Subject: [PATCH] Bug 17964: Replace next with last We certainly always want to retrieve the last row of a given search. If it not sufficient we will need to rethink this code. Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Letters.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index f515fa09e3..5932a03867 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1589,9 +1589,9 @@ sub _get_tt_params { foreach my $key ( @$fk ) { $search->{$key} = $id->{$key}; } - $object = $module->search( $search )->next(); + $object = $module->search( $search )->last(); } else { # Foreign key is single column - $object = $module->search( { $fk => $id } )->next(); + $object = $module->search( { $fk => $id } )->last(); } } else { # using the table's primary key for lookup $object = $module->find($id); @@ -1601,7 +1601,7 @@ sub _get_tt_params { else { # $ref eq 'ARRAY' my $object; if ( @{ $tables->{$table} } == 1 ) { # Param is a single key - $object = $module->search( { $pk => $tables->{$table} } )->next(); + $object = $module->search( { $pk => $tables->{$table} } )->last(); } else { # Params are mutliple foreign keys croak "Multiple foreign keys (table $table) should be passed using an hashref";