[Koha-bugs] [Bug 19809] Koha::Objects::find calls do not need to be forbidden in list context

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Nov 5 16:42:11 CET 2019


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

--- Comment #14 from Julian Maurice <julian.maurice at biblibre.com> ---
(In reply to Marcel de Rooy from comment #13)
> Hi Julian,
> This might have been a bit overcautious, you are right.
> But looking at the code, I still see some problems:
> 
> +    @pars = grep { defined } @pars;
> This is not the same as the earlier check:
> -    return if !@pars || none { defined($_) } @pars;
> Btw note that this statement would return an empty list (with the croak
> removed).

Yes, but the croak is there, so if we reach this line it means we're in scalar
context, so it would return undef.
Also, I am failing to see what the differences are between the two checks. In
both cases, if @pars is empty or contain only undefined values, the rest of the
subroutine is not executed. Can you give a value of @pars for which the
behavior differ ?

> 
>      return $object;
> This is no longer good. Since you are returning 'undef' here literally while
> you want to return empty list if it is list context.

I do not want to return an empty list. I want Koha::Objects::find to behave
like DBIx::Class::ResultSet::find, which returns undef if no results were found
(even if in list context)

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


More information about the Koha-bugs mailing list