Bugzilla – Attachment 106390 Details for
Bug 21395
Make perlcritic happy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21395: Remove 'variable $DEBUG masks earlier declaration in same scope' warning
Bug-21395-Remove-variable-DEBUG-masks-earlier-decl.patch (text/plain), 6.42 KB, created by
Jonathan Druart
on 2020-06-29 11:43:47 UTC
(
hide
)
Description:
Bug 21395: Remove 'variable $DEBUG masks earlier declaration in same scope' warning
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-06-29 11:43:47 UTC
Size:
6.42 KB
patch
obsolete
>From 9eadc1c6bd03b74c330b33383678dbd616efdc2c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 29 Jun 2020 13:42:55 +0200 >Subject: [PATCH] Bug 21395: Remove 'variable $DEBUG masks earlier declaration > in same scope' warning > >% prove t/db_dependent/Serials.t >t/db_dependent/Serials.t .. 8/49 "my" variable $DEBUG masks earlier declaration in same scope at /kohadevbox/koha/C4/Barcodes/ValueBuilder.pm line 45. >"my" variable $DEBUG masks earlier declaration in same scope at /kohadevbox/koha/C4/Barcodes/ValueBuilder.pm line 87. >--- > C4/Barcodes/ValueBuilder.pm | 141 ++++++++++++++++++------------------ > 1 file changed, 71 insertions(+), 70 deletions(-) > >diff --git a/C4/Barcodes/ValueBuilder.pm b/C4/Barcodes/ValueBuilder.pm >index 479a4360f8..22f21a6214 100644 >--- a/C4/Barcodes/ValueBuilder.pm >+++ b/C4/Barcodes/ValueBuilder.pm >@@ -18,92 +18,93 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >-package C4::Barcodes::ValueBuilder::incremental; >+{ >+ package C4::Barcodes::ValueBuilder::incremental; > >-use Modern::Perl; >-use C4::Context; >-my $DEBUG = 0; >+ use Modern::Perl; >+ use C4::Context; >+ my $DEBUG = 0; > >-sub get_barcode { >- my ($args) = @_; >- my $nextnum; >- # not the best, two catalogers could add the same barcode easily this way :/ >- my $query = "select max(abs(barcode)) from items"; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute(); >- while (my ($count)= $sth->fetchrow_array) { >- $nextnum = $count; >+ sub get_barcode { >+ my ($args) = @_; >+ my $nextnum; >+ # not the best, two catalogers could add the same barcode easily this way :/ >+ my $query = "select max(abs(barcode)) from items"; >+ my $sth = C4::Context->dbh->prepare($query); >+ $sth->execute(); >+ while (my ($count)= $sth->fetchrow_array) { >+ $nextnum = $count; >+ } >+ $nextnum++; >+ return $nextnum; > } >- $nextnum++; >- return $nextnum; > } > >-1; >- >-package C4::Barcodes::ValueBuilder::hbyymmincr; >-use C4::Context; >-my $DEBUG = 0; >+{ >+ package C4::Barcodes::ValueBuilder::hbyymmincr; >+ use C4::Context; >+ my $DEBUG = 0; > >-sub get_barcode { >- my ($args) = @_; >- my $nextnum = 0; >- my $year = substr($args->{year}, -2); >- my $month = $args->{mon}; >- my $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?"; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute("^[-a-zA-Z]{1,}$year$month"); >- while (my ($count)= $sth->fetchrow_array) { >- $nextnum = $count if $count; >- $nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 9999 items per month >- warn "Existing incremental number = $nextnum" if $DEBUG; >- } >- $nextnum++; >- $nextnum = sprintf("%0*d", "4",$nextnum); >- $nextnum = $year . $month . $nextnum; >- warn "New hbyymmincr Barcode = $nextnum" if $DEBUG; >- my $scr = " >- var form = document.getElementById('f'); >- if ( !form ) { >- form = document.getElementById('serials_edit'); >- } >- if ( !form ) { >- form = document.getElementById('Aform'); >+ sub get_barcode { >+ my ($args) = @_; >+ my $nextnum = 0; >+ my $year = substr($args->{year}, -2); >+ my $month = $args->{mon}; >+ my $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?"; >+ my $sth = C4::Context->dbh->prepare($query); >+ $sth->execute("^[-a-zA-Z]{1,}$year$month"); >+ while (my ($count)= $sth->fetchrow_array) { >+ $nextnum = $count if $count; >+ $nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 9999 items per month >+ warn "Existing incremental number = $nextnum" if $DEBUG; > } >- for (i=0 ; i<form.field_value.length ; i++) { >- if (form.tag[i].value == '$args->{loctag}' && form.subfield[i].value == '$args->{locsubfield}') { >- fnum = i; >+ $nextnum++; >+ $nextnum = sprintf("%0*d", "4",$nextnum); >+ $nextnum = $year . $month . $nextnum; >+ warn "New hbyymmincr Barcode = $nextnum" if $DEBUG; >+ my $scr = " >+ var form = document.getElementById('f'); >+ if ( !form ) { >+ form = document.getElementById('serials_edit'); >+ } >+ if ( !form ) { >+ form = document.getElementById('Aform'); > } >+ for (i=0 ; i<form.field_value.length ; i++) { >+ if (form.tag[i].value == '$args->{loctag}' && form.subfield[i].value == '$args->{locsubfield}') { >+ fnum = i; >+ } >+ } >+ if (\$('#' + id).val() == '') { >+ \$('#' + id).val(form.field_value[fnum].value + '$nextnum'); > } >- if (\$('#' + id).val() == '') { >- \$('#' + id).val(form.field_value[fnum].value + '$nextnum'); >+ "; >+ return $nextnum, $scr; > } >- "; >- return $nextnum, $scr; > } > >+{ >+ package C4::Barcodes::ValueBuilder::annual; >+ use C4::Context; >+ my $DEBUG = 0; > >-package C4::Barcodes::ValueBuilder::annual; >-use C4::Context; >-my $DEBUG = 0; >- >-sub get_barcode { >- my ($args) = @_; >- my $nextnum; >- my $query = "select max(cast( substring_index(barcode, '-',-1) as signed)) from items where barcode like ?"; >- my $sth=C4::Context->dbh->prepare($query); >- $sth->execute($args->{year} . '-%'); >- while (my ($count)= $sth->fetchrow_array) { >- warn "Examining Record: $count" if $DEBUG; >- $nextnum = $count if $count; >+ sub get_barcode { >+ my ($args) = @_; >+ my $nextnum; >+ my $query = "select max(cast( substring_index(barcode, '-',-1) as signed)) from items where barcode like ?"; >+ my $sth=C4::Context->dbh->prepare($query); >+ $sth->execute($args->{year} . '-%'); >+ while (my ($count)= $sth->fetchrow_array) { >+ warn "Examining Record: $count" if $DEBUG; >+ $nextnum = $count if $count; >+ } >+ $nextnum++; >+ $nextnum = sprintf("%0*d", "4",$nextnum); >+ $nextnum = "$args->{year}-$nextnum"; >+ return $nextnum; > } >- $nextnum++; >- $nextnum = sprintf("%0*d", "4",$nextnum); >- $nextnum = "$args->{year}-$nextnum"; >- return $nextnum; > } > >-1; >- > > =head1 Barcodes::ValueBuilder > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21395
:
79239
|
103666
|
103740
|
104038
|
104039
|
106293
|
106294
|
106295
|
106296
| 106390 |
106393
|
106394
|
106395
|
106398