Posted by dgdgdg on June 7, 2011 at 11:48am
10 followers
| Project: | Feeds |
| Version: | 7.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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
Comments
#1
Hi,
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
#2
This works for me. Attached is the same fix as a patch
#3
This mapper needs a lot more work, but as far as this issue is concerned:
Why not just do,
$sub_field == 'title'?#4
Can 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.
#5
Even 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..
#6
Ran 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.
#7
#2 fixed it for me too - maybe the patch should be applied in the next reiease?
#8
Trying to clear up version and status...
#9
This was fixed in http://drupalcode.org/project/feeds.git/commit/714c9e3.
#10
#11
Automatically closed -- issue fixed for 2 weeks with no activity.