I'm working with a Feeds importer that imports to an image field. I have two tamper plugins attached to this column, one is a required filter, the other is a rewrite plugin to prepend private:// to the image name.
If I configure the weights so the required plugin runs first, I get errors like the following as the rewrite plugin tries to rewrite empty rows that have been unset() by the required filter:
Notice: Undefined offset: 13 in feeds_tamper_rewrite_callback() (line 43 of feeds_tamper/plugins/rewrite.inc).
Warning: Invalid argument supplied for foreach() in feeds_tamper_rewrite_callback() (line 44 of feeds_tamper/plugins/rewrite.inc).
If I have the required plugin run second, then I get file errors because now the field is no longer empty and Feeds tries to import an image with a path of "private://".
At first I was thinking the rewrite plugin could just check isset($result->items[$item_key]) but this bug would affect more than just the rewrite plugin, and the fix should probably be baked into the required plugin if possible or enforced on a higher level.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | rewrite.zip | 753 bytes | stephane-v |
| #2 | rewrite.zip | 753 bytes | stephane-v |
Comments
Comment #1
star-szrRe-titling, the keyword filter does an unset() as well.
Comment #2
stephane-v commentedHi,
I had the same problem so I just made a small modification to the rewrite plugin to solve it.
I added a checkbox in the plugin configuration to ask wether empty fields should be rewritten or not.
So the rewrite plugin must be executed before the required plugin.
Here is the modified rewrite.inc file :
Comment #3
stephane-v commentedThe file in post #2 is not correct. Use this one please.
Comment #4
Ivan Simonov commentedAdd little check to original function:
Comment #5
GaborTorok commentedI prefer the solution in #4.
The rewrite plugin only throws a warning, but the Copy plugin recreates the item, because it writes the items array if ($settings['to_from']=='to'), so Copy plugin should also have the isset check.
Comment #6
twistor commentedThis was fixed in #2068281: Fix the PHP warning produced by the 'required' plugin..