Bug 9966

Summary: Incorrect 404 when a search returns one result hidden by OpacHiddenItems
Product: Koha Reporter: Ed Veal <eveal>
Component: SearchingAssignee: Olli-Antti Kivilahti <olli-antti.kivilahti>
Status: Failed QA --- QA Contact:
Severity: minor    
Priority: P5 - low CC: james.elian, katrin.fischer, marjorie.barry-vila, mathsabypro, olli-antti.kivilahti, pablo.bianchi, veron
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 9966 - Incorrect 404 when a search returns one result hidden by OpacHiddenItems

Description Ed Veal 2013-04-01 19:57:16 UTC
If you set up the OpacHiddenItems syspref to hide based on homebranch and then do a "Title Phrase" search for a title that on the hidden branch owns you get a 404 error rather than the "No Item found" message.
Comment 1 Owen Leonard 2013-04-02 16:05:56 UTC
I don't think this is related to the type of search, I think it has to do with the fact that the search is returning only one record. Normally a search with one result redirects to the detail page for that result. It sounds like the fact that the result is hidden by OpacHiddenItems makes it behave as if the record doesn't exist.
Comment 2 Ed Veal 2013-04-02 16:11:46 UTC
Owen,

I agree but that was the best example I could use to get the error to show. You are correct it is not the search that is at issue it is the fact that it is trying to display something that is hidden. 

Ed
Comment 3 james.elian 2015-05-28 13:43:35 UTC
I resolved a similar situation by re-indexing (koha-rebuild-zebra on my Ubuntu system). Before, the hidden item type was still appearing on search results, and clicking the link to the item would result in a 404 error. After, the item type was correctly hidden from all search results.
Comment 4 Katrin Fischer 2015-05-31 12:41:48 UTC
I think 2 different problems here:
- when there is only one result of the search, that is hidden due to opachiddenitems, then the 404 displays. Maybe we should implement something like  OpacSuppressionRedirect and OpacSuppressionMessage for opachiddenitems?

- The item information in the result list is coming from the Zebra index, so this might be the reason a reindex was necessary to make it work - maybe the item was not indexed yet before?
Comment 5 Olli-Antti Kivilahti 2015-07-27 10:00:04 UTC
Created attachment 41194 [details] [review]
Bug 9966 - Incorrect 404 when a search returns one result hidden by OpacHiddenItems

This patch disables throwing the 404-error. We should be able to show the
opac-detail.pl regardless of hidden items or not.
This doesn't fix the availability on opac-search.pl,
but gets us out of a very awkward predicatement.

TEST PLAN:

1. You can now access opac-detail.pl for Biblios whose ALL Items are hidden by the
   'OpacHiddenItems'-syspref.
Comment 6 Olli-Antti Kivilahti 2015-07-27 10:01:09 UTC
s'il vous plaƮt.
Comment 7 Katrin Fischer 2015-07-27 10:06:51 UTC
If I understand you correctly this will make the record visible, even if all items are hidden. I think this breaks a feature/user expectation. A lot of libraries use the fact the record is hidden with the last item to their advantage and the feature has been explicitly build to function this way from the beginning.

This fix is too simple - it needs to be optional.
Comment 8 Olli-Antti Kivilahti 2015-07-27 11:02:40 UTC
(In reply to Katrin Fischer from comment #7)
> If I understand you correctly this will make the record visible, even if all
> items are hidden. I think this breaks a feature/user expectation. A lot of
> libraries use the fact the record is hidden with the last item to their
> advantage and the feature has been explicitly build to function this way
> from the beginning.
> 
> This fix is too simple - it needs to be optional.

The hidden items should not be displayed in OPAC regardless of this fix.
The way I tested we get the opac-detail.pl with no Items to display because they were all correctly hidden by the "OpacHiddenItems"-syspref.

If this fix is too simple, you can freely wait for a more complete solution. For the time being we are affected by this bug and it causes bad experiences for OPAC users. This patch fixes the biggest issue with the lowest effort.
Comment 9 Olli-Antti Kivilahti 2015-07-27 11:04:26 UTC
Put status back to "Needs Signoff", because QA misunderstood the patch effects and no test results were available to discredit the intended behaviour.
Comment 10 Olli-Antti Kivilahti 2015-07-27 11:04:47 UTC
Failed QA because of missing tests ;)
Comment 11 Katrin Fischer 2015-07-27 11:40:13 UTC
The point is you are deleting code that is there on purpose - the bibliographic details/record shouldn't show when all items are hidden.
Comment 12 Olli-Antti Kivilahti 2015-07-27 11:42:20 UTC
(In reply to Katrin Fischer from comment #11)
> The point is you are deleting code that is there on purpose - the
> bibliographic details/record shouldn't show when all items are hidden.

Sorry, I read Item when you wrote Record.
Comment 13 Pablo AB 2022-09-16 18:08:06 UTC
(In reply to Katrin Fischer from comment #11)
> The point is you are deleting code that is there on purpose - the
> bibliographic details/record shouldn't show when all items are hidden.

This behavior should be optional with a syspref. Some libraries want the bibliographic info still be visible even if all items are hidden (similar as with biblios without items).

Moreover, those bib records are exposed over OAI-PMH, so from a union catalog (where those records are visible) users go directly to a 404.
Comment 14 Katrin Fischer 2022-09-19 21:00:50 UTC
(In reply to Pablo AB from comment #13)
> (In reply to Katrin Fischer from comment #11)
> > The point is you are deleting code that is there on purpose - the
> > bibliographic details/record shouldn't show when all items are hidden.
> 
> This behavior should be optional with a syspref. Some libraries want the
> bibliographic info still be visible even if all items are hidden (similar as
> with biblios without items).
> 
> Moreover, those bib records are exposed over OAI-PMH, so from a union
> catalog (where those records are visible) users go directly to a 404.

It is optional: OpacHiddenItemsHidesRecord