Bug 5415

Summary: Simplify Returns from SimpleSearch
Product: Koha Reporter: Colin Campbell <colin.campbell>
Component: SearchingAssignee: Christophe Croullebois <christophe.croullebois>
Status: CLOSED FIXED QA Contact: Bugs List <koha-bugs>
Severity: enhancement    
Priority: PATCH-Sent (DO NOT USE) CC: chris, christophe.croullebois
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Proposed Patch
Proposed Patch 2
Proposed Patch 3

Description Colin Campbell 2010-11-17 10:50:15 UTC
SimpleSearch routine returns an array of three values an errorstring, a reference to an array of records and a scalar number of hits.

If an error is returned the array_ref and hit_count are undefined

If there is no error returned the errorstring is undefined. but the other elements maybe defined or undefined.

As a result it exports complexity into the calling interface which typically has to test is there an error then for each return element test definedness then assign it etc. leading to code hard to read, maintain and sometimes get right. People do seem to have a problems resulting from the implied "randomness" of the return.

Proposal that the variables used in non-error returns are initialized so that they are only undefined in in error returns. Current code should still work as is (otherwise its a bit buggy already!) Will mean that only error needs checking if not defined hit_count is a scalar >= 0 and array_ref is a ref to a (possibly empty) array.

Calls to SimpleSearch can then simplified accordingly
Comment 1 Colin Campbell 2010-11-17 14:26:04 UTC
Created attachment 2767 [details] [review]
Proposed Patch
Comment 2 Colin Campbell 2010-11-17 14:27:13 UTC Comment hidden (obsolete)
Comment 3 MJ Ray (software.coop) 2010-12-13 12:16:34 UTC
This bug is mentioned in:
Bug 5415 More consistent returns from	SimpleSearch http://lists.koha-community.org/pipermail/koha-patches/2010-November/013053.html
Bug 5415 Let calls of SimpleSearch	utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013054.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013061.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013062.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013063.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013071.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013072.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013074.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013073.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013075.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013064.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013067.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013068.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013069.html
Bug 5415 Let calls of SimpleSearch utilize considtent interface http://lists.koha-community.org/pipermail/koha-patches/2010-November/013070.html
Comment 4 Christophe Croullebois 2011-04-04 15:58:20 UTC
Created attachment 3646 [details] [review]
Proposed Patch 3

This patch replace the Proposed Patch 2.
Comment 5 Chris Cormack 2011-04-08 01:55:15 UTC
pushed please test
Comment 6 Jared Camins-Esakov 2012-12-31 00:30:39 UTC
There have been no further reports of problems so I am marking this bug resolved.