Bug 5415 - Simplify Returns from SimpleSearch
Summary: Simplify Returns from SimpleSearch
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: PATCH-Sent (DO NOT USE) enhancement (vote)
Assignee: Christophe Croullebois
QA Contact: Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-17 10:50 UTC by Colin Campbell
Modified: 2013-12-05 20:05 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Text to go in the release notes:
Version(s) released in:


Attachments
Proposed Patch (5.97 KB, patch)
2010-11-17 14:26 UTC, Colin Campbell
Details | Diff | Splinter Review
Proposed Patch 2 (11.67 KB, patch)
2010-11-17 14:27 UTC, Colin Campbell
Details | Diff | Splinter Review
Proposed Patch 3 (10.85 KB, patch)
2011-04-04 15:58 UTC, Christophe Croullebois
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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.