Bug 26141

Summary: Duplicated code in search.pl
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: aleisha, lucas, martin.renvoize
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00, 20.05.03
Circulation function:
Bug Depends on: 12478    
Bug Blocks:    
Attachments: Bug 26141: Remove duplicated code from search.pl
Bug 26141: Remove duplicated code from search.pl

Description Jonathan Druart 2020-08-05 07:57:52 UTC
commit 417553a9e47bf31f4cb785162e3dced856a2ac2a
  Bug 12478: starting to add search to staff client

This commit added code related to the itemtypes to the advanced search, but this code already existed.

The weird bit is:
$template->param(advancedsearchesloop => \@advancedsearchesloop);
my $types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
my $advancedsearchesloop = prepare_adv_search_types($types);
$template->param(advancedsearchesloop => $advancedsearchesloop);

We are passing twice advancedsearchesloop to the template.
Comment 1 Jonathan Druart 2020-08-05 07:59:27 UTC
Created attachment 107820 [details] [review]
Bug 26141: Remove duplicated code from search.pl

commit 417553a9e47bf31f4cb785162e3dced856a2ac2a
  Bug 12478: starting to add search to staff client

This commit added code related to the itemtypes to the advanced search, but this code already existed.

The weird bit is:
$template->param(advancedsearchesloop => \@advancedsearchesloop);
my $types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
my $advancedsearchesloop = prepare_adv_search_types($types);
$template->param(advancedsearchesloop => $advancedsearchesloop);

We are passing twice advancedsearchesloop to the template.

Test plan (for QA):
Review the changes and confirm that we can safely remove this code
Comment 2 Martin Renvoize (ashimema) 2020-08-05 11:12:32 UTC
Created attachment 107828 [details] [review]
Bug 26141: Remove duplicated code from search.pl

commit 417553a9e47bf31f4cb785162e3dced856a2ac2a
  Bug 12478: starting to add search to staff client

This commit added code related to the itemtypes to the advanced search, but this code already existed.

The weird bit is:
$template->param(advancedsearchesloop => \@advancedsearchesloop);
my $types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
my $advancedsearchesloop = prepare_adv_search_types($types);
$template->param(advancedsearchesloop => $advancedsearchesloop);

We are passing twice advancedsearchesloop to the template.

Test plan (for QA):
Review the changes and confirm that we can safely remove this code

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 3 Martin Renvoize (ashimema) 2020-08-05 11:14:03 UTC
Another one for a straight QA.. I've compared the code and it is indeed a direct clone of the factored out routine directly below it (with a few variables renamed.. moreover the template variable is actually be overwritten by the second call to set it via the factored out return anyway.

Safe to remove, Passing QA
Comment 4 Jonathan Druart 2020-08-05 15:37:07 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 5 Lucas Gass (lukeg) 2020-08-13 18:05:29 UTC
backported to 20.05.x for 20.05.03
Comment 6 Aleisha Amohia 2020-08-16 21:36:24 UTC
enhancement, not backported to 19.11.x