Browse Source

Bug 28572: Remove C4::Debug

We are using Koha::Logger when it makes sense to keep the info,
otherwise we simply remove it

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Bug 28572: Replace missing occurrence in misc/admin/koha-preferences

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
master
Jonathan Druart 2 months ago
parent
commit
3fe837bc74
  1. 2
      C4/Acquisition.pm
  2. 1
      C4/Auth_with_cas.pm
  3. 1
      C4/Auth_with_ldap.pm
  4. 1
      C4/Auth_with_shibboleth.pm
  5. 21
      C4/Barcodes.pm
  6. 3
      C4/Barcodes/EAN13.pm
  7. 4
      C4/Barcodes/annual.pm
  8. 10
      C4/Barcodes/hbyymmincr.pm
  9. 7
      C4/Biblio.pm
  10. 2
      C4/Budgets.pm
  11. 8
      C4/Charset.pm
  12. 3
      C4/Circulation.pm
  13. 3
      C4/ClassSplitRoutine/Dewey.pm
  14. 3
      C4/ClassSplitRoutine/Generic.pm
  15. 5
      C4/ClassSplitRoutine/LCC.pm
  16. 2
      C4/ClassSplitRoutine/RegEx.pm
  17. 1
      C4/Context.pm
  18. 2
      C4/Creators/Batch.pm
  19. 2
      C4/Creators/Layout.pm
  20. 2
      C4/Creators/Lib.pm
  21. 1
      C4/Creators/Profile.pm
  22. 1
      C4/Creators/Template.pm
  23. 183
      C4/Debug.pm
  24. 3
      C4/External/BakerTaylor.pm
  25. 1
      C4/Form/MessagingPreferences.pm
  26. 26
      C4/ImportExportFramework.pm
  27. 4
      C4/Labels/Label.pm
  28. 11
      C4/Letters.pm
  29. 2
      C4/Output.pm
  30. 11
      C4/Overdues.pm
  31. 3
      C4/Patroncards/Lib.pm
  32. 1
      C4/Reports.pm
  33. 13
      C4/Reports/Guided.pm
  34. 2
      C4/SIP/ILS/Item.pm
  35. 5
      C4/SIP/ILS/Patron.pm
  36. 2
      C4/SIP/ILS/Transaction/Checkin.pm
  37. 11
      C4/SIP/ILS/Transaction/Checkout.pm
  38. 5
      C4/Scrubber.pm
  39. 44
      C4/Search.pm
  40. 6
      C4/Serials.pm
  41. 3
      C4/Stats.pm
  42. 2
      C4/Suggestions.pm
  43. 32
      C4/Tags.pm
  44. 2
      Koha/Patron/Files.pm
  45. 1
      acqui/acqui-home.pl
  46. 5
      acqui/basket.pl
  47. 1
      acqui/histsearch.pl
  48. 1
      admin/aqbudgetperiods.pl
  49. 1
      admin/aqbudgets.pl
  50. 1
      admin/aqplan.pl
  51. 1
      admin/clone-rules.pl
  52. 3
      admin/smart-rules.pl
  53. 1
      admin/transport-cost-matrix.pl
  54. 1
      circ/bookcount.pl
  55. 2
      circ/branchoverdues.pl
  56. 8
      circ/overdue.pl
  57. 1
      circ/pendingreserves.pl
  58. 2
      circ/reserveratios.pl
  59. 7
      installer/data/mysql/backfill_statistics.pl
  60. 5
      koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt
  61. 1
      labels/label-create-csv.pl
  62. 1
      labels/label-create-pdf.pl
  63. 1
      labels/label-create-xml.pl
  64. 13
      labels/label-item-search.pl
  65. 1
      members/files.pl
  66. 12
      misc/admin/koha-preferences
  67. 1
      misc/cronjobs/gather_print_notices.pl
  68. 1
      misc/cronjobs/serialsUpdate.pl
  69. 1
      misc/cronjobs/staticfines.pl
  70. 2
      misc/load_testing/benchmark_staff.pl
  71. 15
      misc/migration_tools/bulkmarcimport.pl
  72. 1
      opac/opac-discharge.pl
  73. 1
      opac/opac-ratings-ajax.pl
  74. 1
      opac/opac-ratings.pl
  75. 1
      opac/opac-reserve.pl
  76. 2
      opac/opac-review.pl
  77. 1
      opac/opac-search-history.pl
  78. 10
      opac/opac-tags.pl
  79. 1
      patroncards/create-pdf.pl
  80. 1
      patroncards/image-manage.pl
  81. 1
      plugins/plugins-home.pl
  82. 1
      plugins/plugins-uninstall.pl
  83. 5
      plugins/plugins-upload.pl
  84. 1
      plugins/run.pl
  85. 10
      reports/catalogue_out.pl
  86. 1
      reports/guided_reports.pl
  87. 9
      reports/issues_stats.pl
  88. 4
      reports/reserves_stats.pl
  89. 2
      serials/subscription-bib-search.pl
  90. 1
      suggestion/suggestion.pl
  91. 19
      t/Debug.t
  92. 1
      t/db_dependent/Search.t
  93. 1
      t/db_dependent/Serials.t
  94. 8
      tags/review.pl
  95. 1
      tools/batchMod.pl
  96. 49
      tools/picture-upload.pl
  97. 4
      tools/viewlog.pl

2
C4/Acquisition.pm

@ -22,11 +22,9 @@ use Modern::Perl;
use Carp;
use Text::CSV_XS;
use C4::Context;
use C4::Debug;
use C4::Suggestions;
use C4::Biblio;
use C4::Contract;
use C4::Debug;
use C4::Log qw(logaction);
use C4::Templates qw(gettemplate);
use Koha::DateUtils qw( dt_from_string output_pref );

1
C4/Auth_with_cas.pm

