Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Required for alpha release
#2937717: Add support for manipulating a complete 'feeds item'/'row'.
#2937719: Multiple value handling
#2937721: Create 'SkipException' classes.
Required for full release
#2958013: [META] port remaining feeds tamper plugins
Original report by thomasmurphy
Are there plans to port tamper to Drupal 8? It has been listed as a dependency of a feeds alpha 1 release here
https://www.drupal.org/node/2917928
If you don't have the time to do this, would you be interested in taking on a co-maintainer?
Comments
Comment #2
thomasmurphy CreditAttribution: thomasmurphy at Xequals commentedComment #3
larowlanSo the plan here would be to create a new plugin manager for a plugin type of e.g. Tamperer
The interface would look something like
You should be able to scaffold most of that with Drupal console.
Then you'd need a couple of sample plugins.
e.g. explode would be a good starting point
Comment #4
ericgsmith CreditAttribution: ericgsmith as a volunteer commentedI've started an initial playground here: https://github.com/ericgsmith/tamper
I'm probably not going to contribute a huge amount of time but was just a bit of a play around while I've been bed ridden with post DrupalSouth flu.
It's basically just the plugin type and interface mentioned above, with a possible suggestion to get the plugin to explicitly handle single vs multiple values itself https://github.com/ericgsmith/tamper/pull/1/files
Comment #5
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedtwistor has given me maintainer privileges for this project! This means that we could actively use this project for developing the Tamper module now.
Note that there's an interesting discussion about whether or not develop a Tamper module: #2917928-4: Plan for 8.x-3.0-alpha1 release. (I do think that discussion should be continued in #2917926: Port Feeds Tamper to D8).
Comment #6
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedI've added a D8 release for Tamper on this project so we can track 8.x-1.x issues in this issue queue, Feeds Tamper can be installed with Composer and the testbot can run tests for Feeds Tamper. We can decide later if we use github instead of the Drupal issue queue as our central development station for the Tamper project if Eric feels more comfortable with that. For now we just mirror the two repo's.
Additionally, I've made @ericgsmith a (co-)maintainer of this module.
Comment #7
ericgsmith CreditAttribution: ericgsmith as a volunteer commentedNice :)
I'm happy with using drupal.org as the primary source for issues and development - will hopefully increase visibility for people wanting to contribute some of the plugins.
Comment #8
ericgsmith CreditAttribution: ericgsmith as a volunteer commentedComment #9
ericgsmith CreditAttribution: ericgsmith as a volunteer commentedComment #10
scott.whittaker CreditAttribution: scott.whittaker as a volunteer commentedGreat work guys!
I need to map the same CSV column to two different fields, rewriting that field differently. I can do the rewrite easy enough with regex replace, but if I attempt to reuse the same input map in 2 fields, there is only one tamper for it, so it can't be configured differently for different mappings. Alternatively I've tried adding the same source name twice with different machine names, in which case I do get 2 configurable mappings and tampers, but only the second one works, and the first becomes null.
A third possibility would be a "temporary target" mapping which was available in Drupal 7 Feeds, but this hasn't been implemented in D8 yet.
Are any of the above methods being actively worked on at the moment? Is there another way to do it, short of duplicating the column in the CSV?
Comment #11
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@scott.whittaker
It's not great UX, but on the mapping page it is possible to select the same CSV source twice and handle these as if they were two different sources.
Here is how you do it:
That's it. You now have two CSV sources pointing to the same CSV column, but under the hood they have different machine names. You can now Tamper them separately.
I discovered this "feature" by accident after I developed the UI for the CSV parser. The machine names were added to avoid possible issues with special characters.
Comment #12
scott.whittaker CreditAttribution: scott.whittaker as a volunteer commented@MegaChriz thanks for the quick reply. I mentioned above that I did try this, but even though I am able to tamper both separately only the second mapping actually works and the first comes out as null.
Comment #13
MegaChriz CreditAttribution: MegaChriz as a volunteer commented@scott.whittaker
Oops, somehow I missed that part. Note that CSV sources are case sensitive in the D8 version of Feeds. So the source names have to match exactly. If you make a typo, the source will stay null. I think spaces also matter.
If no matter what you try, the first source remains null, then this could be a bug. There is already a patch that touches the code responsible for this feature. See #2997951: Custom mapping source should use value as item getter instead of machine name?. Basically, in that patch, resolving the source selection is moved out of the CSV parser and put in the entity processor mapping code instead, so other parsers don't have to resolve sources on their own.
Side note: in the future, the Tamper plugin "Copy" could also be used to fulfill this feature request. In this case, you would type in a source that does not appear in the CSV at all and then use the "Copy" plugin to take the value from one of the other sources. This Tamper plugin is not yet ported to D8. See #2976172: Copy Plugin.
Comment #14
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedTamper 8.x-1.0-alpha1 has been released! We can move to beta/rc status as soon as all Feeds Tamper plugins are ported.