[Koha-bugs] [Bug 28871] Koha::Objects->empty doesn't work correctly in list context

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Nov 3 12:40:35 CET 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28871

--- Comment #19 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
(In reply to Marcel de Rooy from comment #18)
> In other words, please show me a better example where it does not work now
> in list context.

This sub:

sub items_fetch {
    return Koha::Items->search(...);
}

will respect list context and do the appropriate thing i.e.

      my @items = items_fetch();

will perform the DB query, and have @items be assigned a list of Koha::Item
objects.

As ->empty is expected to be returned sometimes, and (why not) chained with
other queries, it needs to behave the same as ->search. This is the ->empty
counterpart of what I raised on bug 28883.

Look at t/db_dependendent/Koha/Biblio.t:419

the addition of ->as_list there, is a consequence of the possibility
Koha::Libraries->new->empty is returned in some scenarios.

So Koha::Biblio->pickup_locations can honour list context sometimes, and
sometimes not. With this patch the programmer can be sure ->pickup_locations
has a predictable behavior and avoid coding for exceptional cases.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list