Problem/Motivation
In EntityProcessorBase::existingEntityId() the method getUniqueValue() is called without checking first if the target plugin implements that method. Currently, the method is only defined in FieldTargetBase.
Steps to reproduce
- Implement a FeedsTarget plugin that implements
\Drupal\feeds\Plugin\Type\Target\TargetInterfacebut does not extend\Drupal\feeds\Plugin\Type\Target\FieldTargetBase. - Make sure that the static method
targets()sets a new target definition. On that target definition, call at leastaddProperty()andmarkPropertyUnique(). Do not add a method calledgetUniqueValue(). - Create a new feed type, add the defined target to mapping, mark it as unique.
- Do an import.
You will get something like the following error:
Error: Call to undefined method MyTarget::getUniqueValue()
Proposed resolution
Add the method getUniqueValue() to TargetInterface. Use the same signature as in FieldTargetBase. In TargetBase, implement the method, but just return NULL.
Remaining tasks
Implement the proposed resolution and make sure tests pass with the fix and fail without.Add tests- Review
- Merge
User interface changes
None.
API changes
A new method is added to \Drupal\feeds\Plugin\Type\Target\TargetInterface. In theory, this could break existing modules that implement that interface directly without extending \Drupal\feeds\Plugin\Type\Target\TargetBase. But the code is kinda broken anyway, because EntityProcessorBase expects that all target plugins have the method getUniqueValue() defined.
Data model changes
None.
Issue fork feeds-3566887
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 #3
megachrizComment #4
megachrizI scheduled merging the code.