Bug 16443

Summary: C4::Members::Statistics is not plack safe
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: abl, chris, f.demians, julian.maurice, kyle, m.de.rooy
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:    
Bug Blocks: 7172    
Attachments: Bug 16443: Make C4::Members::Statistics plack safe
Bug 16443: Make C4::Members::Statistics plack safe
Bug 16443: Make C4::Members::Statistics plack safe
Bug 16443: [QA Follow-up] Add two tests for get_fields

Description Jonathan Druart 2016-05-04 19:08:46 UTC
If the prefs is updated, the fields won't be.
To make sure we already fetch updated values, we should remove the package variable and define it in the subroutine.
Comment 1 Jonathan Druart 2016-05-04 19:09:55 UTC Comment hidden (obsolete)
Comment 2 Chris Cormack 2016-05-09 10:02:58 UTC Comment hidden (obsolete)
Comment 3 Chris Cormack 2016-05-09 10:04:11 UTC
This works, I haven't tested if there is a performance hit, but even if there was we need to make the change anyway. But if there is, we may want to put some caching in get_fields
Comment 4 Marcel de Rooy 2016-06-04 13:18:24 UTC
(In reply to Chris Cormack from comment #3)
> This works, I haven't tested if there is a performance hit, but even if
> there was we need to make the change anyway. But if there is, we may want to
> put some caching in get_fields

Yes it is definitely slower. (You could speed up somewhat by returning to dbh, but we chose for DBIx..)
Could we cache the item columns here instead of fetching them every time?
get_fields needs the item columns and the pref.
Comment 5 Marcel de Rooy 2016-06-10 10:04:30 UTC
(In reply to Marcel de Rooy from comment #4)
> (In reply to Chris Cormack from comment #3)
> > This works, I haven't tested if there is a performance hit, but even if
> > there was we need to make the change anyway. But if there is, we may want to
> > put some caching in get_fields
> 
> Yes it is definitely slower. (You could speed up somewhat by returning to
> dbh, but we chose for DBIx..)
> Could we cache the item columns here instead of fetching them every time?
> get_fields needs the item columns and the pref.

Hm. Actually not too bad after all..
Comment 6 Marcel de Rooy 2016-06-10 10:05:51 UTC
Created attachment 52219 [details] [review]
Bug 16443: Make C4::Members::Statistics plack safe

If the prefs is updated, the fields won't be.
To make sure we already fetch updated values, we should remove the
package variable and define it in the subroutine.

There is not test plan, just make sure the changes are consistent.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Marcel de Rooy 2016-06-10 10:05:55 UTC
Created attachment 52220 [details] [review]
Bug 16443: [QA Follow-up] Add two tests for get_fields

Adds t/db_dependent/Members/Statistics.t.

Test plan:
Run the test.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Kyle M Hall 2016-06-10 16:37:10 UTC
Pushed to master for Koha 16.11, thanks Jonathan, Marcel!
Comment 9 Frédéric Demians 2016-06-15 07:40:26 UTC
Pushed in 16.05. Will be in 16.05.01.
Comment 10 Julian Maurice 2016-06-16 08:32:18 UTC
Patches pushed to 3.22.x, will be in 3.22.8