From 9d5b154b691cb5491dcf37795eeddf8fa98d5052 Mon Sep 17 00:00:00 2001 From: Milan Date: Fri, 18 Nov 2022 23:13:08 +0100 Subject: [PATCH] lib/calcms: remove debug code --- lib/calcms/audio_recordings.pm | 2 -- lib/calcms/auth.pm | 22 ---------------------- lib/calcms/calendar.pm | 17 ----------------- lib/calcms/comments.pm | 5 ----- lib/calcms/db.pm | 23 +---------------------- lib/calcms/event_history.pm | 2 -- lib/calcms/events.pm | 18 ------------------ lib/calcms/localization.pm | 2 -- lib/calcms/log.pm | 14 -------------- lib/calcms/params.pm | 5 ----- lib/calcms/password_requests.pm | 2 -- lib/calcms/playout.pm | 2 -- lib/calcms/project.pm | 2 -- lib/calcms/series.pm | 3 --- lib/calcms/series_dates.pm | 2 -- lib/calcms/series_events.pm | 2 -- lib/calcms/series_schedule.pm | 2 -- lib/calcms/startup.pl | 2 +- lib/calcms/studio_timeslot_dates.pm | 2 -- lib/calcms/studio_timeslot_schedule.pm | 2 -- lib/calcms/studios.pm | 2 -- lib/calcms/template.pm | 2 +- lib/calcms/uac.pm | 2 -- lib/calcms/user_day_start.pm | 2 -- lib/calcms/user_default_studios.pm | 2 -- lib/calcms/user_selected_events.pm | 2 -- lib/calcms/user_sessions.pm | 2 -- lib/calcms/user_settings.pm | 2 -- lib/calcms/user_stats.pm | 2 -- lib/calcms/work_dates.pm | 2 -- lib/calcms/work_schedule.pm | 2 -- 31 files changed, 3 insertions(+), 150 deletions(-) diff --git a/lib/calcms/audio_recordings.pm b/lib/calcms/audio_recordings.pm index ba12b8b..c9a77e0 100644 --- a/lib/calcms/audio_recordings.pm +++ b/lib/calcms/audio_recordings.pm @@ -16,8 +16,6 @@ our @EXPORT_OK = qw(get_columns get); # mastered, processed # audioDuration, eventDuration, rmsLeft, rmsRight -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/auth.pm b/lib/calcms/auth.pm index 99a4dff..3df3fb7 100644 --- a/lib/calcms/auth.pm +++ b/lib/calcms/auth.pm @@ -16,15 +16,10 @@ use user_sessions (); our @EXPORT_OK = qw(get_user login logout crypt_password); my $defaultExpiration = 60; -my $debug = 0; -sub debug($); - #TODO: remove CGI sub get_user($$$) { my ($config, $params, $cgi) = @_; - debug("get_user") if $debug; - # login or logout on action if ( defined $params->{authAction} ) { if ( $params->{authAction} eq 'login' ) { @@ -74,7 +69,6 @@ sub login($$$) { my $config = shift; my $user = shift; my $password = shift; - debug("login") if $debug; my $result = authenticate( $config, $user, $password ); @@ -96,7 +90,6 @@ sub logout($$) { my $cgi = shift; my $session_id = read_cookie(); - debug("logout") if $debug; unless ( delete_session($config, $session_id) ) { return show_login_form( 'Cant delete session', 'logged out' ); } @@ -127,14 +120,10 @@ sub create_cookie($$) { } sub read_cookie() { - debug("read_cookie") if $debug; my %cookie = CGI::Cookie->fetch; - debug( "cookies: " . Dumper( \%cookie ) ) if $debug; my $cookie = $cookie{'sessionID'}; - debug( "cookie: " . $cookie ) if $debug; return undef unless defined $cookie; my $session_id = $cookie->value || undef; - debug( "sid: " . $session_id ) if $debug; return $session_id; } @@ -142,7 +131,6 @@ sub read_cookie() { sub delete_cookie($) { my $cgi = shift; - debug("delete_cookie") if $debug; my $cookie = $cgi->cookie( -name => 'sessionID', -value => '', @@ -159,8 +147,6 @@ sub create_session ($$$) { my $user = shift; my $timeout = shift; - debug("create_session") if $debug; - my $session_id = user_sessions::start( $config, { user => $user, @@ -189,7 +175,6 @@ sub delete_session($$) { my $config = shift; my $session_id = shift; - debug("delete_session") if $debug; return undef unless defined $session_id; user_sessions::stop( $config, { session_id => $session_id } ); @@ -249,7 +234,6 @@ sub show_login_form ($$) { }; } - debug("show_login_form") if $debug; print qq{Content-type:text/html @@ -377,11 +361,5 @@ sub show_login_form ($$) { return undef; } -sub debug ($) { - my $message = shift; - print STDERR "$message\n" if $debug > 0; - return; -} - #do not delete last line! 1; diff --git a/lib/calcms/calendar.pm b/lib/calcms/calendar.pm index 7a3c188..cb5b070 100644 --- a/lib/calcms/calendar.pm +++ b/lib/calcms/calendar.pm @@ -17,16 +17,12 @@ sub init() { } sub get_cached_or_render($$$) { - # my $output = $_[0] my $config = $_[1]; my $request = $_[2]; my $parms = $request->{params}->{checked}; - my $debug = $config->{system}->{debug}; - my $calendar = calendar::get( $config, $request ); - calendar::render( $_[0], $config, $request, $calendar ); } @@ -35,8 +31,6 @@ sub get($$) { my $request = shift; my $params = $request->{params}->{checked}; - my $debug = $config->{system}->{debug}; - my $language = $config->{date}->{language} || 'en'; my $date = $params->{date} || ''; @@ -287,10 +281,7 @@ sub render($$$$) { my $calendar = $_[3]; my $parms = $request->{params}->{checked}; - my $debug = $config->{system}->{debug}; - my $template_parameters = $calendar; - $template_parameters->{debug} = $config->{system}->{debug}; $template_parameters->{base_url} = $config->{locations}->{base_url}; $template_parameters->{cache_base_url} = $config->{cache}->{base_url}; $template_parameters->{server_cache} = $config->{cache}->{server_cache} if ( $config->{cache}->{server_cache} ); @@ -305,8 +296,6 @@ sub get_calendar_weeks($$$) { my $start = shift; my $end = shift; - my $debug = $config->{system}->{debug}; - $start = time::date_to_array($start); $end = time::date_to_array($end); @@ -460,17 +449,11 @@ sub check_params($$) { my $template = template::check( $config, $params->{template}, 'calendar.html' ); - my $debug = $params->{debug}; - if ( ( defined $debug ) && ( $debug =~ /([a-z\_\,]+)/ ) ) { - $debug = $1; - } - return { template => $template, date => $date, from_date => $from_date, till_date => $till_date, - debug => $debug, month_only => $month_only, open_end => $open_end, start_date => $start_date, diff --git a/lib/calcms/comments.pm b/lib/calcms/comments.pm index f4957fa..e6c1991 100644 --- a/lib/calcms/comments.pm +++ b/lib/calcms/comments.pm @@ -623,11 +623,6 @@ sub check_params ($$) { $comment->{type} = 'tree'; } - my $debug = $params->{debug} || ''; - if ( $debug =~ /([a-z\_\,]+)/ ) { - $comment->{debug} = $1; - } - log::error( $config, 'missing parameter a' ) if ( defined $params->{limit} ) && ( $comment->{limit} eq '' ); log::error( $config, 'missing parameter b' ) if ( defined $params->{event_id} ) && ( $comment->{event_id} eq '' ); log::error( $config, 'missing parameter c' ) diff --git a/lib/calcms/db.pm b/lib/calcms/db.pm index 2b937d0..a40b00a 100644 --- a/lib/calcms/db.pm +++ b/lib/calcms/db.pm @@ -20,10 +20,6 @@ our @EXPORT_OK = qw( $read ); -#debug settings -my $debug_read = 0; -my $debug_write = 0; - #database control our $read = 1; our $write = 1; @@ -60,7 +56,7 @@ sub connect($;$) { put( $dbh, "set names utf8", undef ); put( $dbh, "set time_zone='" . $options->{date}->{time_zone} . "'", undef ); $request->{connection} = $dbh; - $options->{connections}->{$key} = $dbh; + #$options->{connections}->{$key} = $dbh; $connections->{$key} = $dbh; return $dbh; } @@ -90,11 +86,6 @@ sub get($$;$) { my $results = $sth->fetchall_arrayref({}); - if ( $debug_read == 1 ) { - print STDERR Dumper( $results->[0] ) . "\n" if ( scalar @$results == 1 ); - print STDERR @$results . "\n" if ( scalar @$results != 1 ); - } - $sth->finish; return $results; } @@ -125,12 +116,6 @@ sub insert ($$$){ my @bind_values = map { $entry->{$_} } @keys; my $sql = "insert into $table \n ($keys) \n values ($values);\n"; - - if ( $debug_write == 1 ) { - print STDERR $sql . "\n"; - print STDERR Dumper( \@bind_values ) . "\n" if scalar(@bind_values); - } - put( $dbh, $sql, \@bind_values ); my $result = get( $dbh, 'SELECT LAST_INSERT_ID() id;' ); return $result->[0]->{id} if $result->[0]->{id} > 0; @@ -141,11 +126,6 @@ sub insert ($$$){ sub put($$$) { my ($dbh, $sql, $bind_values) =@_; - if ( $debug_write == 1 ) { - print STDERR $sql . "\n"; - print STDERR Dumper($bind_values) . "\n" if defined $bind_values; - } - my $sth = $dbh->prepare($sql); if ( $write == 1 ) { if ( ( defined $bind_values ) && ( ref($bind_values) eq 'ARRAY' ) ) { @@ -155,7 +135,6 @@ sub put($$$) { } } $sth->finish; - print STDERR "1\n" if ( $debug_write == 1 ); my $result = get( $dbh, 'SELECT ROW_COUNT() changes;' ); return $result->[0]->{changes} if $result->[0]->{changes} > 0; diff --git a/lib/calcms/event_history.pm b/lib/calcms/event_history.pm index 405958f..591a9fd 100644 --- a/lib/calcms/event_history.pm +++ b/lib/calcms/event_history.pm @@ -9,8 +9,6 @@ use Data::Dumper; #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get get_by_id insert insert_by_event_id delete); -sub debug; - sub get_columns ($){ my $config = shift; diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index 77bb333..9bfa252 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -47,8 +47,6 @@ sub get_cached_or_render($$$) { my ($response, $config, $request) = @_; my $params = $request->{params}->{checked}; - my $debug = $config->{system}->{debug}; - my $results = events::get( $config, $request ); events::render( $response, $config, $request, $results ); return $response; @@ -105,8 +103,6 @@ sub get($$); sub get($$) { my ($config, $request) = @_; - my $debug = $config->{system}->{debug}; - my $dbh = db::connect( $config, $request ); ( my $query, my $bind_values ) = events::get_query( $dbh, $config, $request ); @@ -136,7 +132,6 @@ sub modify_results ($$$$) { my $projects = {}; my $studios = {}; - # print $running_event_id." ".$running_events->[0]->{start}." ".$running_events->[0]->{title} if ($debug ne''); my $time_diff = ''; if ( scalar @$results > 0 ) { $results->[0]->{__first__} = 1; @@ -871,8 +866,6 @@ sub get_query($$$) { my ($dbh, $config, $request) = @_; my $params = $request->{params}->{checked}; - my $debug = $config->{system}->{debug}; - $params->{recordings} = '' unless defined $params->{recordings}; my $bind_values = []; @@ -1209,12 +1202,9 @@ sub render($$$$;$) { $params->{$param} = $root_params->{$param}; } } - my $debug = $config->{system}->{debug}; - my %tparams = %$params; my $tparams = \%tparams; $tparams->{events} = $results; - $tparams->{debug} = $debug; $tparams->{server_cache} = $config->{cache}->{server_cache} if ( $config->{cache}->{server_cache} ); $tparams->{use_client_cache} = $config->{cache}->{use_client_cache} @@ -1520,8 +1510,6 @@ sub delete ($$$) { my $event_id = shift; my $params = $request->{params}->{checked}; - my $debug = $config->{system}->{debug}; - my $dbh = db::connect($config); my $query = 'delete from calcms_events where id=?'; @@ -1768,11 +1756,6 @@ sub check_params ($$) { my $project_id = $params->{project_id} || ''; my $studio_id = $params->{studio_id} || ''; - my $debug = $params->{debug} || ''; - if ( $debug =~ /([a-z\_\,]+)/ ) { - $debug = $1; - } - my $json_callback = $params->{json_callback} || ''; if ( $json_callback ne '' ) { $json_callback =~ s/[^a-zA-Z0-9\_]//g; @@ -1806,7 +1789,6 @@ sub check_params ($$) { title => $title, event_id => $event_id, search => $search, - debug => $debug, archive => $archive, last_days => $last_days, order => $order, diff --git a/lib/calcms/localization.pm b/lib/calcms/localization.pm index ad9bc42..74f277d 100644 --- a/lib/calcms/localization.pm +++ b/lib/calcms/localization.pm @@ -11,8 +11,6 @@ use user_settings(); #use base 'Exporter'; our @EXPORT_OK = qw(get getJavascript); -sub debug; - # get localisation # file : po file # language : get for selected language diff --git a/lib/calcms/log.pm b/lib/calcms/log.pm index a4df952..7f7147f 100644 --- a/lib/calcms/log.pm +++ b/lib/calcms/log.pm @@ -19,20 +19,6 @@ sub error($$) { print STDERR "missing config at log::error\n"; die(); } - - #do not call template::check to avoid deep recursion! - if ( $config->{system}->{debug} ) { - - template::process( - $config, 'print', - 'templates/default.html', - { - static_files_url => $config->{locations}->{static_files_url}, - error => $message - } - ); - } - die(); } diff --git a/lib/calcms/params.pm b/lib/calcms/params.pm index 1456792..6398fb4 100644 --- a/lib/calcms/params.pm +++ b/lib/calcms/params.pm @@ -10,7 +10,6 @@ use Apache2::Request(); #use base 'Exporter'; our @EXPORT_OK = qw(get isJson); -sub debug; my $isJson = 0; sub isJson () { @@ -62,9 +61,5 @@ sub get ($) { return ( $cgi, $params, $status ); } -sub debug ($) { - my $message = shift; -} - #do not delete last line! 1; diff --git a/lib/calcms/password_requests.pm b/lib/calcms/password_requests.pm index 014da3c..f7e8789 100644 --- a/lib/calcms/password_requests.pm +++ b/lib/calcms/password_requests.pm @@ -16,8 +16,6 @@ use uac; use db; use auth; -sub debug; - sub get_columns ($) { my $config = shift; diff --git a/lib/calcms/playout.pm b/lib/calcms/playout.pm index 9020fe5..ec2aa03 100644 --- a/lib/calcms/playout.pm +++ b/lib/calcms/playout.pm @@ -13,8 +13,6 @@ use series_events(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get sync); -sub debug; - sub get_columns ($) { my $config = shift; diff --git a/lib/calcms/project.pm b/lib/calcms/project.pm index e309b10..9462e3e 100644 --- a/lib/calcms/project.pm +++ b/lib/calcms/project.pm @@ -22,8 +22,6 @@ our @EXPORT_OK = qw( #TODO: globally replace get_studios by get_studio_assignments -sub debug; - # get project columns sub get_columns ($) { my $config = shift; diff --git a/lib/calcms/series.pm b/lib/calcms/series.pm index 3ccff0d..1ece629 100644 --- a/lib/calcms/series.pm +++ b/lib/calcms/series.pm @@ -26,8 +26,6 @@ our @EXPORT_OK = qw( #TODO: remove studio_id #TODO: get project_id, studio_id by join with project_series -sub debug; - # get series columns sub get_columns ($) { my $config = shift; @@ -442,7 +440,6 @@ sub search_events ($$$) { permissions => $request->{permissions} }; - #my $debug=1; my $events = events::get( $config, $request2 ); return $events; } diff --git a/lib/calcms/series_dates.pm b/lib/calcms/series_dates.pm index a241212..a7c308c 100644 --- a/lib/calcms/series_dates.pm +++ b/lib/calcms/series_dates.pm @@ -19,8 +19,6 @@ use series_schedule(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete get_dates get_series); -sub debug; - sub get_columns ($) { my $config = shift; diff --git a/lib/calcms/series_events.pm b/lib/calcms/series_events.pm index 0e30605..a935e68 100644 --- a/lib/calcms/series_events.pm +++ b/lib/calcms/series_events.pm @@ -32,8 +32,6 @@ our @EXPORT_OK = qw( set_playout_status ); -sub debug; - # update main fields of the event by id # do not check for project,studio,series # all changed columns are returned for history handling diff --git a/lib/calcms/series_schedule.pm b/lib/calcms/series_schedule.pm index f0364af..1e0064b 100644 --- a/lib/calcms/series_schedule.pm +++ b/lib/calcms/series_schedule.pm @@ -21,8 +21,6 @@ use series_dates(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete); -sub debug; - sub get_columns ($) { my $config = shift; diff --git a/lib/calcms/startup.pl b/lib/calcms/startup.pl index 85080c5..866171d 100644 --- a/lib/calcms/startup.pl +++ b/lib/calcms/startup.pl @@ -1,7 +1,7 @@ use lib qw(/home/radio/calcms/calcms/); use Data::Dumper; -use Apache::DBI(); +#use Apache::DBI(); use Time::Local(); use Date::Calc(); use Calendar::Simple qw(date_span); diff --git a/lib/calcms/studio_timeslot_dates.pm b/lib/calcms/studio_timeslot_dates.pm index 39dc4fb..9a844d2 100644 --- a/lib/calcms/studio_timeslot_dates.pm +++ b/lib/calcms/studio_timeslot_dates.pm @@ -15,8 +15,6 @@ use time(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete get_dates); -sub debug; - sub get_columns ($){ my $config = shift; diff --git a/lib/calcms/studio_timeslot_schedule.pm b/lib/calcms/studio_timeslot_schedule.pm index 4bdd78a..003ddaf 100644 --- a/lib/calcms/studio_timeslot_schedule.pm +++ b/lib/calcms/studio_timeslot_schedule.pm @@ -13,8 +13,6 @@ use studio_timeslot_dates(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete); -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/studios.pm b/lib/calcms/studios.pm index 9e9d64b..17069c1 100644 --- a/lib/calcms/studios.pm +++ b/lib/calcms/studios.pm @@ -10,8 +10,6 @@ use images(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get get_by_id insert update delete check check_studio); -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/template.pm b/lib/calcms/template.pm index aff87bc..715f042 100644 --- a/lib/calcms/template.pm +++ b/lib/calcms/template.pm @@ -53,7 +53,7 @@ sub process($$$$) { $params->{jobs} = roles::get_user_jobs($config); if ( ( $filename =~ /json\-p/ ) || (params::isJson) ) { my $header = "Content-type:application/json; charset=utf-8\n\n"; - my $json = JSON::to_json( $params, { pretty => 1 } ); + my $json = JSON->new->pretty(1)->canonical()->encode($params); $json = $header . $params->{json_callback} . $json; if ( ( defined $_[1] ) && ( $_[1] eq 'print' ) ) { diff --git a/lib/calcms/uac.pm b/lib/calcms/uac.pm index b2c3a4d..9dc1f06 100644 --- a/lib/calcms/uac.pm +++ b/lib/calcms/uac.pm @@ -28,8 +28,6 @@ our @EXPORT_OK = qw( permission_denied ); -sub debug; - # get user by name sub get_user($$) { my $config = shift; diff --git a/lib/calcms/user_day_start.pm b/lib/calcms/user_day_start.pm index 34dce6a..9fce22e 100644 --- a/lib/calcms/user_day_start.pm +++ b/lib/calcms/user_day_start.pm @@ -9,8 +9,6 @@ use Data::Dumper; # table: calcms_user_day_start # columns: user, project_id, studio_id, series_id, day_start -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/user_default_studios.pm b/lib/calcms/user_default_studios.pm index 64816e4..4d2e619 100644 --- a/lib/calcms/user_default_studios.pm +++ b/lib/calcms/user_default_studios.pm @@ -9,8 +9,6 @@ use Data::Dumper; # table: calcms_user_default_studios # columns: user, project_id, studio_id -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/user_selected_events.pm b/lib/calcms/user_selected_events.pm index a8a36da..052def5 100644 --- a/lib/calcms/user_selected_events.pm +++ b/lib/calcms/user_selected_events.pm @@ -11,8 +11,6 @@ use Data::Dumper; # project_studio_filter, series_filter <- optional filter params # selected_project, selected_studio, selected_series, selected_event <-result -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/user_sessions.pm b/lib/calcms/user_sessions.pm index e826d4a..ef3917a 100644 --- a/lib/calcms/user_sessions.pm +++ b/lib/calcms/user_sessions.pm @@ -21,8 +21,6 @@ use time; #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete); -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/user_settings.pm b/lib/calcms/user_settings.pm index 1881cf2..6ca6da8 100644 --- a/lib/calcms/user_settings.pm +++ b/lib/calcms/user_settings.pm @@ -12,8 +12,6 @@ use series_dates(); #use base 'Exporter'; our @EXPORT_OK = qw(getColors getColorCss get insert update delete get_columns defaultColors); -sub debug; - our $defaultColors = [ { name => 'color_event', diff --git a/lib/calcms/user_stats.pm b/lib/calcms/user_stats.pm index b29571c..afd50af 100644 --- a/lib/calcms/user_stats.pm +++ b/lib/calcms/user_stats.pm @@ -8,8 +8,6 @@ use Data::Dumper; #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get update insert get_stats increase); -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/work_dates.pm b/lib/calcms/work_dates.pm index 765edb1..4cb361d 100644 --- a/lib/calcms/work_dates.pm +++ b/lib/calcms/work_dates.pm @@ -19,8 +19,6 @@ use work_schedule(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete get_dates); -sub debug; - sub get_columns($) { my $config = shift; diff --git a/lib/calcms/work_schedule.pm b/lib/calcms/work_schedule.pm index 52c7002..56bff79 100644 --- a/lib/calcms/work_schedule.pm +++ b/lib/calcms/work_schedule.pm @@ -20,8 +20,6 @@ use series_dates(); #use base 'Exporter'; our @EXPORT_OK = qw(get_columns get insert update delete); -sub debug; - sub get_columns($) { my $config = shift;