Bug 30386

Summary: Prevent search errors if deleted record still remains in search indexes
Product: Koha Reporter: Kyle M Hall <kyle>
Component: Architecture, internals, and plumbingAssignee: Kyle M Hall <kyle>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: nick, wizzyrea
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 30386: Prevent search errors if deleted record still remains in search indexes

Description Kyle M Hall 2022-03-28 14:57:51 UTC
If a bib is deleted, but for some reason doesn't get deleted from the search indexes, any search where that record is a result will produce the error:

Can't call method "items" on an undefined value at /usr/share/koha/lib/C4/Search.pm line 2064.
Comment 1 Kyle M Hall 2022-03-28 15:10:35 UTC
Created attachment 132349 [details] [review]
Bug 30386: Prevent search errors if deleted record still remains in search indexes

If a bib is deleted, but for some reason doesn't get deleted from the search indexes, any search where that record is a result will produce the error:

Can't call method "items" on an undefined value at /usr/share/koha/lib/C4/Search.pm line 2064.

Test Plan:
1) Enable item-level_itypes
2) Create 3 records in Koha that share a word
3) Search for that word, note your 3+ results
4) Delete one of those recordst from the database using koha-mysql
5) Search for the word again
6) Note the error!
7) Apply this patch
8) Search for the word again
9) Note you get results!
Comment 2 Owen Leonard 2022-04-04 11:30:38 UTC
I could not reproduce this error. I also tried this test plan:

1) Enable item-level_itypes
2) Create 3 records in Koha that share a word
3) Ran koha-rebuild-zebra
4) Search for that word, note your 3+ results
5) Ran koha-indexer --stop kohadev
6) delete from biblio where biblionumber = XXX;
7) Searched again, deleted record still returned along with the others.
Comment 3 Liz Rea 2022-04-07 13:30:39 UTC
This is for elastic search, I believe, not zebra.

Cheers,
Liz
Comment 4 Nick Clemens 2022-05-12 19:29:37 UTC

*** This bug has been marked as a duplicate of bug 29374 ***