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.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | tamper-entity_finder_fieldable_fields-3517986-9.patch | 1.14 KB | baikho |
Issue fork feeds_tamper-3517986
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:
- 3517986-entity-finder-plugin
compare
1 hidden branch
Issue fork tamper-3517986
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
baikho commentedComment #3
baikho commentedComment #4
baikho commentedComment #5
baikho commentedComment #6
baikho commentedWoops wrong module :)
Comment #9
baikho commentedComment #15
megachriz@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.
Comment #16
baikho commented#15 Thanks, will do
Comment #17
baikho commentedComment #19
megachrizThanks for your contribution! I merged the code.