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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Summit’s picture

Version: 7.x-2.0-alpha3 » 7.x-2.x-dev

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

Johnny vd Laar’s picture

Status: Active » Reviewed & tested by the community
FileSize
952 bytes

This works for me. Attached is the same fix as a patch

twistor’s picture

Status: Reviewed & tested by the community » Needs work

This mapper needs a lot more work, but as far as this issue is concerned:

Why not just do, $sub_field == 'title'?

emackn’s picture

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.

twistor’s picture

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..

tea.time’s picture

Version: 7.x-2.x-dev » 7.x-2.0-alpha4
FileSize
36.75 KB

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.

lundj’s picture

Status: Needs work » Active

#2 fixed it for me too - maybe the patch should be applied in the next reiease?

Robin Millette’s picture

Version: 7.x-2.0-alpha4 » 7.x-2.x-dev
Status: Active » Needs work

Trying to clear up version and status...

twistor’s picture

twistor’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.