Problem/Motivation
When using the Rewrite plugin after an other plugin, the source value on the item remains unchanged. That's because Feeds Tamper currently writes the tampered value back to the item after all tampers have been applied.
Say for example you have the following value on a source field called "WORK_PHONE":
123/456-7890
And you want that to transform to:
(123)456-7890
If you apply a plugin first that replaces a slash with a close bracket and then apply the Rewrite plugin after that, in the end result what the first applied tamper had done is lost. You'll get "(123/456-7890" instead of "(123)456-7890".
Steps to reproduce
- Have a source item with the following values:
- WORK_PHONE: 123/456-7890
- Configure the following tampers for the source "WORK_PHONE":
- Find replace:
- Text to find: /
- Text to replace: )
- Rewrite:
- Replacement pattern: ([WORK_PHONE]
- Find replace:
- Run the Feeds import
Expected result: (123)456-7890
Actual result: (123/456-7890
Proposed resolution
In FeedsSubscriber, write back the value to the item after each applied Tamper plugin (instead of doing this after the whole chain of Tamper plugins are applied).
Remaining tasks
Work out the source of the problem.Fix the problem.- Review/Merge
User interface changes
None
API changes
None
Data model changes
None
Issue fork feeds_tamper-3323381
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Issue fork tamper-3323381
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
damienmckennaI ended up changing the output format so that the extra tamper steps were not needed and I could ignore this bug.
Comment #3
megachrizI see that there are a few other issues for the Rewrite plugin as well:
#3224959: Rewrite plugin: iterate through values to rewrite
#3065458: Rewrite plugin does not work after Explode
#3183675: Rewrite value using another field value only if empty.
#3185029: Rewrite plugin: use keys of source definition in replacement patterns
Comment #6
megachrizI think that the issue actually is in Feeds Tamper:
/with)([phone]With Feeds, the result becomes:
That's because Feeds Tamper now writes the result back to the source at the end of the chain and not in between.
Comment #7
megachrizComment #9
megachrizMoving this to Feeds Tamper now.
Comment #10
megachrizI've provided a fix and I've updated the issue summary to clarify what the problem is.
Comment #13
megachrizI merged the code!