Problem/Motivation
Given an entity reference field in which the Target Type is "Node", Mode is "Simple", and Target Bundles are left unchecked (resulting in all being available), running Devel Generate's content generation function results in an error. Here is an excerpt from an example message for a "related node" entityreference field when running Devel Generate:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'page' for column 'field_related_nodes_target_id' at row 1: INSERT INTO {field_data_field_related_nodes} [...]
Proposed resolution
I have found the issue to be in entityreference.devel_generate.inc:_entityreference_devel_generate()'s handling of the results of a call to getReferencableEntities(). The result of a call to getReferencableEntities() is and array keyed by the entity type and then by entity ID. _entityreference_devel_generate() appears to be coded under the assumption that the results are simply keyed by the entity ID, which they are not.
Remaining tasks
The solution is coded and ready for review. I have only tested this on an entity reference field in which the Target Type is "Node", Mode is "Simple", and Target Bundles are all left unchecked. Other uses of entity reference and Devel Generate need to be tested.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | entityreference-devel-generate-fix.diff-3.diff | 904 bytes | benkoren |
| #2 | entityreference-devel-generate-fix.diff-2.diff | 882 bytes | benkoren |
| entityreference-devel-generate-fix.diff | 765 bytes | benkoren |
Comments
Comment #1
benkoren commentedComment #2
benkoren commentedI was mistaken in my previous patch. Attached is the patch that should fix the issue correctly.
Comment #4
benkoren commentedComment #5
benkoren commentedComment #7
benjifisherThis is a duplicate of #1852112: Invalid field value with devel_generate.
I have no idea why the original patch above passed automatic testing. The patch from the other issue was committed on January 1.
I like the patch here better than the one that was adopted. It seems like an odd use of a loop: