Bug 16955

Summary: Internal Server Error while populating new framework
Product: Koha Reporter: Marc Véron <veron>
Component: Staff interfaceAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: f.demians, gmcharlt, jonathan.druart, josef.moravec, julian.maurice, kyle, mtj
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16987
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 11842    
Bug Blocks: 17009    
Attachments: Bug 16955: Internal Server Error while populating new framework
Bug 16955: Internal Server Error while populating new framework
Bug 16955: Do not clear from cache when adding a new framework
Bug 16955: Do not clear from cache when adding a new framework
Bug 16955: Do not clear from cache when adding a new framework

Description Marc Véron 2016-07-21 16:32:36 UTC
While populating a new framework, an internal server error occurs.

It happens on an installation with Plack.

Steps to reproduce:

- Go to  Home > Administration > MARC frameworks 
- Add framework e.g. TEST, submit
- In List of frameworks, go to framework TEST, Actions, 
  MARC Structure
- Create framework for... : Select DEFAULT 
Result: Internal Server Error (rest of sceen blank)
Comment 1 Marc Véron 2016-07-21 16:35:28 UTC
Lines from plack-error.log:

Variable "$cache" is not available at (...)/admin/marctagstructure.pl line 360.
Variable "$frameworkcode" is not available at /home/marc/koha/admin/marctagstructure.pl line 362.
Variable "$cache" is not available at (...)/admin/marctagstructure.pl line 360.
Variable "$frameworkcode" is not available at (...)a/admin/marctagstructure.pl line 362.
Can't call method "clear_from_cache" on an undefined value at /home/marc/koha/admin/marctagstructure.pl line 360.
Comment 2 Marc Véron 2016-07-21 19:48:02 UTC Comment hidden (obsolete)
Comment 3 Josef Moravec 2016-07-30 08:55:48 UTC
*** Bug 16987 has been marked as a duplicate of this bug. ***
Comment 4 Josef Moravec 2016-07-30 09:01:40 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2016-08-01 12:06:23 UTC
Introduced by bug 11842.
Comment 6 Jonathan Druart 2016-08-01 12:18:54 UTC
There was a wrong c/p here (you can blame me), the last 2 lines are using $frameworkcode instead of $newframeworkcode.
Moreover the 4 clear_from_cache calls are inside the while loop, which means that we are clearing the cache 4 times per subfield (!).
Finally these calls are actually not needed :) As we are creating a new framework, the cache should be empty...
Comment 7 Jonathan Druart 2016-08-01 12:20:15 UTC
(In reply to Jonathan Druart from comment #6)
> Moreover the 4 clear_from_cache calls are inside the while loop, which means
> that we are clearing the cache 4 times per subfield (!).

Ha, it is added by this patch.
Comment 8 Marc Véron 2016-08-01 20:18:48 UTC
Hi Jonathan,

Sorry, I have no time at the mmoment to fix this.

Can you provide an alternative patch?

Thanks
Marc
Comment 9 Jonathan Druart 2016-08-02 08:46:54 UTC Comment hidden (obsolete)
Comment 10 Christopher Brannon 2016-08-06 23:12:20 UTC Comment hidden (obsolete)
Comment 11 Nick Clemens 2016-08-12 16:41:49 UTC
Created attachment 54387 [details] [review]
Bug 16955: Do not clear from cache when adding a new framework

There are several issues with these lines:
1/ $cache is not defined correctly and it not visible inside
duplicate_framework
2/ $frameworkcode is a wrong c/p, it should be $newframeworkcode
3/ these calls are not needed. As we are creating a new framework, the cache
should be empty...

This patch will simply remove these calls

Test plan:
Duplicate a framework and confirm that you do not get any error in your
logs.

Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 12 Kyle M Hall 2016-08-18 15:49:06 UTC
Pushed to master for 16.11, thanks Jonathan!
Comment 13 Frédéric Demians 2016-08-23 10:34:46 UTC
Pushed in 16.05. Will be in 16.05.03.
Comment 14 Julian Maurice 2016-08-24 10:41:54 UTC
Pushed to 3.22.x, will be in 3.22.10