[Bug 43879] New: AddReturn does not reindex the record when a withdrawn item blocks the return after clearing onloan
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43879 Bug ID: 43879 Summary: AddReturn does not reindex the record when a withdrawn item blocks the return after clearing onloan Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: minor Priority: P5 - low Component: Circulation Assignee: koha-bugs@lists.koha-community.org Reporter: adolfo.rodriguez@xercode.es QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle@bywatersolutions.com Target Milestone: --- In AddReturn, if the item is not checked out but has items.onloan set (inconsistent data), onloan is cleared with skip_record_index, as the record is reindexed at the end of the function. But if the item is withdrawn and BlockReturnOfWithdrawnItems blocks the return, AddReturn returns early, before reaching that reindex. The database no longer has onloan, but the search index still has it, so the search results keep showing the item as checked out. With RecordLocalUseOnReturn enabled the record happens to be reindexed, because the localuse store does not skip the indexing. Without it, nothing is reindexed. The Wrongbranch early return a few lines below already reindexes the record before returning. To reproduce: 1. Enable BlockReturnOfWithdrawnItems and disable RecordLocalUseOnReturn. 2. Take an item that is not checked out, set it as withdrawn and set items.onloan (e.g. UPDATE items SET onloan = CURDATE() WHERE itemnumber = X), and reindex its record. 3. Search the catalog: the item is shown as checked out. 4. Check the item in. The return is blocked (item withdrawn). 5. items.onloan is now NULL, but the search results still show the item as checked out. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43879 Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43879 --- Comment #1 from Adolfo Rodríguez Taboada <adolfo.rodriguez@xercode.es> --- Created attachment 208639 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208639&action=edit Bug 43879: Reindex the record when a withdrawn item blocks the return If the item is not checked out but has items.onloan set, AddReturn clears onloan with skip_record_index, as the record is reindexed at the end of the function. When the item is withdrawn and BlockReturnOfWithdrawnItems blocks the return, AddReturn returned early, before that reindex, so the search results kept showing the item as checked out. This patch reindexes the record before that early return when onloan has been cleared, the same way the Wrongbranch early return already does. When RecordLocalUseOnReturn is enabled, the localuse store already reindexes the record, so it is not reindexed a second time. Steps to follow: 1. Make sure the search index is updated automatically (koha-es-indexer running, or the Zebra daemon). 2. Enable BlockReturnOfWithdrawnItems and disable RecordLocalUseOnReturn. 3. Take an item that is not checked out, set it as withdrawn and set items.onloan, for example: UPDATE items SET withdrawn = 1, onloan = CURDATE() WHERE itemnumber = X; and reindex its record: misc/search_tools/rebuild_elasticsearch.pl -b --bnumber <biblionumber> 4. Search the catalog: the item is shown as checked out. 5. Check the item in: the return is blocked (item withdrawn). items.onloan is now NULL, but the search results still show the item as checked out. 6. Apply the patch and restart Plack if running under it. 7. Repeat steps 3 to 5. Now the search results no longer show the item as checked out, only as withdrawn. 8. Enable RecordLocalUseOnReturn and repeat steps 3 to 5: local use is recorded and the record is reindexed (only once). 9. prove t/db_dependent/Circulation.t Signed-off-by: Adolfo Rodríguez <adolfo.rodriguez@xercode.es> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43879 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com Assignee|koha-bugs@lists.koha-commun |adolfo.rodriguez@xercode.es |ity.org | --- Comment #2 from David Nind <david@davidnind.com> --- Added assignee 8-). The patch doesn't seem to fix the issue for me - it is still shown as "1 checked out:", and the tests fail. Testing notes (using KTD): 1. Start up KTD with Elasticsearch: ktd --search-engine es8 up 2. The settings for step 2 are the defaults with KTD: - BlockReturnOfWithdrawnItems = is already set to "Block" - RecordLocalUseOnReturn = is already set to "Don't record" 3. Records and items used: - Before patch: Programming Perl (262), item 578 (barcode 39999000011418) - After the patch: Perl Better Practices (191), item 409 (barcode 39999000008036) - Step 8: Programming the Perl DBI (13), item 35 (barcode 39999000000559) 4. Step 7: records in results still show as "1 checked out:". After I applied the patch, I also tried: - A full reindex: koha-elasticsearch --rebuild -d -b -a kohadev - I restarted everything: restart_all 5. The tests fail for me. 6. I didn't try with Zebra. Test failures: prove t/db_dependent/Circulation.t t/db_dependent/Circulation.t .. 18/79 # Transfer limit: Holding -> Return # Transfer limit: Return -> Home # Transfer limit: Return -> Holding t/db_dependent/Circulation.t .. 66/79 # Failed test 'AddReturn reports the Wrongbranch blocker with the item's homebranch as the right branch' # at t/db_dependent/Circulation.t line 8220. # Structures begin differing at: # $got->[1]{LocalUse} = '1' # $expected->[1]{LocalUse} = Does not exist # Looks like you failed 1 test of 1. # Failed test 'Tests for Wrongbranch blocker (AllowReturnToBranch)' # at t/db_dependent/Circulation.t line 8236. # Failed test 'Item is reported to have been transferred' # at t/db_dependent/Circulation.t line 8258. # Structures begin differing at: # $got->[1]{LocalUse} = '1' # $expected->[1]{LocalUse} = Does not exist # Looks like you failed 1 test of 2. # Failed test 'Tests for transfer not in transit' # at t/db_dependent/Circulation.t line 8274. t/db_dependent/Circulation.t .. 78/79 # Looks like you failed 2 tests of 79. t/db_dependent/Circulation.t .. Dubious, test returned 2 (wstat 512, 0x200) Failed 2/79 subtests Test Summary Report ------------------- t/db_dependent/Circulation.t (Wstat: 512 (exited 2) Tests: 79 Failed: 2) Failed tests: 68-69 Non-zero exit status: 2 Files=1, Tests=79, 57 wallclock secs ( 0.12 usr 0.01 sys + 40.38 cusr 8.72 csys = 49.23 CPU) Result: FAIL -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43879 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #3 from David Nind <david@davidnind.com> --- Changed status to Failed QA, as the tests fail. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org