I ran across this issue when converting an array of text values into a list of nids for an entity reference field by searching on a field value corresponding to each text value with Entity Field Query Finder. I found that if the Entity Field Query Finder plugin gets not results from the query, all element items are removed from the $result. I believe that instead of removing all items from the result, only the current item should be removed.

The following code change inside of the feeds_tamper_efq_finder_callback function works, but may not be the ideal solution:

   else {
     // We didn't find a value, remove the item.
     // @todo Fallback.
-    unset($result->items[$item_key][$element_key]);
+    $delta = array_search($field, $result->items[$item_key][$element_key]);
+    unset($result->items[$item_key][$element_key][$delta]);
   }
 
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slbrassard created an issue. See original summary.

slbrassard’s picture

After having done more testing, I have come up with the following code:

   else {
     // We didn't find a value, remove the item.
     // @todo Fallback.
-    unset($result->items[$item_key][$element_key]);
+    if(is_array($result->items[$item_key][$element_key])) {
+      $delta = array_search($field, $result->items[$item_key][$element_key]);
+      unset($result->items[$item_key][$element_key][$delta]);
+    }
+    else {
+      $result->items[$item_key][$element_key] = NULL;
+    }
   }
 
twistor’s picture

Status: Active » Needs review
FileSize
828 bytes

Here's a patch, with some things changed around a bit.

Status: Needs review » Needs work

The last submitted patch, 3: feeds_tamper-2792585-3.patch, failed testing.

twistor’s picture

Status: Needs work » Needs review