Subject: | Empty summary is added when convert() is called |
The convert() call simply checks the defined-ness of various,
attributes, but some of them may be returning XML::Feed::Content
objects, which could be wrapping an undef body.
I've attached a patch with a test for the problem, as well as a fix
(it's one line).
Subject: | xml-feed.patch |
diff -rNu XML-Feed-0.12.orig/lib/XML/Feed/Entry.pm XML-Feed-0.12/lib/XML/Feed/Entry.pm
--- XML-Feed-0.12.orig/lib/XML/Feed/Entry.pm 2007-09-30 18:16:59.000000000 -0500
+++ XML-Feed-0.12/lib/XML/Feed/Entry.pm 2007-09-30 18:26:13.000000000 -0500
@@ -4,6 +4,8 @@
use strict;
use base qw( Class::ErrorHandler );
+use Scalar::Util qw( blessed );
+
use Carp;
sub wrap {
@@ -35,6 +37,7 @@
for my $field (qw( title link content summary category author id issued modified )) {
my $val = $entry->$field();
next unless defined $val;
+ next if blessed $val && $val->isa('XML::Feed::Content') && ! defined $val->body;
$new->$field($val);
}
$new;
diff -rNu XML-Feed-0.12.orig/t/08-convert-summary-bug.t XML-Feed-0.12/t/08-convert-summary-bug.t
--- XML-Feed-0.12.orig/t/08-convert-summary-bug.t 1969-12-31 18:00:00.000000000 -0600
+++ XML-Feed-0.12/t/08-convert-summary-bug.t 2007-09-30 18:25:21.000000000 -0500
@@ -0,0 +1,23 @@
+# $Id$
+
+use strict;
+use Test::More tests => 1;
+use XML::Feed;
+use XML::Feed::Entry;
+
+my $feed = XML::Feed->new();
+$feed->title('My Feed');
+$feed->link('http://www.example.com/');
+$feed->description('Wow!');
+
+my $entry = XML::Feed::Entry->new();
+$entry->title('Foo Bar');
+$entry->link('http://www.example.com/foo/bar.html');
+$entry->content('This is the content, but there is no summary.');
+$entry->author('Foo Baz');
+
+$feed->add_entry($entry);
+
+
+unlike($feed->convert('Atom')->as_xml(), qr{<summary>},
+ 'no summary tag after converting to Atom');