Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
There is a probelm with the link mapper.
When the field name contains 'url' (eg my field is field_url)
There is a test for 'url' against field_url:url and field_url:title ... both match against url and overwrite url subfield
fix as per the following code to run the test against $sub_field
FIX ... sorry not easy to get a patch right now
link.inc
function link_feeds_set_target($source, $entity, $target, $value) {
if (empty($value)) {
return;
}
// Handle non-multiple value fields.
if (!is_array($value)) {
$value = array($value);
}
// Iterate over all values.
$i = 0;
$info = field_info_field($target);
list($field_name, $sub_field) = explode(':', $target);
foreach ($value as $v) {
if (!is_array($v) && !is_object($v)) {
//if (strstr($target, 'url')) { DELETE
if (strstr($sub_field, 'url')) { // NEW
if(isset($entity->{$field_name}['und'][$i]['title'])) {
$field['und'][$i]['title'] = $entity->{$field_name}['und'][$i]['title'];
}
$field['und'][$i]['url'] = $v;
}
//elseif (strstr($target, 'title')) { DELETE
elseif (strstr($sub_field, 'title')) { // NEW
if(isset($entity->{$field_name}['und'][$i]['url'])) {
$field['und'][$i]['url'] = $entity->{$field_name}['und'][$i]['url'];
}
$field['und'][$i]['title'] = $v;
}
}
if ($info['cardinality'] == 1) {
break;
}
$i++;
}
$entity->{$field_name} = $field;
}
Thanks
Comment | File | Size | Author |
---|---|---|---|
#6 | feeds_link_mapping.png | 36.75 KB | tea.time |
#2 | feeds-link-title.patch | 952 bytes | Johnny vd Laar |
Comments
Comment #1
Summit CreditAttribution: Summit commentedHi,
Thanks for the fix! I had exactly the same problem with latest 2.dev feeds. Can anyone please supply a patch for this. I am on travel, so no possibility for this. Thanks!
greetings, Martijn
Comment #2
Johnny vd Laar CreditAttribution: Johnny vd Laar commentedThis works for me. Attached is the same fix as a patch
Comment #3
twistor CreditAttribution: twistor commentedThis mapper needs a lot more work, but as far as this issue is concerned:
Why not just do,
$sub_field == 'title'
?Comment #4
emackn CreditAttribution: emackn commentedCan you provide some setup to reproduce the error to verify the patch. I created a node type for the feed items with a field named 'field_text_url' and did not see the issue you describe. Also used the common syndication parser.
What might work best is an exported feature that recreates the setup for the feeds importer, its content type for the feed item and anything else that might help with this issue.
Comment #5
twistor CreditAttribution: twistor commentedEven better would be a test case that fails without the patch, and passes with it.
Alas, we can't, #1191330: Allow feeds_mapper.test to set field instance settings..
Comment #6
tea.time CreditAttribution: tea.time commentedRan into this exact problem just now...
@emackn - attached is a screenshot of the node processor's field mappings; the two denoted in red are the problem case. "External URL" is a Link field.
If the "Title" => "External URL Title" mapping is not set, then the "Item URL (link)" => "External URL URL" mapping works correctly, i.e. the feed item's URL gets saved into the URL portion of the Link type field.
But if the title mapping is set e.g. as shown in the screenshot, the feed item's title also gets wrongly saved into the URL portion of the Link field, rather than into the Title portion.
Comment #7
lundj CreditAttribution: lundj commented#2 fixed it for me too - maybe the patch should be applied in the next reiease?
Comment #8
Robin Millette CreditAttribution: Robin Millette commentedTrying to clear up version and status...
Comment #9
twistor CreditAttribution: twistor commentedThis was fixed in http://drupalcode.org/project/feeds.git/commit/714c9e3.
Comment #10
twistor CreditAttribution: twistor commented