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

  1. Implement a FeedsTarget plugin that implements \Drupal\feeds\Plugin\Type\Target\TargetInterface but does not extend \Drupal\feeds\Plugin\Type\Target\FieldTargetBase.
  2. Make sure that the static method targets() sets a new target definition. On that target definition, call at least addProperty() and markPropertyUnique(). Do not add a method called getUniqueValue().
  3. Create a new feed type, add the defined target to mapping, mark it as unique.
  4. 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

Command icon 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

megachriz created an issue. See original summary.

megachriz’s picture

Issue summary: View changes
Status: Active » Needs review
megachriz’s picture

Status: Needs review » Fixed

I scheduled merging the code.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • megachriz committed bab8382a on 8.x-3.x
    fix: #3566887 Added method getUniqueValue() to \Drupal\feeds\Plugin\Type...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.