From c5460b1239202726a600e526f7ddea94ede1de57 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. --- C4/Letters.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index b8aab42..0a0760f 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1575,9 +1575,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); @@ -1587,7 +1587,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