Problem/Motivation

The current implementation of the Feeds Tamper Entity Finder Plugin assumes that Content Entities without bundles will not have fieldable fields. This assumption is incorrect and leads to the plugin not working correctly for content entities that don't use bundles but still have fieldable fields.

Steps to reproduce

Create a custom content entity type without bundles but with fieldable fields.
Attempt to use the Feeds Tamper Entity Finder Plugin with this entity type.
Observe that the plugin fails to retrieve the fields for the entity type.

Proposed resolution

Replace the existing code in the getFieldDefinitions() method with the following:

$field_definitions = [];
if (!$this->entityTypeSupportBundles($entity_type_id)) {
  // Return base and fieldable field definitions.
  $field_definitions = $this->entityFieldManager->getFieldDefinitions($entity_type_id, $entity_type_id);
}

This change ensures that for entity types without bundles, the method always returns both base field and fieldable definitions, regardless of whether the entity type has bundle support.

Remaining tasks

Update the getFieldDefinitions() method in the EntityFinder class with the proposed code.
Test the plugin with various entity types, including custom content entities without bundles, to ensure it works correctly in all scenarios.
Update any relevant documentation or comments in the code to reflect this change.

User interface changes

No user interface changes are required for this fix.

API changes

There are no API changes. This fix modifies the internal logic of the plugin but does not affect its public interface.

Data model changes

No data model changes are required for this fix. The change only affects how the plugin retrieves field definitions for entity types without bundles.

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:

Issue fork tamper-3517986

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

baikho created an issue. See original summary.

baikho’s picture

Issue summary: View changes
baikho’s picture

Issue summary: View changes
baikho’s picture

Issue summary: View changes
baikho’s picture

Issue summary: View changes
baikho’s picture

Project: Feeds Tamper » Tamper
Version: 8.x-2.0-beta4 » 8.x-1.x-dev

Woops wrong module :)

baikho changed the visibility of the branch 3517986-entity-finder-plugin to hidden.

baikho’s picture

megachriz made their first commit to this issue’s fork.

megachriz changed the visibility of the branch 3517986-entity-finder-plugin to hidden.

megachriz changed the visibility of the branch 8.x-1.x to hidden.

megachriz’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

@baikho
Can you provide a test that demonstrates the bug? This way we can ensure that the bug doesn't accidentally return in the future. The test case should be added to \Drupal\Tests\tamper\Functional\Plugin\Tamper\EntityFinderTest.

Note: I moved the code to a new branch called '3517986-entity-finder-fieldable', because I had some trouble pushing/pulling from/to 8.x-1.x, which is a branch name already used in the main repo.

baikho’s picture

Assigned: Unassigned » baikho

#15 Thanks, will do

baikho’s picture

Assigned: baikho » Unassigned
Status: Needs work » Needs review

  • megachriz committed 6511a5f1 on 8.x-1.x
    Issue #3517986 by baikho: Fixed Entity Finder Plugin should support...
megachriz’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Thanks for your contribution! I merged the code.

Status: Fixed » Closed (fixed)

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