When a hold was being edited on page 2+ of a patron's list of holds, the
offset was > 0. Since the input hold_ids array ref has only 1 member, using
the offset as a starting point in searching began the search beyond the end
of the array and thus returned nothing.
The code in this commit moves the handling of the offset and limit to cases
where the input hold_ids is undefined, as this is, I think the intended
behavior. Typically when hold_ids is passed to the fetch_user_holds function
in EGCatLoader::Account, you want to retrieve those holds regardless of
the offset and limit values.
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
my $offset = shift;
my $e = $self->editor;
+ my $all_ids; # to be used below.
if(!$hold_ids) {
my $circ = OpenSRF::AppSession->create('open-ils.circ');
$available
)->gather(1);
$circ->kill_me;
- }
- my $all_ids = $hold_ids;
- $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
+ $all_ids = $hold_ids;
+ $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
+
+ } else {
+ $all_ids = $hold_ids;
+ }
return { ids => $hold_ids, all_ids => $all_ids } if $ids_only or @$hold_ids == 0;