Bug 27676

Summary: finesMode=off not correctly handled
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: andrewfh, fridolin.somers, martin.renvoize, victor
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.03,20.05.09,19.11.15
Bug Depends on:    
Bug Blocks: 22824    
Attachments: Bug 27676: Correct finesMode ne off condition
Bug 27676: Correct finesMode ne off condition

Description Jonathan Druart 2021-02-11 10:20:43 UTC
finesMode is 'off' by default (sysprefs.sql), but if you modify its value from the UI and set it to 'production' then back to 'off', the DB value becomes an empty string '', because of $YAML::Syck::ImplicitTyping
Comment 1 Jonathan Druart 2021-02-11 10:25:07 UTC
Created attachment 116700 [details] [review]
Bug 27676: Correct finesMode ne off condition

finesMode is 'off' by default (sysprefs.sql), but if you modify its value from
the UI and set it to 'production' then back to 'off', the DB value becomes an
empty string '', because of $YAML::Syck::ImplicitTyping

This has been found when working on on removing YAML::Syck (bug 22824),
so it's not perfect but the situation will be cleared in the follow-up
bug report.

Test plan:
0. Don't apply the patch
1. reset_all
=> finesMode eq 'off' in DB
2. Set the pref's value to production
3. Switch it back to 'off'
4. Value is '' in DB
5. Check an item in that should generate overdue charges
=> Charges are not generated
6. Apply the patch
7. Check an item in that should generate overdue charges
=> Charges are generated
Comment 2 Martin Renvoize 2021-02-11 13:29:49 UTC
Created attachment 116719 [details] [review]
Bug 27676: Correct finesMode ne off condition

finesMode is 'off' by default (sysprefs.sql), but if you modify its value from
the UI and set it to 'production' then back to 'off', the DB value becomes an
empty string '', because of $YAML::Syck::ImplicitTyping

This has been found when working on on removing YAML::Syck (bug 22824),
so it's not perfect but the situation will be cleared in the follow-up
bug report.

Test plan:
0. Don't apply the patch
1. reset_all
=> finesMode eq 'off' in DB
2. Set the pref's value to production
3. Switch it back to 'off'
4. Value is '' in DB
5. Check an item in that should generate overdue charges
=> Charges are not generated
6. Apply the patch
7. Check an item in that should generate overdue charges
=> Charges are generated

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 3 Martin Renvoize 2021-02-11 13:31:00 UTC
Good catch!

I've checked other occurrences of finesMode and none of them fail in this way.

Simple, trivial, patch that works as expected.

Going straight for QA here.

Passed.
Comment 4 Jonathan Druart 2021-02-12 11:19:04 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 5 Fridolin Somers 2021-02-12 14:55:08 UTC
Pushed to 20.11.x for 20.11.03
Comment 6 Andrew Fuerste-Henry 2021-02-18 14:41:48 UTC
Correcting a typo in the test plan (charge behavior was backwards between 5 and 7):
Test plan:
0. Don't apply the patch
1. reset_all
=> finesMode eq 'off' in DB
2. Set the pref's value to production
3. Switch it back to 'off'
4. Value is '' in DB
5. Check an item in that should generate overdue charges
=> Charges are generated
6. Apply the patch
7. Check an item in that should generate overdue charges
=> Charges are not generated
Comment 7 Andrew Fuerste-Henry 2021-02-18 14:43:53 UTC
Pushed to 20.05.x for 20.05.09
Comment 8 Victor Grousset/tuxayo 2021-02-21 02:59:04 UTC
Backported: Pushed to 19.11.x branch for 19.11.15