If I set a feed to "Update existing aggregation items" it throws an error when aggregation items are updated from the RSS feed, the error looks like this:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'574736065\', fid = 436, image_id = 0, image_guid = '0', aggregation_item_optio' at line 1 query: UPDATE aggregation_item SET url = 'http://thesuperficial.com/2008/01/amy_winehouse_jogs_with_nugget.php', original_author = 'The Superficial', story_guid = \'574736065\', fid = 436, image_id = 0, image_guid = '0', aggregation_item_options = 's:74:\"a:2:{s:20:\"link_to_original_url\";i:1;s:24:\"link_to_original_comment\";i:0;}\";' , original_comments = \http://thesuperficial.com/images/amy_winehouse_jogs_.jpg\' WHERE nid = 1436 in /Public/http/drupal/includes/database.mysql.inc on line 172.

Comments

longtailweb’s picture

ditto to the error message. Don't know what is causing it yet. Only happens to me when I am admin and right after running cron.php.

I did notice that I am getting multiple aggregation_items created for the same feed items. Not sure if these are related.

longtailweb’s picture

Not sure if it is the cause, but I noticed in the code for aggregation.module the following,

* Implementation of hook_update().
*/

function aggregation_item_update($node)
{
db_query("UPDATE {aggregation_item} SET url = '%s', original_author = '%s', ".
"%s fid = %d, image_id = %d, image_guid = '%s', aggregation_item_options = '%s' %s ".

I changed the aggregation_items_options entries to include ' ' around the %s variable. I haven't received the error message yet, but not sure if this is the reason why.

So, now my code looks like
aggregation_item_options = '%s' '%s' ".

longtailweb’s picture

Spoke too soon. Received teh error message again.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'4563119\', fid = 212, image_id = 0, image_guid = '0', aggregation_item_options' at line 1 query: UPDATE xjzaggregation_item SET url = 'http://blog.myspace.com/index.cfm?fuseaction=blog.view&friendID=94969566...', original_author = 'Randy - MySpace Blog', story_guid = \'4563119\', fid = 212, image_id = 0, image_guid = '0', aggregation_item_options = 's:74:\"a:2:{s:20:\"link_to_original_url\";i:1;s:24:\"link_to_original_comment\";i:1;}\";' ', original_comments = \'http://blog.myspace.com/index.cfm?fuseaction=blog.view&friendID=94969566...\'' WHERE nid = 431 in /includes/database.mysql.inc on line 172.

longtailweb’s picture

This query has a few things I don't understand,
db_query("UPDATE {aggregation_item} SET url = '%s', original_author = '%s', ".
"%s fid = %d, image_id = %d, image_guid = '%s', aggregation_item_options = '%s' %s ".
"WHERE nid = %d", $node->url, $node->original_author, $node->story_guid === '' ? '' : "story_guid = '{$node->story_guid}',", $node->fid, $node->image_id, $node->image_guid ? $node->image_guid : 0, $node->aggregation_item_options, trim($node->original_comments) == '' ? '' : ", original_comments = '".trim($node->original_comments)."'", $node->nid);

Why is there an extra %s at the beginning of the second line of the query? It seems like it shouldn't be there.

Also not sure about how the comments are working, there are two %s at the end of the second line, and I'm not sure what is being accomplished by this.

longtailweb’s picture

After looking in the database, I see the hook_insert puts a story_guid for each item, but update doesn't contain the story_guid field. So, I added story_guid to the update field where the extra variable was. Not sure if this fixed it, but doesn't seem like the query would have worked otherwise.

longtailweb’s picture

Well, heck.
$node->story_guid === '' ? '' : "story_guid = '{$node->story_guid}'

This places the story_guid = in the update query if story_guid is blank, or something. I don't really understand it.
But, it seems to explain why the story_guid was missing and that I should probably remove it from the database query.

I'll leave it until I get another error message, but I fully expect one.

Ashraf Amayreh’s picture

:) I couldn't really test many feeds for update because I didn't have a feed that updated its items. So this branch seems to have been left without much testing as updating existing items didn't seem to be used often.

I'll take a look at this in the coming weekend, I expect it's a very trivial error. if someone can point me to feeds they use that give them this error this would be ideal. Sorry for taking long on what seems to be a serious issue. But I was, and is still actually, so busy I can't find the time to scratch my head.

longtailweb’s picture

List of Blog/Website Feeds used for WiseReunion.com

You can view the above page for my list of feeds. Also, here are two I tested against most,

http://www.landwatch.com/default.aspx?ct=r&type=5%2C75%3B6%2C1158&so=d&s...
http://buyit.dfw.com/findit/search/rss_search.jsp?sort=modifieddate&sort...

The landwatch.com feed I used because I modified code to capture the Feed's Logo image and display it. I may have done this poorly, but I don't think it caused the problem above. I've had the SQL error problem since the first day of installation, but I didn't troubleshoot till now cause i wasn't concerned.

Additionally, I have another problem that may or not be related. I have tons of duplicate items being created when cron is run. This certainly might be because of changes I made, and I haven't troubleshot it yet. But, I wanted to mention in case it was related.

I haven't seen the SQL error message since I made the code change above, but I'm not sure if that caused the Duplication problem.

longtailweb’s picture

I've changed my sql query back to your original minus the ' ' surrounding the node->story_guid in the variables part of the query.
Here is what i have now:

db_query("UPDATE {aggregation_item} SET url = '%s', original_author = '%s', ".
"%s fid = %d, image_id = %d, image_guid = '%s', aggregation_item_options = '%s' %s ".
"WHERE nid = %d", $node->url, $node->original_author, $node->story_guid === '' ? '' : "story_guid = {$node->story_guid},", $node->fid, $node->image_id, $node->image_guid ? $node->image_guid : 0, $node->aggregation_item_options, trim($node->original_comments) == '' ? '' : ", original_comments = '".trim($node->original_comments)."'", $node->nid);

I have rerun cron several times and no longer receive the error message like before. Not sure if the problem is fixed but I don't receive the error message any more. Now, I'm still looking into why I was getting multiple entries for each feed item, but this probably has more to do with my changes than anything else.

I'll keep you updated on my progress.

longtailweb’s picture

my duplication of feed items issue was unrelated to you code and was related to code I added to pull feed logo images from feeds.

Boiling my ridiculously long comments above down, the only change I made that I stuck with was removing the ' ' from story_guid = '{$node->story_guid}'

I have no error messages, and everything works like it should for me, I think.

Ashraf Amayreh’s picture

Assigned: Unassigned » Ashraf Amayreh
Status: Active » Closed (fixed)

Well, I did find something wrong here. Fixed in the upcoming new release.