Subject: | BUG: $item->guid() returns link value instead of actual guid |
Date: | Fri, 18 Nov 2011 18:48:12 +0400 |
To: | bug-xml-feedpp [...] rt.cpan.org |
From: | Никулин Юрий <ynikulin [...] yandex.ru> |
Bug description: $item->guid() returns link value instead of actual guid.
Distribution name and version: XML::FeddPP 0.43
Perl version: v5.8.8 (propably all)
Operating System vendor and version: all
How to reproduce
use XML::FeedPP;
my $source = <<EOF;
<rss version="2.0">
<channel>
<title>Title of the site</title>
<link>http://www.kawa.net/</link>
<copyright>Owner of the site</copyright>
<language>ja</language>
<pubDate>Mon, 02 Jan 2006 03:04:05 +0600</pubDate>
<description>Description of the site</description>
<item>
<title>The Perl Directory - perl.org</title>
<link>http://www.perl.org/</link>
<author isPermaLink="false">Author</author>
<category>Category of the first item</category>
<guid isPermaLink="true">http://www.ru</guid>
<pubDate>Sun, 11 Dec 2005 10:09:08 -0700</pubDate>
<description>Description of the first item</description>
</item>
</channel>
</rss>
EOF
my $feed = XML::FeedPP::RSS->new();
$feed->merge($source);
my @items = $feed->get_item();
print 'GUID is "' . $items[0]->guid() . '", expected "http://www.ru"' . "\n";
Possible patch
--- /usr/lib/perl5/site_perl/5.8.8/XML/FeedPP.pm 2011-11-16 15:13:06.000000000 +0400
+++ /home/nikulin/cpanlib/XML/FeedPP.pm 2011-11-16 15:11:14.000000000 +0400
@@ -2571,7 +2571,7 @@
my $map = { map { $_ => 1 } @_ };
foreach my $key ( keys %$merge ) {
next if exists $map->{$key};
- next if exists $base->{$key};
+ next if exists $base->{$key} && $base->{$key} ne 'guid' && !$merge->{$key};
$base->{$key} = $merge->{$key};
}
}