Bug 30366

Summary: Warn when running automatic_item_modification_by_age.pl
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: Installation and upgrade (command-line installer)Assignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: fridolin.somers, kyle, martin.renvoize, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Martin Renvoize Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.06
Bug Depends on:    
Bug Blocks: 25790    
Attachments: Bug 30366: Remove warn when running automatic_item_modification_by_age.pl
Bug 30366: Remove warn when running automatic_item_modification_by_age.pl
Bug 30366: Remove warn when running automatic_item_modification_by_age.pl

Description Katrin Fischer 2022-03-26 23:31:25 UTC
When using the ./misc/cronjobs/automatic_item_modification_by_age.pl -v after setting up rules under tools > Automatic item modifications by age the script outputs several lines of warnings:

With patch from 22827:
Use of uninitialized value in string eq at /kohadevbox/koha/C4/Items.pm line 1856.

Master as of today:
Use of uninitialized value in string eq at /kohadevbox/koha/C4/Items.pm line 1852.
Comment 1 Fridolin Somers 2022-04-25 20:44:38 UTC
Created attachment 133844 [details] [review]
Bug 30366: Remove warn when running automatic_item_modification_by_age.pl

When using the ./misc/cronjobs/automatic_item_modification_by_age.pl -v
after setting up rules under Tools > Automatic item modifications by age
the script outputs several lines of warnings:
Use of uninitialized value in string eq at /kohadevbox/koha/C4/Items.pm line 1864.

This is because even when there is no condition defined, modification rule is stored with empty hash, like :
[{"substitutions":[{"field":"items.new_status","value":"0"}],"conditions":[{}],"age":"60","agefield":"items.dateaccessioned"}]

Test plan :
1) Go to Tools > Automatic item modifications by age
2) Create a rule with no conditions, just a substitution
3) Run misc/cronjobs/automatic_item_modification_by_age.pl -v
4) Check there is no warning
5) Edit the rule to add a condition
6) Run misc/cronjobs/automatic_item_modification_by_age.pl -v
7) Check the condition is applied
Comment 2 Owen Leonard 2022-04-26 13:44:17 UTC
Created attachment 133899 [details] [review]
Bug 30366: Remove warn when running automatic_item_modification_by_age.pl

When using the ./misc/cronjobs/automatic_item_modification_by_age.pl -v
after setting up rules under Tools > Automatic item modifications by
age the script outputs several lines of warnings:

Use of uninitialized value in string eq at /kohadevbox/koha/C4/Items.pm
line 1864.

This is because even when there is no condition defined, modification
rule is stored with empty hash, like :
[{"substitutions":[{"field":"items.new_status","value":"0"}],"conditions":[{}],"age":"60","agefield":"items.dateaccessioned"}]

Test plan :
1) Go to Tools > Automatic item modifications by age
2) Create a rule with no conditions, just a substitution
3) Run misc/cronjobs/automatic_item_modification_by_age.pl -v
4) Check there is no warning
5) Edit the rule to add a condition
6) Run misc/cronjobs/automatic_item_modification_by_age.pl -v
7) Check the condition is applied

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 3 Martin Renvoize 2022-04-26 13:56:08 UTC
Created attachment 133901 [details] [review]
Bug 30366: Remove warn when running automatic_item_modification_by_age.pl

When using the ./misc/cronjobs/automatic_item_modification_by_age.pl -v
after setting up rules under Tools > Automatic item modifications by
age the script outputs several lines of warnings:

Use of uninitialized value in string eq at /kohadevbox/koha/C4/Items.pm
line 1864.

This is because even when there is no condition defined, modification
rule is stored with empty hash, like :
[{"substitutions":[{"field":"items.new_status","value":"0"}],"conditions":[{}],"age":"60","agefield":"items.dateaccessioned"}]

Test plan :
1) Go to Tools > Automatic item modifications by age
2) Create a rule with no conditions, just a substitution
3) Run misc/cronjobs/automatic_item_modification_by_age.pl -v
4) Check there is no warning
5) Edit the rule to add a condition
6) Run misc/cronjobs/automatic_item_modification_by_age.pl -v
7) Check the condition is applied

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2022-04-26 13:56:43 UTC
Trivial and clear fix, works as expected, no regressions found and QA scripts happy.

PQA
Comment 5 Fridolin Somers 2022-05-02 21:24:28 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 6 Kyle M Hall 2022-05-13 15:46:55 UTC
Pushed to 21.11.x for 21.11.06
Comment 7 Victor Grousset/tuxayo 2022-06-23 01:44:50 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.
Comment 8 Martin Renvoize 2022-06-23 13:49:13 UTC
Warning cleanup, no documentation change required.