Bug 27970

Summary: Koha::Template::Plugin::Branches->pickup_location is failing due to unexpected behavior of Koha::Libraries->new->empty
Product: Koha Reporter: Andreas Jonsson <andreas.jonsson>
Component: CirculationAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: gmcharlt, kyle.m.hall, tomascohen
Version: 20.05   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:

Description Andreas Jonsson 2021-03-17 08:33:07 UTC
This test-script:

#!/usr/bin/perl -w 
#
use strict;

use Koha::Libraries;
use Data::Dumper;

my @empty = map {$_->unblessed} Koha::Libraries->new->empty;

print Dumper(\@empty);


yields this output:

$VAR1 = [
          []
        ];

In other words, we get an array with a reference to an empty array.  This is unexpected in two different ways:

* The array should contain hash references (whenever it contains anything).
* The array should be empty.

The problem is that this will cause Template::Plugin::Branches->pickup_location to crash in some circumstances.

A workaround is to add something like this to the loop:

            next if is_arrayref($l);

I'm guessing the actual error is in DBIx.
Comment 1 Tomás Cohen Arazi 2022-01-06 11:49:27 UTC

*** This bug has been marked as a duplicate of bug 29807 ***
Comment 2 Tomás Cohen Arazi 2022-01-06 11:51:18 UTC
Thanks for the report, Andreas, I'm sorry I didn't notice it earlier. Working on a fix based on your findings, on bug 29807.