@ -20,7 +20,6 @@ package C4::Auth_with_cas;
use strict;
use warnings;
use C4::Debug;
use C4::Context;
use Koha::AuthUtils qw(get_script_name);
use Authen::CAS::Client;

1
C4/Auth_with_ldap.pm

@ -20,7 +20,6 @@ package C4::Auth_with_ldap;
use Modern::Perl;
use Carp;
use C4::Debug;
use C4::Context;
use C4::Members::Messaging;
use C4::Auth qw(checkpw_internal);

1
C4/Auth_with_shibboleth.pm

@ -19,7 +19,6 @@ package C4::Auth_with_shibboleth;
use Modern::Perl;
use C4::Debug;
use C4::Context;
use Koha::AuthUtils qw(get_script_name);
use Koha::Database;

21
C4/Barcodes.pm

@ -23,14 +23,12 @@ use warnings;
use Carp;
use C4::Context;
use C4::Debug;
use C4::Barcodes::hbyymmincr;
use C4::Barcodes::annual;
use C4::Barcodes::incremental;
use C4::Barcodes::EAN13;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
use vars qw($max $prefformat);
BEGIN {
@ -73,11 +71,8 @@ sub value {
my $self = shift;
if (@_) {
my $value = shift;
if (defined $value) {
$debug and print STDERR " setting barcode value to $value\n";
} else {
warn "Error: UNDEF argument to value";
}
warn "Error: UNDEF argument to value"
unless defined $value;
$self->{value} = $value;
}
return $self->{value};
@ -96,16 +91,13 @@ sub parse { # return 3 parts of barcode: non-incrementing, incrementing, non-inc
carp "Barcode '$barcode' has no incrementing part!";
return ($barcode,undef,undef);
}
$debug and warn "Barcode '$barcode' parses into: '$1', '$2', ''";
return ($1,$2,''); # the third part is in anticipation of barcodes that include checkdigits
}
sub max {
my $self = shift;
if ($self->{is_max}) {
$debug and print STDERR "max taken from Barcodes value $self->value\n";
return $self->value;
}
$debug and print STDERR "Retrieving max database query.\n";
return $self->db_max;
}
sub db_max {
@ -123,7 +115,6 @@ sub next_value {
warn "No max barcode ($self->autoBarcode format) found. Using initial value.";
return $self->initial;
}
$debug and print STDERR "(current) max barcode found: $max\n";
my ($head,$incr,$tail) = $self->parse($max); # for incremental, you'd get ('',the_whole_barcode,'')
unless (defined $incr) {
warn "No incrementing part of barcode ($max) returned by parse.";
@ -135,11 +126,9 @@ sub next_value {
# Those should override next_value() to work accordingly.
$incr++;
$debug and warn "$incr";
$head = $self->process_head($head,$max,$specific);
$tail = $self->process_tail($tail,$incr,$specific); # XXX use $incr and not $max!
my $next_value = $head . $incr . $tail;
$debug and print STDERR "( next ) max barcode found: $next_value\n";
return $next_value;
}
sub next {
@ -183,9 +172,6 @@ sub new {
my $class_or_object = shift;
my $type = ref($class_or_object) || $class_or_object;
my $from_obj = ref($class_or_object) ? 1 : 0; # are we building off another Barcodes object?
if ($from_obj) {
$debug and print STDERR "Building new(@_) from old Barcodes object\n";
}
my $autoBarcodeType = (@_) ? shift : $from_obj ? $class_or_object->autoBarcode : _prefformat;
$autoBarcodeType =~ s/^.*:://; # in case we get C4::Barcodes::incremental, we just want 'incremental'
unless ($autoBarcodeType) {
@ -196,7 +182,6 @@ sub new {
carp "The autoBarcode format '$autoBarcodeType' is unrecognized.";
return;
}
carp "autoBarcode format = $autoBarcodeType" if $debug;
my $self;
if ($autoBarcodeType eq 'OFF') {
$self = $class_or_object->default_self($autoBarcodeType);
@ -207,7 +192,6 @@ sub new {
$self = $class_or_object->new_object(@_);
$self->serial($class_or_object->serial + 1);
if ($class_or_object->is_max) {
$debug and print STDERR "old object was max: ", $class_or_object->value, "\n";
$self->previous($class_or_object);
$class_or_object->next($self);
$self->value($self->next_value($class_or_object->value));
@ -216,7 +200,6 @@ sub new {
$self->value($self->next_value);
}
} else {
$debug and print STDERR "trying to create new $autoBarcodeType\n";
$self = &{$types->{$autoBarcodeType}} (@_);
$self->value($self->next_value) and $self->is_max(1);
$self->serial(1);

3
C4/Barcodes/EAN13.pm

@ -21,13 +21,11 @@ use strict;
use warnings;
use C4::Context;
use C4::Debug;
use Algorithm::CheckDigits;
use Carp;
use vars qw(@ISA);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
BEGIN {
@ISA = qw(C4::Barcodes);
@ -50,7 +48,6 @@ sub process_tail {
my $ean = CheckDigits('ean');
my $full = $ean->complete($whole);
my $chk = $ean->checkdigit($full);
$debug && warn "# process_tail $tail -> $chk [$whole -> $full] $specific";
return $chk;
}

4
C4/Barcodes/annual.pm

@ -23,12 +23,10 @@ use warnings;
use Carp;
use C4::Context;
use C4::Debug;
use Koha::DateUtils qw( output_pref dt_from_string );
use vars qw(@ISA);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
use vars qw($width);
BEGIN {
@ -55,7 +53,6 @@ sub db_max {
my $year = substr($iso,0,4); # YYYY
$sth->execute("$year-%");
my $row = $sth->fetchrow_hashref;
warn "barcode db_max (annual format, year $year): $row->{barcode}" if $debug;
return $row->{barcode};
}
@ -71,7 +68,6 @@ sub parse {
carp "Barcode '$barcode' has no incrementing part!";
return ($barcode,undef,undef);
}
$debug and warn "Barcode '$barcode' parses into: '$1', '$2', ''";
return ($1,$2,''); # the third part is in anticipation of barcodes that include checkdigits
}
sub width {

10
C4/Barcodes/hbyymmincr.pm

@ -22,14 +22,12 @@ use Modern::Perl;
use Carp;
use C4::Context;
use C4::Debug;
use Koha::DateUtils qw( dt_from_string output_pref );
use constant WIDTH => 4; # FIXME: too small for sizeable or multi-branch libraries?
use vars qw(@ISA);
use vars qw($debug $cgi_debug); # from C4::Debug, of course
BEGIN {
@ISA = qw(C4::Barcodes);
@ -42,7 +40,6 @@ sub db_max {
my $self = shift;
my $width = WIDTH;
my $query = "SELECT SUBSTRING(barcode,-$width) AS chunk, barcode FROM items WHERE barcode REGEXP ? ORDER BY chunk DESC LIMIT 1";
$debug and print STDERR "(hbyymmincr) db_max query: $query\n";
my $sth = C4::Context->dbh->prepare($query);
my ($iso);
if (@_) {
@ -64,7 +61,6 @@ sub db_max {
}
my ($row) = $sth->fetchrow_hashref;
my $max = $row->{barcode};
warn "barcode max (hbyymmincr format): $max" if $debug;
return ($max || 0);
}
@ -85,7 +81,6 @@ sub parse { # return 3 parts of barcode: non-incrementing, incrementing, non-i
carp "Barcode '$barcode' has no incrementing part!";
return ($barcode,undef,undef);
}
$debug and warn "Barcode '$barcode' parses into: '$1', '$2', ''";
return ($1,$2,''); # the third part is in anticipation of barcodes that include checkdigits
}
@ -111,7 +106,6 @@ sub process_head { # (self,head,whole,specific)
}
sub new_object {
$debug and warn "hbyymmincr: new_object called";
my $class_or_object = shift;
my $type = ref($class_or_object) || $class_or_object;
@ -127,10 +121,6 @@ sub new_object {
$self->branch( @_ ? shift : $from_obj ? $class_or_object->branch : '' );
warn "HBYYMM Barcode created with no branchcode, default is blank" if ( $self->branch() eq '' );
# take the branch from argument, or existing object, or default
use Data::Dumper;
$debug and print STDERR "(hbyymmincr) new_object: ", Dumper($self), "\n";
return $self;
}

7
C4/Biblio.pm

@ -92,8 +92,8 @@ use C4::ClassSource;
use C4::Charset;
use C4::Linker;
use C4::OAI::Sets;
use C4::Debug;
use Koha::Logger;
use Koha::Caches;
use Koha::Authority::Types;
use Koha::Acquisition::Currencies;
@ -106,9 +106,6 @@ use Koha::SearchEngine::Indexer;
use Koha::Libraries;
use Koha::Util::MARC;
use vars qw($debug $cgi_debug);
=head1 NAME
C4::Biblio - cataloging management functions
@ -2498,7 +2495,7 @@ $server is authorityserver or biblioserver
sub ModZebra {
my ( $record_number, $op, $server ) = @_;
$debug && warn "ModZebra: updates requested for: $record_number $op $server\n";
Koha::Logger->get->debug("ModZebra: updates requested for: $record_number $op $server");
my $dbh = C4::Context->dbh;
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates

2
C4/Budgets.pm

@ -22,7 +22,6 @@ use C4::Context;
use Koha::Database;
use Koha::Patrons;
use Koha::Acquisition::Invoice::Adjustments;
use C4::Debug;
use C4::Acquisition;
use vars qw(@ISA @EXPORT);
@ -510,7 +509,6 @@ sub GetBudgetHierarchy {
}
}
$query.=" WHERE ".join(' AND ', @where_strings) if @where_strings;
$debug && warn $query,join(",",@bind_params);
my $sth = $dbh->prepare($query);
$sth->execute(@bind_params);

8
C4/Charset.pm

@ -17,15 +17,15 @@ package C4::Charset;
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use Modern::Perl;
use MARC::Charset qw/marc8_to_utf8/;
use Text::Iconv;
use C4::Debug;
use Unicode::Normalize;
use Encode qw( decode encode is_utf8 );
use Koha::Logger;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
BEGIN {
@ -353,7 +353,7 @@ sub SetMarcUnicodeFlag {
$marc_record->insert_grouped_field(
MARC::Field->new( 100, '', '', "a" => $string ) );
}
$debug && warn "encodage: ", substr( $marc_record->subfield(100, 'a'), $encodingposition, 3 );
Koha::Logger->get->debug("encodage: ", substr( $marc_record->subfield(100, 'a'), $encodingposition, 3 ));
} else {
warn "Unrecognized marcflavour: $marc_flavour";
}

3
C4/Circulation.pm

@ -34,7 +34,6 @@ use C4::Members;
use C4::Accounts;
use C4::ItemCirculationAlertPreference;
use C4::Message;
use C4::Debug;
use C4::Log; # logaction
use C4::Overdues qw(CalcFine UpdateFine get_chargeable_units);
use C4::RotatingCollections qw(GetCollectionItemBranches);
@ -2293,8 +2292,6 @@ sub AddReturn {
(C4::Context->preference("UseBranchTransferLimits") and
! IsBranchTransferAllowed($branch, $returnbranch, $item->$BranchTransferLimitsType )
)) {
$debug and warn sprintf "about to call ModItemTransfer(%s, %s, %s, %s)", $item->itemnumber,$branch, $returnbranch, $transfer_trigger;
$debug and warn "item: " . Dumper($item->unblessed);
ModItemTransfer($item->itemnumber, $branch, $returnbranch, $transfer_trigger, { skip_record_index => 1 });
$messages->{'WasTransfered'} = $returnbranch;
$messages->{'TransferTrigger'} = $transfer_trigger;

3
C4/ClassSplitRoutine/Dewey.pm

@ -19,8 +19,6 @@ package C4::ClassSplitRoutine::Dewey;
use Modern::Perl;
use C4::Debug;
=head1 NAME
C4::ClassSplitRoutine::Dewey - Dewey call number split method
@ -66,7 +64,6 @@ sub split_callnumber {
push @lines, split /\s+/,
pop @lines
; # split the last piece into an arbitrary number of pieces at spaces
$debug and print STDERR "split_ddcn array: ", join( " | ", @lines ), "\n";
return @lines;
}

3
C4/ClassSplitRoutine/Generic.pm

@ -19,8 +19,6 @@ package C4::ClassSplitRoutine::Generic;
use Modern::Perl;
use C4::Debug;
=head1 NAME
C4::ClassSplitRoutine::Generic - generic call number sorting key routine
@ -58,7 +56,6 @@ sub split_callnumber {
warn sprintf( 'regexp failed to match string: %s', $cn_item );
push( @lines, $cn_item );
}
$debug and print STDERR "split_ccn array: ", join( " | ", @lines ), "\n";
return @lines;
}

5
C4/ClassSplitRoutine/LCC.pm

@ -20,7 +20,7 @@ package C4::ClassSplitRoutine::LCC;
use Modern::Perl;
use Library::CallNumber::LC;
use C4::Debug;
use Koha::Logger;
=head1 NAME
@ -45,12 +45,11 @@ sub split_callnumber {
# lccn examples: 'HE8700.7 .P6T44 1983', 'BS2545.E8 H39 1996';
my @lines = Library::CallNumber::LC->new($cn_item)->components();
unless (scalar @lines && defined $lines[0]) {
$debug and warn sprintf('regexp failed to match string: %s', $cn_item);
Koha::Logger->get->debug(sprintf('regexp failed to match string: %s', $cn_item));
@lines = $cn_item; # if no match, just use the whole string.
}
my $LastPiece = pop @lines;
push @lines, split /\s+/, $LastPiece if $LastPiece; # split the last piece into an arbitrary number of pieces at spaces
$debug and warn "split LCC array: ", join(" | ", @lines), "\n";
return @lines;
}

2
C4/ClassSplitRoutine/RegEx.pm

@ -19,8 +19,6 @@ package C4::ClassSplitRoutine::RegEx;
use Modern::Perl;
use C4::Debug;
=head1 NAME
C4::ClassSplitRoutine::RegEx - regex call number sorting key routine

1
C4/Context.pm

@ -44,7 +44,6 @@ use POSIX ();
use YAML::XS;
use ZOOM;
use C4::Debug;
use Koha::Caches;
use Koha::Config::SysPref;
use Koha::Config::SysPrefs;

2
C4/Creators/Batch.pm

@ -6,8 +6,6 @@ use warnings;
use autouse 'Data::Dumper' => qw(Dumper);
use C4::Context;
use C4::Debug;
sub _check_params {
my $given_params = {};

2
C4/Creators/Layout.pm

@ -6,10 +6,8 @@ use warnings;
use autouse 'Data::Dumper' => qw(Dumper);
use C4::Context;
use C4::Debug;
use C4::Creators::PDF;
# FIXME: Consider this style parameter verification instead...
# my %param = @_;
# for (keys %param)

2
C4/Creators/Lib.pm

@ -23,7 +23,6 @@ use Storable qw(dclone);
use autouse 'Data::Dumper' => qw(Dumper);
use C4::Context;
use C4::Debug;
BEGIN {
use base qw(Exporter);
@ -266,7 +265,6 @@ sub get_all_image_names {
my $image_names = [];
my $query = "SELECT image_name FROM creator_images";
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3 if $debug;
$sth->execute();
if ($sth->err) {
warn sprintf('Database returned the following error: %s', $sth->errstr);

1
C4/Creators/Profile.pm

@ -6,7 +6,6 @@ use warnings;
use autouse 'Data::Dumper' => qw(Dumper);
use C4::Context;
use C4::Debug;
use C4::Creators::Lib qw(get_unit_values);

1
C4/Creators/Template.pm

@ -6,7 +6,6 @@ use POSIX qw(ceil);
use autouse 'Data::Dumper' => qw(Dumper);
use C4::Context;
use C4::Debug;
use C4::Creators::Profile;
use C4::Creators::Lib qw(get_unit_values);

183
C4/Debug.pm

@ -1,183 +0,0 @@
package C4::Debug;
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use Exporter;
# use CGI qw ( -utf8 );
use vars qw(@ISA @EXPORT $debug $cgi_debug);
# use vars qw(@EXPORT_OK %EXPORT_TAGS);
BEGIN {
@ISA = qw(Exporter);
@EXPORT = qw($debug $cgi_debug);
# @EXPOR_OK = qw();
# %EXPORT_TAGS = ( all=>[qw($debug $cgi_debug)], );
}
BEGIN {
# this stuff needs a begin block too, since dependencies might alter their compilations
# for example, adding DataDumper
$debug = $ENV{KOHA_DEBUG} || $ENV{DEBUG} || 0;
# CGI->new conflicts w/ some upload functionality,
# since we would get the "first" CGI object here.
# Instead we have to parse for ourselves if we want QUERY_STRING triggers.
# my $query = CGI->new(); # conflicts!
# $cgi_debug = $ENV{KOHA_CGI_DEBUG} || $query->param('debug') || 0;
$cgi_debug = $ENV{KOHA_CGI_DEBUG} || 0;
unless ($cgi_debug or not $ENV{QUERY_STRING}) {
foreach (split /\&/, $ENV{QUERY_STRING}) {
/^debug\=(.+)$/ or next;
$cgi_debug = $1;
last;
}
}
unless ($debug =~ /^\d$/) {
warn "Invalid \$debug value attempted: $debug";
$debug=1;
}
unless ($cgi_debug =~ /^\d$/) {
$debug and
warn "Invalid \$cgi_debug value attempted: $cgi_debug";
$cgi_debug=1;
}
}
# sub import {
# print STDERR __PACKAGE__ . " (Debug) import @_\n";
# C4::Debug->export_to_level(1, @_);
# }
1;
__END__
=head1 NAME
C4::Debug - Standardized, centralized, exported debug switches.
=head1 SYNOPSIS
use C4::Debug;
=head1 DESCRIPTION
The purpose of this module is to centralize some of the "switches" that turn debugging
off and on in Koha. Most often, this functionality will be provided via C4::Context.
C4::Debug is separate to preserve the relatively stable state of Context, and
because other code will use C4::Debug without invoking Context.
Although centralization is our intention,
for logical and security reasons, several approaches to debugging need to be
kept separate. Information useful to developers in one area will not necessarily
be useful or even available to developers in another area.
For example, the designer of template-influenced javascript my want to be able to
trigger javascript's alert function to display certain variable values, to verify
the template selection is being performed correctly. For this purpose the presence
of a javascript "debug" variable might be a good switch.
Meanwhile, where security coders (say, for LDAP Auth) will appreciate low level feedback about
Authentication transactions, an environmental system variable might be a good switch.
However, clearly we would not want to expose that same information (e.g., entire LDAP records)
to the web interface based on a javascript variable (even if it were possible)!
All that is a long way of saying THERE ARE SECURITY IMPLICATIONS to turning on
debugging in various parts of the system, so don't treat them all the same or confuse them.
=head1 VARIABLES / AREAS
=head2 $debug - System, general
The general purpose debug switch.
=head3 How to Set $debug:
=over
=item environmental variable DEBUG or KOHA_DEBUG. In bash, you might do:
export KOHA_DEBUG=1;
perl t/Auth.t;
=item Keep in mind that your webserver will not be running in the same environment as your shell.
However, for development purposes, the same effect can be had by using Apache's SET_ENV
command with ERROR_LOG enabled for your VirtualHost. Not intended for production systems.
=item You can force the value from perl directly, like:
use C4::Debug;
BEGIN { $C4::Debug::debug = 1; }
# now any other dependencies that also use C4::Debug will have debugging ON.
=back
=head2 $cgi_debug (CGI params) The web-based debug switch.
=head3 How to Set $cgi_debug:
=over
=item From a web browser, for example by supplying a non-zero debug parameter (1 to 9):
http://www.mylibrary.org/cgi-bin/koha/opac-search.pl?q=history&debug=1
=item Or in HTML, add a similar input parameter:
<input type="hidden" name="debug" value="1" />
=item Or from shell (or Apache), set KOHA_CGI_DEBUG.
=back
The former methods mean $cgi_debug is exposed. Do NOT use it to trigger any actions that you would
not allow a (potentially anonymous) end user to perform. Dumping sensitive data, directory listings, or
emailing yourself a test message would all be bad actions to tie to $cgi_debug.
=head1 OTHER SOURCES of Debug Switches
=head2 System Preferences
=cut
=head2 Database Debug
Debugging at the database level might be useful. Koha does not currently integrate any such
capability.
=head1 CONVENTIONS
Debug values range from 0 to 9. At zero (the default), debugging is off.
=head1 AUTHOR
Joe Atzberger
atz AT liblime DOT com
=head1 SEE ALSO
CGI(3)
C4::Context
=cut

3
C4/External/BakerTaylor.pm

@ -23,7 +23,6 @@ use LWP::Simple;
use HTTP::Request::Common;
use C4::Context;
use C4::Debug;
use Modern::Perl;
@ -91,9 +90,7 @@ sub availability {
($user and $pass) or return;
$isbn =~ s/(p|-)//g; # sanitize
my $url = "https://contentcafe2.btol.com/ContentCafe/InventoryAvailability.asmx/CheckInventory?UserID=$user&Password=$pass&Value=$isbn";
$debug and warn __PACKAGE__ . " request:\n$url\n";
my $content = get($url);
$debug and print STDERR $content, "\n";
warn "could not retrieve $url" unless $content;
my $xmlsimple = XML::Simple->new();
my $result = $xmlsimple->XMLin($content);

1
C4/Form/MessagingPreferences.pm

@ -23,7 +23,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Members::Messaging;
use C4::Debug;
use constant MAX_DAYS_IN_ADVANCE => 30;

26
C4/ImportExportFramework.pm

@ -27,8 +27,7 @@ use Text::CSV_XS;
use List::MoreUtils qw(indexes);
use C4::Context;
use C4::Debug;
use Koha::Logger;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -226,7 +225,7 @@ sub ExportFramework
}
};
if ($@) {
$debug and warn "Error ExportFramework $@\n";
Koha::Logger->get->warn("Error ExportFramework $@");
return 0;
}
}
@ -298,7 +297,7 @@ sub _export_table_csv
$$strCSV .= chr(10);
};
if ($@) {
$debug and warn "Error _export_table_csv $@\n";
Koha::Logger->get->warn("Error _export_table_csv $@");
return 0;
}
return 1;
@ -364,7 +363,7 @@ sub _export_table_ods
}
};
if ($@) {
$debug and warn "Error _export_table_ods $@\n";
Koha::Logger->get->warn("Error _export_table_ods $@");
return 0;
}
return 1;
@ -429,7 +428,7 @@ sub _export_table_excel
}
};
if ($@) {
$debug and warn "Error _export_table_excel $@\n";
Koha::Logger->get->warn("Error _export_table_excel $@");
return 0;
}
return 1;
@ -551,7 +550,7 @@ sub createODS
}
};
if ($@) {
$debug and warn "Error createODS $@\n";
Koha::Logger->get->warn("Error createODS $@");
} else {
# create ods file from tempdir directory
eval {
@ -676,11 +675,11 @@ sub ImportFramework
}
}
} else {
$debug and warn "Error ImportFramework couldn't create dom\n";
Koha::Logger->get->warn("Error ImportFramework couldn't create dom");
}
};
if ($@) {
$debug and warn "Error ImportFramework $@\n";
Koha::Logger->get->warn("Error ImportFramework $@");
} else {
if ($extension eq 'csv') {
close($dom) if ($dom);
@ -689,7 +688,7 @@ sub ImportFramework
}
unlink ($filename) if ($deleteFilename); # remove temporary file
} else {
$debug and warn "Error ImportFramework no conex to database or not readeable $filename\n";
Koha::Logger->get->warn("Error ImportFramework no conex to database or not readeable $filename");
}
if ($deleteFilename && $tempdir && -d $tempdir && -w $tempdir) {
eval {
@ -860,8 +859,7 @@ sub _processRow_DB
$sth->execute((@$dataFields, @$dataFields));
};
if ($@) {
warn $@;
$debug and warn "Error _processRow_DB $@\n";
Koha::Logger->get->warn("Error _processRow_DB $@");
} else {
$ok = 1;
}
@ -1011,7 +1009,7 @@ sub _import_table_ods
my $nodeR = $nodes[0]->firstChild;
return _processRows_Table($dbh, $frameworkcode, $nodeR, $table, $PKArray, 'ods', $fields2Delete);
} else {
$debug and warn "Error _import_table_ods there's not worksheet for $table\n";
Koha::Logger->get->warn("Error _import_table_ods there's not worksheet for $table");
}
return 0;
}#_import_table_ods
@ -1037,7 +1035,7 @@ sub _import_table_excel
}
}
} else {
$debug and warn "Error _import_table_excel there's not worksheet for $table\n";
Koha::Logger->get->warn("Error _import_table_excel there's not worksheet for $table");
}
return 0;
}#_import_table_excel

4
C4/Labels/Label.pm

@ -10,7 +10,6 @@ use Data::Dumper;
use Text::Bidi qw( log2vis );
use C4::Context;
use C4::Debug;
use C4::Biblio;
use Koha::ClassSources;
use Koha::ClassSortRules;
@ -153,8 +152,6 @@ sub _get_barcode_data {
for my $field ( @fields ) {
if ($item->{$field}) {
push @data, $item->{$field};
} else {
$debug and warn sprintf("The '%s' field contains no data.", $field);
}
}
$datastring .= join ' ', @data;
@ -241,7 +238,6 @@ sub _BIBBAR {
my $barcode_y_scale_factor = 0.01 * $self->{'height'}; # this scales the barcode height to 10% of the label height
my $line_spacer = ($self->{'font_size'} * 1); # number of pixels between text rows (This is actually leading: baseline to baseline minus font size. Recommended starting point is 20% of font size.).
my $text_lly = ($self->{'lly'} + ($self->{'height'} - $self->{'top_text_margin'}));
$debug and warn "Label: llx $self->{'llx'}, lly $self->{'lly'}, Text: lly $text_lly, $line_spacer, Barcode: llx $barcode_llx, lly $barcode_lly, $barcode_width, $barcode_y_scale_factor\n";
return $self->{'llx'}, $text_lly, $line_spacer, $barcode_llx, $barcode_lly, $barcode_width, $barcode_y_scale_factor;
}

11
C4/Letters.pm

@ -32,7 +32,6 @@ use C4::Members;
use C4::Log;
use C4::SMS;
use C4::Templates;
use C4::Debug;
use Koha::DateUtils;
use Koha::SMS::Providers;
@ -928,7 +927,7 @@ sub EnqueueLetter {
my $content = $params->{letter}->{content};
$content =~ s/\s+//g if(defined $content);
if ( not defined $content or $content eq '' ) {
warn "Trying to add an empty message to the message queue" if $debug;
Koha::Logger->get->info("Trying to add an empty message to the message queue");
return;
}
@ -1013,7 +1012,7 @@ sub SendQueuedMessages {
warn sprintf( 'sending %s message to patron: %s',
$message->{'message_transport_type'},
$message->{'borrowernumber'} || 'Admin' )
if $params->{'verbose'} or $debug;
if $params->{'verbose'};
# This is just begging for subclassing
next MESSAGE if ( lc($message->{'message_transport_type'}) eq 'rss' );
if ( lc( $message->{'message_transport_type'} ) eq 'email' ) {
@ -1024,13 +1023,13 @@ sub SendQueuedMessages {
my $patron = Koha::Patrons->find( $message->{borrowernumber} );
my $sms_provider = Koha::SMS::Providers->find( $patron->sms_provider_id );
unless ( $sms_provider ) {
warn sprintf( "Patron %s has no sms provider id set!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
warn sprintf( "Patron %s has no sms provider id set!", $message->{'borrowernumber'} ) if $params->{'verbose'};
_set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
next MESSAGE;
}
unless ( $patron->smsalertnumber ) {
_set_message_status( { message_id => $message->{'message_id'}, status => 'failed' } );
warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'} or $debug;
warn sprintf( "No smsalertnumber found for patron %s!", $message->{'borrowernumber'} ) if $params->{'verbose'};
next MESSAGE;
}
$message->{to_address} = $patron->smsalertnumber; #Sometime this is set to email - sms should always use smsalertnumber
@ -1299,8 +1298,6 @@ sub _get_unsent_messages {
}
}
$debug and warn "_get_unsent_messages SQL: $statement";
$debug and warn "_get_unsent_messages params: " . join(',',@query_params);
my $sth = $dbh->prepare( $statement );
my $result = $sth->execute( @query_params );
return $sth->fetchall_arrayref({});

2
C4/Output.pm

@ -100,8 +100,6 @@ sub pagination_bar {
$base_url =~ s/$delim*\b$startfrom_name=(\d+)//g; # remove previous pagination var
unless (defined $current_page and $current_page > 0 and $current_page <= $nb_pages) {
$current_page = ($1) ? $1 : 1; # pull current page from param in URL, else default to 1
# $debug and # FIXME: use C4::Debug;
# warn "with QUERY_STRING:" .$ENV{QUERY_STRING}. "\ncurrent_page:$current_page\n1:$1 2:$2 3:$3";
}
$base_url =~ s/($delim)+/$1/g; # compress duplicate delims
$base_url =~ s/$delim;//g; # remove empties

11
C4/Overdues.pm

@ -31,7 +31,7 @@ use C4::Circulation;
use C4::Context;
use C4::Accounts;
use C4::Log; # logaction
use C4::Debug;
use Koha::Logger;
use Koha::DateUtils;
use Koha::Account::Lines;
use Koha::Account::Offsets;
@ -275,7 +275,6 @@ sub CalcFine {
$amount = $item->{replacementprice} if ( $issuing_rule->{cap_fine_to_replacement_price} && $item->{replacementprice} && $amount > $item->{replacementprice} );
$debug and warn sprintf("CalcFine returning (%s, %s, %s)", $amount, $units_minus_grace, $chargeable_units);
return ($amount, $units_minus_grace, $chargeable_units);
}
@ -522,8 +521,6 @@ sub UpdateFine {
my $amount = $params->{amount};
my $due = $params->{due} // q{};
$debug and warn "UpdateFine({ itemnumber => $itemnum, borrowernumber => $borrowernumber, due => $due, issue_id => $issue_id})";
unless ( $issue_id ) {
carp("No issue_id passed in!");
return;
@ -547,7 +544,7 @@ sub UpdateFine {
while (my $overdue = $overdues->next) {
if ( defined $overdue->issue_id && $overdue->issue_id == $issue_id && $overdue->status eq 'UNRETURNED' ) {
if ($accountline) {
$debug and warn "Not a unique accountlines record for issue_id $issue_id";
Koha::Logger->get->debug("Not a unique accountlines record for issue_id $issue_id"); # FIXME Do we really need to log that?
#FIXME Should we still count this one in total_amount ??
}
else {
@ -563,12 +560,12 @@ sub UpdateFine {
if ($accountline) {
if ( ( $amount - $accountline->amount ) > $maxIncrease ) {
my $new_amount = $accountline->amount + $maxIncrease;
$debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached";
Koha::Logger->get->debug("Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached");
$amount = $new_amount;
}
}
elsif ( $amount > $maxIncrease ) {
$debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $maxIncrease - MaxFine reached";
Koha::Logger->get->debug("Reducing fine for item $itemnum borrower $borrowernumber from $amount to $maxIncrease - MaxFine reached");
$amount = $maxIncrease;
}
}

3
C4/Patroncards/Lib.pm

@ -20,10 +20,7 @@ package C4::Patroncards::Lib;
use strict;
use warnings;
use autouse 'Data::Dumper' => qw(Dumper);
use C4::Context;
use C4::Debug;
BEGIN {
use base qw(Exporter);

1
C4/Reports.pm

@ -22,7 +22,6 @@ use CGI qw ( -utf8 );
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use C4::Context;
use C4::Debug;
BEGIN {
require Exporter;

13
C4/Reports/Guided.pm

@ -30,11 +30,11 @@ use Koha::DateUtils;
use Koha::Patrons;
use Koha::Reports;
use C4::Output;
use C4::Debug;
use C4::Log;
use Koha::Notice::Templates;
use C4::Letters;
use Koha::Logger;
use Koha::AuthorisedValues;
use Koha::Patron::Categories;
use Koha::SharedContent;
@ -550,7 +550,8 @@ sub execute_query {
}
$offset = 0 unless $offset;
$limit = 999999 unless $limit;
$debug and print STDERR "execute_query($sql, $offset, $limit)\n";
Koha::Logger->get->debug("Report - execute_query($sql, $offset, $limit)");
my ( $is_sql_valid, $errors ) = Koha::Report->new({ savedsql => $sql })->is_sql_valid;
return (undef, @{$errors}[0]) unless $is_sql_valid;
@ -571,9 +572,11 @@ sub execute_query {
# Grab offset/limit from user supplied LIMIT and drop the LIMIT so we can control pagination
($sql, $useroffset, $userlimit) = strip_limit($sql);
$debug and warn sprintf "User has supplied (OFFSET,) LIMIT = %s, %s",
$useroffset,
(defined($userlimit ) ? $userlimit : 'UNDEF');
Koha::Logger->get->debug(
sprintf "User has supplied (OFFSET,) LIMIT = %s, %s",
$useroffset, ( defined($userlimit) ? $userlimit : 'UNDEF' ) );
$offset += $useroffset;
if (defined($userlimit)) {
if ($offset + $limit > $userlimit ) {

2
C4/SIP/ILS/Item.pm

@ -19,7 +19,6 @@ use C4::SIP::Sip qw(add_field);
use C4::Biblio;
use C4::Circulation;
use C4::Context;
use C4::Debug;
use C4::Items;
use C4::Members;
use C4::Reserves;
@ -372,7 +371,6 @@ sub available {
my ($self, $for_patron) = @_;
my $count = (defined $self->{pending_queue}) ? scalar @{$self->{pending_queue}} : 0;
my $count2 = (defined $self->{hold_attached} ) ? scalar @{$self->{hold_attached} } : 0;
$debug and print STDERR "availability check: pending_queue size $count, hold_attached size $count2\n";
if (defined($self->{borrowernumber})) {
($self->{borrowernumber} eq $for_patron) or return 0;
return ($count ? 0 : 1);

5
C4/SIP/ILS/Patron.pm

@ -17,7 +17,6 @@ use Data::Dumper;
use C4::SIP::Sip qw(add_field maybe_add);
use C4::Debug;
use C4::Context;
use C4::Koha;
use C4::Members;
@ -53,7 +52,6 @@ sub new {
|| Koha::Patrons->find( { userid => $patron_id } );
}
$debug and warn "new Patron: " . Dumper($patron->unblessed) if $patron;
unless ($patron) {
siplog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
return;
@ -62,7 +60,6 @@ sub new {
my $pw = $kp->{password};
my $flags = C4::Members::patronflags( $kp );
my $debarred = $patron->is_debarred;
$debug and warn sprintf("Debarred = %s : ", ($debarred||'undef')); # Do we need more debug info here?
my ($day, $month, $year) = (localtime)[3,4,5];
my $today = sprintf '%04d-%02d-%02d', $year+1900, $month+1, $day;
my $expired = ($today gt $kp->{dateexpiry}) ? 1 : 0;
@ -134,7 +131,6 @@ sub new {
userid => $kp->{userid},
);
}
$debug and warn "patron fines: $ilspatron{fines} ... amountoutstanding: $kp->{amountoutstanding} ... CHARGES->amount: $flags->{CHARGES}->{amount}";
if ( $patron->is_debarred and $patron->debarredcomment ) {
$ilspatron{screen_msg} .= " -- " . $patron->debarredcomment;
@ -165,7 +161,6 @@ sub new {
$ilspatron{items} = \@barcodes;
$self = \%ilspatron;
$debug and warn Dumper($self);
siplog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id});
bless $self, $type;
return $self;

2
C4/SIP/ILS/Transaction/Checkin.pm

@ -12,7 +12,6 @@ use strict;
use C4::SIP::ILS::Transaction;
use C4::Circulation;
use C4::Debug;
use C4::Items qw( ModItemTransfer );
use C4::Reserves qw( ModReserveAffect );
use Koha::DateUtils qw( dt_from_string );
@ -90,7 +89,6 @@ sub do_checkin {
my $checkin_blocked_by_holds = $holds_block_checkin && $item->biblio->holds->count;
$debug and warn "do_checkin() calling AddReturn($barcode, $branch)";
( $return, $messages, $issue, $borrower ) =
AddReturn( $barcode, $branch, undef, $return_date )
unless $human_required || $checkin_blocked_by_holds;

11
C4/SIP/ILS/Transaction/Checkout.pm

@ -18,14 +18,10 @@ use C4::Context;
use C4::Circulation;
use C4::Members;
use C4::Reserves qw(ModReserveFill);
use C4::Debug;
use Koha::DateUtils;
use parent qw(C4::SIP::ILS::Transaction);
our $debug;
# Most fields are handled by the Transaction superclass
my %fields = (
security_inhibit => 0,
@ -40,8 +36,6 @@ sub new {
$self->{_permitted}->{$element} = $fields{$element};
}
@{$self}{keys %fields} = values %fields;
# $self->{'due'} = time() + (60*60*24*14); # two weeks hence
$debug and warn "new ILS::Transaction::Checkout : " . Dumper $self;
return bless $self, $class;
}
@ -54,7 +48,6 @@ sub do_checkout {
my $patron = Koha::Patrons->find($self->{patron}->{borrowernumber});
my $overridden_duedate; # usually passed as undef to AddIssue
my $prevcheckout_block_checkout = $account->{prevcheckout_block_checkout};
$debug and warn "do_checkout borrower: . " . $patron->borrowernumber;
my ($issuingimpossible, $needsconfirmation) = _can_we_issue($patron, $barcode, 0);
my $noerror=1; # If set to zero we block the issue
@ -77,7 +70,6 @@ sub do_checkout {
} elsif ($confirmation eq 'RESERVE_WAITING'
or $confirmation eq 'TRANSFERRED'
or $confirmation eq 'PROCESSING') {
$debug and warn "Item is on hold for another patron.";
$self->screen_msg("Item is on hold for another patron.");
$noerror = 0;
} elsif ($confirmation eq 'ISSUED_TO_ANOTHER') {
@ -123,13 +115,10 @@ sub do_checkout {
}
}
unless ($noerror) {
$debug and warn "cannot issue: " . Dumper($issuingimpossible) . "\n" . Dumper($needsconfirmation);
$self->ok(0);
return $self;
}
# can issue
$debug and warn sprintf("do_checkout: calling AddIssue(%s, %s, %s, 0)\n", $patron->borrowernumber, $barcode, $overridden_duedate)
. "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
my $issue = AddIssue( $patron->unblessed, $barcode, $overridden_duedate, 0 );
$self->{due} = $self->duedatefromissue($issue, $itemnumber);

5
C4/Scrubber.pm

@ -25,9 +25,6 @@ use Carp;
use HTML::Scrubber;
use C4::Context;
use C4::Debug;
my %scrubbertypes = (
default => {}, # place holder, default settings are below as fallbacks in call to constructor
@ -46,7 +43,6 @@ sub new {
if ( !exists $scrubbertypes{$type} ) {
croak "New called with unrecognized type '$type'";
}
$debug and carp "Building new Scrubber of type '$type'";
my $settings = $scrubbertypes{$type};
my $scrubber = HTML::Scrubber->new(
allow => exists $settings->{allow} ? $settings->{allow} : [],
@ -65,7 +61,6 @@ __END__
=head1 C4::Sanitize
Standardized wrapper with settings for building HTML::Scrubber tailored to various koha inputs.