Hi

I have custom node types with e-mail fields and I am using display suite. There I show instead of the plain email address a link to the email contact form.
If the email field is empty, then nothing is shown.
If the email field has a value, then the link to the contact form is shown.
This works all fine.

But when I import data records with feeds and there are empty email fields, something is imported into this email field, because when I display the node, then the link to the contact form is shown and naturally returns then an error. However, I cannot see what is imported, because when I edit the node, then the email field is indeed empty and when I save the node, the problem has gone.
This means, that I have to edit every imported node and save it, which is not convenient.

Has anybody an idea what is happening and whether there is a workaround?

thanks

Comments

beauregard’s picture

Title: Importing empty email field still shows email » Importing empty email field: field is not completely empty
beauregard’s picture

Title: Importing empty email field: field is not completely empty » Importing empty email field: email field is anyway created in the DB
beauregard’s picture

I changed the title, hoping anybody will answer this bug.
What happens: When I import data with feeds and one of the mapped field is an email field, then feeds creates in the database a emailfield record, even the email field is empty. This does not happen with any other field (text, numeric etc.). It happens only with the email field.
As I understand this should not be the case.

twistor’s picture

Assigned: Unassigned » twistor

Will check this out.

beauregard’s picture

I have some more information about this bug: This happens also with URL-Fields. I am importing nodes via XML-Feed. In this feed for some nodes the Email and Website Address field is empty:

<Website/>
<EMail/>

However, feeds creates in the database in the corresponding field-table the records with empty values.

A note: I have installed patch #161 from this thread: https://www.drupal.org/node/1107522
This patch works fine, but does not solve this bug here

MegaChriz’s picture

I can confirm this bug exists. When importing an empty value for a Email field, the empty value is saved in the database and when displaying the node, the Email field's label is shown. I recently found out that the same happens for a Link field, see #1107522-195: Framework for expected behavior when importing empty/blank values + text field fix. For link field I fixed this by adding the following code to the target callback implementation (link_feeds_set_target()):

// Filter out empty values.
$info = field_info_field($field_name);
$field['und'] = _field_filter_items($info, $field['und']);

For some reason, text, number, date and taxonomy fields do not have this problem (or at least the field labels are not displayed on the node display for "empty" fields).

Calling _field_filter_items() for every target that represents a field would solve the problem for every field. But I think right now, Feeds can't be sure for every target out there if it represents a field, so at this point it looks like the code above must be added to every target implementation that represents a field to fix the problem. Not the most elegant solution.
Thoughts?

AdamPS’s picture

Status: Active » Closed (duplicate)

I confirm this behaviour for email fields. It causes my pages to have visible labels without values, like "Email: ".

It looks like the code for email fields in feeds is in the email module not this module. I found that there is an issue there with a patch that fixes this bug: #2095197: Improve Feeds integration..

I don't see this behaviour for link fields. The function link_feeds_set_target() starts with an explicit test for empty.

  if (empty($value)) {
    return;
  }
AdamPS’s picture

MegaChriz’s picture

@AdamPS
In the dev version of Feeds the code you posted in #7 is no longer there. But the fix for link field is now handled in #1107522: Framework for expected behavior when importing empty/blank values + text field fix. I posted the solution I used for link field here as I thought it could solve it for email field as well, but also because the problem "label shown for empty field" possibly affects more fields than just link and email field. If that is the case, I hope it could be solved in a general way.

But you are right that because the email field mapper is implemented by the email module, this issue should have been opened there.

I had left this issue open to discuss if this problem could be solved in a general way or that it should be handled per module. First step would be to find out if there are more field mappers provided by other modules that have the problem of having the field label shown when the value is empty.

AdamPS’s picture

@MegaChriz I agree, the general discussion is a valid one - maybe you could create a new issue?

For any one like me who has the specific problem described by the OP, the good news is that there is a patch as per the related issue.