Bug 26587 added a concatenation that sends a warning if var is undef : $ prove t/db_dependent/Template/Plugin/Branches.t Use of uninitialized value $branchcode in concatenation (.) or string at /kohadevbox/koha/Koha/Template/Plugin/Branches.pm line 35.
Created attachment 129208 [details] [review] Bug 29826: Remove warning in t/db_dependent/Template/Plugin/Branches.t Bug 26587 added a concatenation that sends a warning if var is undef : $ prove t/db_dependent/Template/Plugin/Branches.t Use of uninitialized value $branchcode in concatenation (.) or string at /kohadevbox/koha/Koha/Template/Plugin/Branches.pm line 35. This patch adds an early return empty string when GetName is called without $branchcode Test plan : 1) Run t/db_dependent/Template/Plugin/Branches.t without patch 2) Run with the patch to see warning disappear
Created attachment 129630 [details] [review] Bug 29826: Remove warning in t/db_dependent/Template/Plugin/Branches.t Bug 26587 added a concatenation that sends a warning if var is undef : $ prove t/db_dependent/Template/Plugin/Branches.t Use of uninitialized value $branchcode in concatenation (.) or string at /kohadevbox/koha/Koha/Template/Plugin/Branches.pm line 35. This patch adds an early return empty string when GetName is called without $branchcode Test plan : 1) Run t/db_dependent/Template/Plugin/Branches.t without patch 2) Run with the patch to see warning disappear Signed-off-by: David Nind <david@davidnind.com>
I don't know if this is correct. We should never call the plugin without parameter. In my opinion the test is wrong and should be removed.
(In reply to Jonathan Druart from comment #3) > I don't know if this is correct. We should never call the plugin without > parameter. In my opinion the test is wrong and should be removed. This may occur with suggestions that can have branch undefined.
This report refers to the test. So the suggestion thing might be a different case. Or widen the scope by changing the title? + return q{} unless defined $branchcode; This still has the effect of testing if there is a branch with an empty code. Which makes no sense either? So you could also return unless $branchcode.
(In reply to Marcel de Rooy from comment #5) > This report refers to the test. So the suggestion thing might be a different > case. Or widen the scope by changing the title? Ah good point, I change title. > > + return q{} unless defined $branchcode; > This still has the effect of testing if there is a branch with an empty > code. Which makes no sense either? > So you could also return unless $branchcode. Ah indeed. But we must allow branchcode=0.
Created attachment 130030 [details] [review] Bug 29826: Manage call of Template Plugin Branches GetName() with null or empty branchcode Bug 26587 added a concatenation that sends a warning if var is undef : $ prove t/db_dependent/Template/Plugin/Branches.t Use of uninitialized value $branchcode in concatenation (.) or string at /kohadevbox/koha/Koha/Template/Plugin/Branches.pm line 35. This patch adds an early return empty string when GetName is called with $branchcode null or empty string. Test plan : 1) Run t/db_dependent/Template/Plugin/Branches.t without patch 2) Run with the patch to see warning disappear
Comment on attachment 129630 [details] [review] Bug 29826: Remove warning in t/db_dependent/Template/Plugin/Branches.t Replaced by later patch
Created attachment 130201 [details] [review] Bug 29826: Manage call of Template Plugin Branches GetName() with null or empty branchcode Bug 26587 added a concatenation that sends a warning if var is undef : $ prove t/db_dependent/Template/Plugin/Branches.t Use of uninitialized value $branchcode in concatenation (.) or string at /kohadevbox/koha/Koha/Template/Plugin/Branches.pm line 35. This patch adds an early return empty string when GetName is called with $branchcode null or empty string. Test plan : 1) Run t/db_dependent/Template/Plugin/Branches.t without patch 2) Run with the patch to see warning disappear Signed-off-by: David Nind <david@davidnind.com>
Created attachment 131183 [details] [review] Bug 29826: Manage call of Template Plugin Branches GetName() with null or empty branchcode Bug 26587 added a concatenation that sends a warning if var is undef : $ prove t/db_dependent/Template/Plugin/Branches.t Use of uninitialized value $branchcode in concatenation (.) or string at /kohadevbox/koha/Koha/Template/Plugin/Branches.pm line 35. This patch adds an early return empty string when GetName is called with $branchcode null or empty string. Test plan : 1) Run t/db_dependent/Template/Plugin/Branches.t without patch 2) Run with the patch to see warning disappear Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Great fix, includes tests, no regressions and squelched warnings. Passing QA
Pushed to master for 22.05, thanks to everybody involved [U+1F984]
Pushed to 21.11.x for 21.11.04
Missing dependency, not backported to 21.05