Subject: | Silent warnings |
Hello.
I use very useful HTML::CalendarMonth in my web app.
It's worried about only one, When looking at the log, It is that the repeated warning messages.
Use of uninitialized value $today in numeric lt (<) at /home/bokutin/perl5/perlbrew/perls/5.16.3-threaded/lib/site_perl/5.16.3/HTML/CalendarMonth.pm line 319.
Use of uninitialized value $today in numeric eq (==) at /home/bokutin/perl5/perlbrew/perls/5.16.3-threaded/lib/site_perl/5.16.3/HTML/CalendarMonth.pm line 322.
Use of uninitialized value $html[14] in join or string at /home/bokutin/perl5/perlbrew/perls/5.16.3-threaded/lib/site_perl/5.16.3/HTML/Element.pm line 1089.
Use of uninitialized value $html[14] in join or string at /home/bokutin/perl5/perlbrew/perls/5.16.3-threaded/lib/site_perl/5.16.3/HTML/Element.pm line 1089.
Based on the latest version of HTML-CalendarMonth and HTML-CalendarMonth,
warning should not be shown in the local, I was corrected.
% uncpan http://search.cpan.org/CPAN/authors/id/M/MS/MSISK/HTML-CalendarMonth-1.26.tar.gz
% ( vim & git commit )
% git show
diff --git a/lib/HTML/CalendarMonth.pm b/lib/HTML/CalendarMonth.pm
index e618ffd..0eee67c 100644
--- a/lib/HTML/CalendarMonth.pm
+++ b/lib/HTML/CalendarMonth.pm
@@ -314,7 +314,7 @@ sub _gencal {
if $self->head_week;
}
- if ($self->semantic_css) {
+ if ($self->semantic_css and defined $self->today) {
my $today = $self->today;
if ($today < 0) {
$self->item($self->days)->push_attr(class => 'hcm-past');
diff --git a/t/30_silent_warn.t b/t/30_silent_warn.t
new file mode 100644
index 0000000..e92e0d9
--- /dev/null
+++ b/t/30_silent_warn.t
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+use strict;
+use FindBin;
+use lib $FindBin::RealBin;
+
+use Test::More;
+use Test::FailWarnings;
+use HTML::CalendarMonth;
+
+my ($last_month_y, $last_month_m) = do {
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+ (1900+$year, $mon);
+};
+my $cal = HTML::CalendarMonth->new( year => $last_month_y, month => $last_month_m, head_y => 0, semantic_css => 1 );
+$cal->as_HTML;
+
+ok 1;
+
+done_testing;
% uncpan http://search.cpan.org/CPAN/authors/id/M/MS/MSISK/HTML-Element-Extended-1.18.tar.gz
% ( vim & git commit )
% git show
diff --git a/lib/HTML/ElementSuper.pm b/lib/HTML/ElementSuper.pm
index e861090..c16f6f1 100644
--- a/lib/HTML/ElementSuper.pm
+++ b/lib/HTML/ElementSuper.pm
@@ -462,7 +462,7 @@ sub replace_with {
sub FETCH {
my($self, $k) = @_;
- return if $self->{mask} && !$self->{cloning};
+ return '' if $self->{mask} && !$self->{cloning};
$self->{_array}[$k];
}
In my environment, in the modification of the above, warn is no longer displayed.
I would appreciate if you would consider the uptake of code if it is good.
Sincerely yours,
Tomohiro Hosaka