Bug 17118

Summary: Regression: Bug 15381 triggers error when trying to clear a linked authority
Product: Koha Reporter: Owen Leonard <oleonard>
Component: MARC Authority data supportAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: f.demians, jonathan.druart, kyle
Version: Main   
Hardware: All   
OS: All   
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 17118: (follow-up 15381) Fix regression when clearing a linked authority
[SIGNED-OFF] Bug 17118: (follow-up 15381) Fix regression when clearing a linked authority
[PASSED QA] Bug 17118: (follow-up 15381) Fix regression when clearing a linked authority

Description Owen Leonard 2016-08-12 16:28:28 UTC
To reproduce:

1. Edit a record which has a field linked to an 
   authority record (100a for instance).
2. Click the link which triggers the tag editor.
   A pop-up window should be displayed.
3. In the pop-up window, click the "Clear field"
   button.
4. A second pop-up window opens and displays an error:

Can't call method "authtypecode" on an undefined value at /authorities/blinddetail-biblio-search.pl line 61.
Comment 1 Jonathan Druart 2016-08-19 15:15:22 UTC Comment hidden (obsolete)
Comment 2 Aleisha Amohia 2016-08-22 04:36:23 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2016-08-28 19:20:29 UTC
Created attachment 54956 [details] [review]
[PASSED QA] Bug 17118: (follow-up 15381) Fix regression when clearing a linked authority

Changes made on bug 15381 assumed that the authid was always set.
But if the user wants to clear the field of the authority, the script is
called with authid=0 (FIXME...)

To fix this issue, it's better to move the new calls to
  Koha::Authorities->find($authid)->authtypecode
and
  Koha::Authority::Types->find($authtypecode);
at the correct place

Test plan:
1. Edit a record which has a field linked to an
   authority record (100a for instance).
2. Click the link which triggers the tag editor.
   A pop-up window should be displayed.
3. In the pop-up window, click the "Clear field"
   button.
=> Without this patch A second pop-up window opens and displays an error:
  Can't call method "authtypecode" on an undefined value at /authorities/blinddetail-biblio-search.pl line 61.
=> With this patch applied the field is correctly cleared.

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>
Comment 4 Kyle M Hall 2016-09-02 15:01:40 UTC
Pushed to master for 16.11, thanks Jonathan!
Comment 5 Frédéric Demians 2016-09-08 19:35:02 UTC
Pushed in 16.05. Will be in 16.05.04.