Closed (outdated)
Project:
Feeds
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Oct 2010 at 18:02 UTC
Updated:
16 Jun 2016 at 22:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
alex_b commentedDo you map to node id?
Comment #2
jaarong commentedNo, I'm using the Feed importer that comes out of the box with Feeds, it has these mappings by default:
Title Title
Description Body
Published date Published date
Item URL (link) URL
Item GUID GUID
Comment #3
Bevan commentedThis bug is caused by the following code in
taxonomy_feeds_set_target();For new items this works fine. But nodes which already exist and are being updated, have the existing terms as objects in
$node->taxonomy.Because the above code does not check for the presence of the terms, each existing term gets added again and is found twice in
$node->taxonomy;$node->taxonomy['tags']Having the term found twice in
$node->taxonomycausestaxonomy_node_save()to attempt save the same node:term relationship twice, because it has no handling for this scenario.While Drupal core could handle this better in
taxonomy_node_save(), a fix for Drupal 6 or 7 is not likely to be accepted and will probably break other contrib modules. Additionally, the fix in Feeds is very simple;The attached patch fixes it bug by removing the
if ($vocabulary->tags) {}section so that all vocabularies are handled equally, regardless of whether the vocabulary is a tagging vocabulary or not. The patch looks more complicated than it is because all of the oldelse {}is indented one level less.Please excuse the SVN-not-CVS patch.
Comment #4
Bevan commentedThinking about this a little more, I believe this patch will cause Feeds to neglect a special case where a tag in the source does not already exist as a Drupal Term. Feeds has an (intentional?) feature by which it will create the term if the vocabulary is a tagging vocabulary, but not create the term if the vocabulary is not a tagging vocabulary. AFICT that feature depends on the use of
$node->taxonomy['tags'].I will test and report back
Comment #5
Bevan commentedI confirmed that the patch breaks that feature. I guess the better solution is to expand the
if ($vocabulary->tags) {}section to check for existing term objects and unsetting them if they are already in$node->taxonomy['tags']. This is quite messy though. Any better ideas?Comment #6
Bevan commentedThis patch reverts the previous patch (#3) and extends the
if ($vocabulary->tags) {}section to de-duplicate terms that are in both the$node->taxonomyand$node->taxonomy['tags']sections.Comment #7
bradjones1I'm running into a similar issue but is there any way to fix this without hacking core? Seems like a pretty major fix to what seems to be a module-specific issue.
Comment #8
Bevan commented@bradjones1,
This patch is for Feeds, not Drupal core. Also it not so much a dirty "hack" as opposed to a clean bug fix.
A patch in this issue will probably get committed to Feeds to fix the bug, so as long as you have a way to manage the patch in your code base and update/reapply it or merge it in when you next update Feeds, then it is a safe and clean "hack". On the other hand, the bug that this patch fixes does not cause any data loss, it only causes errors to be reported, so it's not a big deal if it gets lost in an upgrade.
Please review and test the patch if you are able. You can mark it "RTBC" if you are confident it is ready to be committed.
Comment #9
awlo commentedThe second patch works for me just fine.
@Bevan, when uploading files, please make sure they don't have special characters in them (spaces, a comma and a hash in this case), since now the links to patches are broken. To download or view them you have to encode them properly:
http://drupal.org/files/issues/933758%23comment-3925610%20Duplicate%20En...
Comment #10
cedarm commentedPatch from #6 works, but shouldn't the de-dup come after the array_merge()? Also, I think we can eliminate a nested loop and get array_diff_key() to do some of the work for us.
Patch a is a direct replacement for #6.
Patch b is rolled after new patch for #925264: Don't allow commas in tag names.
Comment #11
bradjones1@Bevan - apologies for my nonsensical reply... looking back at this post now I don't even know what I was talking about re: core. I'll try the patch. Thanks for your work on this.
Comment #12
jvieille commentedPatch #10 (a) works for me
Thanks
Comment #13
zazinteractive commentedThanks cedarm. 10a fixed it for me
EDIT: actually it reduced the number of duplicate key records but some are still there
Comment #14
Michsk commentedI tried 10B but i sometimes keep getting the error:
Duplicate entry '1103-18758' for key 'PRIMARY' query: INSERT INTO term_node (nid, vid, tid) VALUES (18744, 18758, 1103) in /var/www/vhosts/##.nl/httpdocs/modules/taxonomy/taxonomy.module op regel 713.I must say tough that after applying the patch i get a lot less of them then i did before.
After applying the patch, it looks like something is going wrong with the vocab. Because my path is [vocab-raw]/etcetc but the token does not recognize the vocab so the path stays [vocab-raw]
Comment #15
hyunkeln commentedApply this patch:
+ foreach ($terms as $k => $v) {
+ $alias = taxonomy_get_term_by_name($terms[$k]);
+ if(isset($alias[0]->name))
+ if($terms[$k]!=$alias[0]->name)
+ $terms[$k]=$alias[0]->name;
+ }
before line:
$terms = array_merge($terms, drupal_explode_tags($node->taxonomy['tags'][$vocabulary->vid]));
In file: feeds/mappers/taxonomy.inc
In order to ensure than the terms are new, the other patches fail when terms with special chars are used: español, méxico, Österreich, etc...
Comment #16
gerlos commentedI applied your #10 and #15 patches, but still get this error, both with current and dev version of this module. :-(
Solved disabling tags for node types I'm importing (I was importing events using the ical node processor and parsing tags from description using hashtags module).
Comment #17
achtoncedarm's patch 10a in #10 works for me as well.
Here's a re-roll of that patch against 6.x-1.x-dev. Beware that #1567878: Notice: Undefined property: stdClass::$taxonomy affected the logic slightly so this patch won't apply against any current betas. I also modified the comments slightly due to this, so please be aware of that change when you review the patch.
For those who need the patch to apply against current recommended release (beta12), you can use this patch instead (not listed below).
Comment #18
twistor commented