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
Created attachment 2767 [details] [review] Proposed Patch
Created attachment 2768 [details] [review] Proposed Patch 2
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
Created attachment 3646 [details] [review] Proposed Patch 3 This patch replace the Proposed Patch 2.
pushed please test
There have been no further reports of problems so I am marking this bug resolved.