[Koha-bugs] [Bug 24965] New: Koha::Object->to_api should handle undef counts

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Mar 24 13:21:05 CET 2020


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

            Bug ID: 24965
           Summary: Koha::Object->to_api should handle undef counts
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: tomascohen at gmail.com
        QA Contact: testopia at bugs.koha-community.org

If to_api is requested to embed the count on a relation that might be undef
(for example, if the relation is not just a FK on another table but linking
table:

sub current_item_level_holds {
    my ($self) = @_;

    my $items_rs     = $self->_result->aqorders_items;
    my @item_numbers = $items_rs->get_column('itemnumber')->all;

    return unless @item_numbers;

    my $biblio = $self->biblio;
    return unless $biblio;

    return $biblio->current_holds->search(
        {
            itemnumber => {
                -in => \@item_numbers
            }
        }
    );
}

it is possible to get exceptions for calling ->count on an undefined object. We
should catch this situation and return zero.

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


More information about the Koha-bugs mailing list