Problem/Motivation
When comparing revisions of an entity that contains an Entity Reference field, the Diff module may fail to display reference updates.
This occurs when the field value provides only the target_id (e.g., after an entity reference update) but does not include the loaded entity object.
As a result, the updated reference change is not visible in the Diff output, which can cause confusion for users reviewing content revisions.
Steps to reproduce
Create a content type with an Entity Reference field referencing another entity (e.g., Node or Taxonomy Term).
Create a node and set a reference value.
Edit the node and change the reference to a different entity.
Go to Revisions → Compare revisions (Diff view).
Observe that the entity reference field does not display any change, even though the reference has been updated.
Proposed resolution
Add a fallback condition in EntityReferenceFieldBuilder to handle cases where 'target_id' exists but 'entity' is not available.
This ensures the updated entity reference ID is displayed properly in the Diff output.
Remaining tasks
Add fallback for target_id when entity is missing
Verify that updated entity references appear in revision comparison
Confirm backward compatibility with existing Diff displays
User interface changes
In Diff view, when only the target_id is available, the output will now display a message such as:
Entity ID: 25
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3552007-entity-reference-target-id-fix-2.patch | 642 bytes | shaila.amale |
Issue fork diff-3552007
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
shaila.amale commentedComment #3
acbramley commentedPlease follow https://git.drupalcode.org/project/diff#contribution-guidelines
Comment #6
benstallings commentedComment #7
acbramley commentedphpstan is failing.
Comment #8
benstallings commented@acbramley those are all deprecations that don't take effect until Drupal 13, and they are unrelated to this MR. Phpstan for the current version is all green. If I've missed something, please let me know specifically what you're referring to.
Comment #9
acbramley commented@benstallings woops, I thought we were ignoring failures on next major but I had the config flipped.
Comment #10
acbramley commented