[Koha-bugs] [Bug 22407] OMNIBUS: Use DBIC relations to fetch related object rather than searching for the object

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jul 10 01:57:54 CEST 2020


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

--- Comment #15 from David Cook <dcook at prosentient.com.au> ---
(In reply to Julian Maurice from comment #14)
> What is there to check in this particular situation ? _new_from_dbic either
> dies or return a blessed object. If it dies then Koha::Patron::guarantor
> should die too, if it returns a blessed object, then there is nothing to
> check.

That's an interesting perspective. 

If it dies, it's probably going to bring down that entire Plack worker. That
seems problematic to me. We could try to trap the error in the caller, but in
practice that is rare in Koha. That being said, even if it doesn't die, we need
to handle a non-fatal exception too. Maybe it is better to die in the grand
scheme of things, as it'll more easily show code bugs and bad data.

If it doesn't die, what happens if you want to add a check to that object?
Maybe you only want to return the guarantor under certain conditions. It
probably makes sense to add that check here rather than in every caller of this
method. To do that, you'd have to refactor to use the syntax I described
anyway. Or maybe you're doing some debugging because the guarantor being
returned isn't correct. You can't add any logging in this code unless you
refactor to the syntax I described.

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


More information about the Koha-bugs mailing list