I'm not sure why but

        // Check if the item already exists
        $duplicate = db_fetch_array(db_query("SELECT nid FROM {aggregator_node} WHERE guid = '%s'", $node['guid']));

isn't pulling the nid from the database. When I looked at the data visually it looked equal. Changing to

        // Check if the item already exists
        $duplicate = db_fetch_array(db_query("SELECT nid FROM {aggregator_node} WHERE link = '%s'", $node['link']));

resolved my issue but is this the correct fix?

Comments

budda’s picture

A guid is required because the link field is not guaranteed in items (especially with ATOM feeds) so your code will not work in all cases either.

can you display whe generated GUID and see what it looks like compared to ones already in the dbase for the same feed item?

Anonymous’s picture

As I said already I visually compared the GUID in the comparison string with the data in the DB and they look identical. It's probably a MySql thing with the GET data in the string; but I'm not savvy with that. I'll do some further digging. At least I was able to begin feeding affiliate data to my site.

Anonymous’s picture

The stored GUID contains prefixes that include a timestamp. The generated GUID will never match the database value because the generated GUID contains a new timestamp.

Anonymous’s picture

Well, it seems that my feed provider is generating a new date and time even though the item is the same. The feed is allowing me to publish affiliate product links and I doubt that I can influence them to make the changes. Should I look at providing a method for not using a timestamp in the feedmanager_generate_guid function? The feed input for would present the creator of the feed an option with the default to create the GUID with the timestamp.

Anonymous’s picture

@budda:

A guid is required because the link field is not guaranteed in items (especially with ATOM feeds) so your code will not work in all cases either.

But the LINK column in both the aggregator_node and aggregator_item tables is not allowed to be null and only aggregator_node contains the GUID column. I can see that maybe the link item can come from two different sources and the GUID makes it unique; is that correct? Otherwise if I can guarantee myself that the link is only from one source then GUID isn't important at all; correct?