Bug 16056

Summary: Error when deleting MARC authority
Product: Koha Reporter: Owen Leonard <oleonard>
Component: MARC Authority data supportAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: brendan, jonathan.druart, julian.maurice, tomascohen
Version: master   
Hardware: All   
OS: All   
URL: /cgi-bin/koha/authorities/authorities-home.pl
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 15381    
Bug Blocks:    
Attachments: Bug 16056: Do not crash when searching for an authority if zebra's index is not up-to-date
Bug 16056: [ALT] Do not crash when searching for an authority if zebra's index is not up-to-date
[SIGNED-OFF] Bug 16056: [ALT] Do not crash when searching for an authority if zebra's index is not up-to-date
Bug 16056: Do not crash when searching for an authority if zebra's index is not up-to-date

Description Owen Leonard 2016-03-11 19:03:45 UTC
When I try to delete a MARC authority record from the authority search results list (Authorities -> Search) I get an error.

Can't call method "authtypecode" on an undefined value at C4/AuthoritiesMarc.pm line 305.

I think the authority is being deleted correctly but the out-of-date index is triggering an error, because reloading the search results page triggers the error again. Reindexing makes it go away.

I'm guessing this is related to Bug 15380 or Bug 15381.
Comment 1 Jonathan Druart 2016-03-21 15:35:16 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2016-03-21 15:38:47 UTC Comment hidden (obsolete)
Comment 3 Owen Leonard 2016-03-23 12:53:05 UTC Comment hidden (obsolete)
Comment 4 Tomás Cohen Arazi 2016-03-23 14:50:18 UTC
I think the right behaviour would be that Koha raises an error when trying to delete a record it is not on the DB.

Hey, what would happen if we filter non-existent indexed records out, and then someone deletes "another" record in the meantime?

The best approach is to make Koha handle this situations elegantly, instead of adding more and more latency to search results rendering.

I vote for: render the deleted record, using Zebra's data as usual. Then show an error box if the user tries to delete it.
Comment 5 Jonathan Druart 2016-03-23 16:14:05 UTC
Tomas, this patch fixes a a major regression, I don't think we should have this discussion here :) Let's go with the first patch if you think the second one is not good enough.
Comment 6 Owen Leonard 2016-03-23 16:51:30 UTC
The first patch eliminates the error but from the point of view of the user it appears as if the deletion never happened.
Comment 7 Jonathan Druart 2016-03-23 17:15:40 UTC
(In reply to Owen Leonard from comment #6)
> The first patch eliminates the error but from the point of view of the user
> it appears as if the deletion never happened.

Yes, that was I have attached the second patch. But it was the behavior before 15381 (and I guess it has already been like that).
Comment 8 Jonathan Druart 2016-03-29 07:54:06 UTC
Removing the in discussion status to get other opinions. Pick the patch you want, but pick one :)
Comment 9 Tomás Cohen Arazi 2016-04-01 18:01:52 UTC
Created attachment 49810 [details] [review]
Bug 16056: Do not crash when searching for an authority if zebra's index is not up-to-date

This patch fixes a regression introduced by
commit 7e70202d34d75f988fbaea9b911347417c203aac
  Bug 15381: Remove GetAuthType and GetAuthTypeCode

This first version will reintroduce the same behavior as before bug
15381: the record will be displayed even if it's no in the DB

Test plan:
Search for authorities
delete one
The zebra's index is not updated yet and the results will contain the
record you have deleted.

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Comment 10 Brendan Gallagher 2016-04-01 19:05:25 UTC
Pushed to Master - Should be in the May 2016 release.  Thanks!
Comment 11 Julian Maurice 2016-04-06 13:07:47 UTC
Not needed in stable versions, status changed to RESOLVED