[Bug 12151] New: remove remaining uses of the Perl smartmatch operator
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Bug ID: 12151 Summary: remove remaining uses of the Perl smartmatch operator Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: gmcharlt@gmail.com Reporter: gmcharlt@gmail.com QA Contact: testopia@bugs.koha-community.org The Perl smartmatch operator has been marked as experimental as of Perl 5.18. As the syntax and interpretation of it is therefore subject to change, current uses of it should be removed. This is especially the case when running under Perl 5.18, as by default use of experimental constructs generates warning messages. The following source files contain the ~~ operator: C4/Search.pm: unless ( $data ~~ @used_datas ) { misc/translator/translate: if ( $cmd !~ /create/ && $lang && not $lang ~~ $installer->{langs} ) { opac/opac-search.pl: if ( $sort ~~ @allowed_sortby ) { tools/batchMod.pl: unless ( $field_to_update->subfield($subfield->[0]) ~~ $subfield->[1] ) { The following source files contain the given construct, which also uses smartmatch: C4/Serials.pm: given ($num_type) { reports/acquisitions_stats.pl: given ($_) { reports/acquisitions_stats.pl: given ($podsp) { reports/acquisitions_stats.pl: given ($rodsp) { reports/acquisitions_stats.pl: given ($process) { reports/borrowers_stats.pl: given ($line) { reports/borrowers_stats.pl: given ($column) { reports/borrowers_stats.pl: given ($i) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chris@bigballofwax.co.nz --- Comment #1 from Chris Cormack <chris@bigballofwax.co.nz> --- unless ( $data ~~ @used_datas ) { Should be the same as unless ( grep ( $_ eq $data) @used_datas ) { (I think, just noting it down for when I get the chance to try it) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #2 from Chris Cormack <chris@bigballofwax.co.nz> --- (In reply to Chris Cormack from comment #1)
unless ( $data ~~ @used_datas ) {
Should be the same as
unless ( grep ( $_ eq $data) @used_datas ) {
(I think, just noting it down for when I get the chance to try it)
It should be unless ( grep { $_ eq $data } @used_datas ) { -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com Depends on| |12301 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |12338 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 28580 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28580&action=edit Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl This patch removes the use of smartmatch operators in the search code. Regards To+ -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 28581 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28581&action=edit Bug 12151: Remove uses of smartmatch operator in report scripts This patch removes the use of smartmatch operators in report scripts. Regards To+ Sponsored-by: Universidad Nacional de Cordoba -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #5 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 28615 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28615&action=edit Bug 12151: Remove uses of smartmatch operator from Koha/Solr/QueryBuilder.pm Just that. Regards To+ -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #6 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 28616 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28616&action=edit Bug 12151: Remove use of smartmatch operator in tools/batchMod.pl The '~~' smartmatch operator is used to compare MARC::Field->subfield(code) (i.e. a string) and the text element of each MARC::Field->subfields() which is also plain text. Substituting '~~' for 'eq' should be harmless then. Regards To+ -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #7 from Jonathan Druart <jonathan.druart@biblibre.com> --- Comment on attachment 28580 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=28580 Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl Review of attachment 28580: --> (http://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=12151&attachment=28580) ----------------------------------------------------------------- ::: C4/Search.pm @@ +533,4 @@
foreach my $field (@fields) { my $data = $field->as_string( $subfield_letters, $facet->{sep} );
+ unless ( any { $data eq $_ } @used_datas ) {
Why don't you use grep? unless( grep /^$date$/, @used_datas ) Should do the same without the List::MoreUtils deps. ::: opac/opac-search.pl @@ +358,4 @@
@sort_by = $cgi->param('sort_by'); $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by); foreach my $sort (@sort_by) { + if ( any { $sort eq $_ } @allowed_sortby ) {
Same here. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #8 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Jonathan Druart from comment #7)
Comment on attachment 28580 [details] [review] Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl
Review of attachment 28580 [details] [review]: -----------------------------------------------------------------
::: C4/Search.pm @@ +533,4 @@
foreach my $field (@fields) { my $data = $field->as_string( $subfield_letters, $facet->{sep} );
+ unless ( any { $data eq $_ } @used_datas ) {
Why don't you use grep? unless( grep /^$date$/, @used_datas )
Should do the same without the List::MoreUtils deps.
I was more used to the Lists::Moreutils which don't have much footprint, and was already used all over the project. Feel free to change it. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28580|0 |1 is obsolete| | --- Comment #9 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 29013 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29013&action=edit Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl This patch removes the use of smartmatch operators in the search code. Regards To+ Edit: this revision uses 'grep' instead of Lists::MoreUtils::any Sponsored-by: Universidad Nacional de Cordoba -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28581|0 |1 is obsolete| | --- Comment #10 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 29014 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29014&action=edit Bug 12151: Remove uses of smartmatch operator in report scripts This patch removes the use of smartmatch operators in report scripts. Regards To+ Sponsored-by: Universidad Nacional de Cordoba -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28615|0 |1 is obsolete| | --- Comment #11 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 29015 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29015&action=edit Bug 12151: Remove uses of smartmatch operator from Koha/Solr/QueryBuilder.pm Just that. Regards To+ Sponsored-by: Universidad Nacional de Cordoba -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #28616|0 |1 is obsolete| | --- Comment #12 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 29016 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29016&action=edit Bug 12151: Remove use of smartmatch operator in tools/batchMod.pl The '~~' smartmatch operator is used to compare MARC::Field->subfield(code) (i.e. a string) and the text element of each MARC::Field->subfields() which is also plain text. Substituting '~~' for 'eq' should be harmless then. Regards To+ Sponsored-by: Universidad Nacional de Cordoba -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #13 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 29487 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29487&action=edit [SIGNED-OFF] Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl This patch removes the use of smartmatch operators in the search code. Regards To+ Edit: this revision uses 'grep' instead of Lists::MoreUtils::any Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Passes koha-qa.pl, all affected scripts appear to work properly -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #29013|0 |1 is obsolete| | Attachment #29014|0 |1 is obsolete| | Attachment #29015|0 |1 is obsolete| | Attachment #29016|0 |1 is obsolete| | --- Comment #14 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 29488 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29488&action=edit [SIGNED-OFF] Bug 12151: Remove uses of smartmatch operator in report scripts This patch removes the use of smartmatch operators in report scripts. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #15 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 29489 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29489&action=edit [SIGNED-OFF] Bug 12151: Remove uses of smartmatch operator from Koha/Solr/QueryBuilder.pm Just that. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #16 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 29490 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29490&action=edit [SIGNED-OFF] Bug 12151: Remove use of smartmatch operator in tools/batchMod.pl The '~~' smartmatch operator is used to compare MARC::Field->subfield(code) (i.e. a string) and the text element of each MARC::Field->subfields() which is also plain text. Substituting '~~' for 'eq' should be harmless then. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off CC| |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #17 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 29519 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29519&action=edit [PASSED QA] Bug 12151: Remove uses of smartmatch operator in Search.pm and opac-search.pl This patch removes the use of smartmatch operators in the search code. Regards To+ Edit: this revision uses 'grep' instead of Lists::MoreUtils::any Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Passes all tests and QA script. Tested search, no problems found. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #18 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 29520 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29520&action=edit [PASSED QA] Bug 12151: Remove uses of smartmatch operator in report scripts This patch removes the use of smartmatch operators in report scripts. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Passes QA script and tests. Acquisition and Patron statistics wizard tested, no regressions found. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #19 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 29521 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29521&action=edit Bug 12151: Remove uses of smartmatch operator from Koha/Solr/QueryBuilder.pm Just that. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Passes QA script and tests. Could only verify by reading the code. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 --- Comment #20 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 29522 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29522&action=edit [PASSED QA] Bug 12151: Remove use of smartmatch operator in tools/batchMod.pl The '~~' smartmatch operator is used to compare MARC::Field->subfield(code) (i.e. a string) and the text element of each MARC::Field->subfields() which is also plain text. Substituting '~~' for 'eq' should be harmless then. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Passes QA script and tests. Tested batch modification of items, no problems found. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA CC| |katrin.fischer@bsz-bw.de -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #29488|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #29489|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #29490|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #29487|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #29521|0 |1 is obsolete| | --- Comment #21 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 29523 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=29523&action=edit [PASSED QA] Bug 12151: Remove uses of smartmatch operator from Koha/Solr/QueryBuilder.pm Just that. Regards To+ Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Passes QA script and tests. Could only verify by reading the code. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #22 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Patches pushed to master. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=12593 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dpavlin@rot13.org --- Comment #23 from Dobrica Pavlinusic <dpavlin@rot13.org> --- Please see Bug 12593 for fix of problem with facets and data with square brackets -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |12593 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rel_3_16_4_candidate Status|Pushed to Master |Pushed to Stable --- Comment #24 from Galen Charlton <gmcharlt@gmail.com> --- Pushed to 3.16.x for inclusion in 3.16.4. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Fridolin SOMERS <fridolyn.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|Pushed to Stable |RESOLVED CC| |fridolyn.somers@biblibre.co | |m --- Comment #25 from Fridolin SOMERS <fridolyn.somers@biblibre.com> --- I choose to not push to 3.14.x I set as resolved -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12151 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |15250 Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15250 [Bug 15250] Software error: Can't locate object method "field" via package "aqorders.datereceived" in reports/acquisitions_stats.pl -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org