Subject: | Net-Google-Calendar-Entry dies when entry->when not defined. |
When a calendar entry is repeating and has no when element, the code
dies attempting to read the when entry. I was able to fix it on my
local copy by changing subroutine _attribute_get in
Net::Google::Calendar::Entry.pm
sub _attribute_get {
my ($self, $ns, $what, $key) = @_;
my $elem = $self->_my_get($self->{_gd_ns}, $what, $key);
# was: if ($elem->hasAttribute($key)) {
if ($elem&&$elem->hasAttribute($key)) {
return $elem->getAttribute($key);
} else {
return $elem;
}
}
I am using perl v5.10.0 built for i386-linux-thread-multi with
Net-Google-Calendar v0.95 .
sample snippet that evoked the error:
$cal->set_calendar($c);
for my $event ($cal->get_events ) {
print $event->title."\n";
print $event->content->body."\n";
print $event->author->name,"\n";
print $event->author->email,"\n";
print $event->category,"\n";
print $event->published,"\n";
print $event->updated,"\n";
if (defined $event->when) {
my @r=$event->when ;
for my $d (@r ) {
print Dumper($d);
print $d->datetime,"\n";
}
}
print "*****\n\n";
}
last;
}
Output log:
Birthday Reminder for foo
Phil Durbin
phildrbn@gmail.com
XML::Atom::Category=HASH(0x936e588)
2008-12-09T15:39:04.000Z
2008-12-09T15:39:04.000Z
Can't call method "hasAttribute" on an undefined value at
/usr/lib/perl5/vendor_perl/5.10.0/Net/Google/Calendar/Entry.pm line 184.