From 5f5e87269329ce70a4a31c9914c88df761bae611 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 Content-Type: text/plain; charset=utf-8 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 --- C4/Letters.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index f515fa0..5932a03 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"; -- 2.1.4