Issue #3490274: Allow to re-save existing referenced entity
Summary: This MR adds configurable functionality to automatically save referenced entities when the referencing entity is saved, addressing transaction consistency issues particularly for the Media Widget module use case and other scenarios where referenced entity changes need to be persisted atomically.
Technical Implementation:
-
EntityReferenceItem::preSave()
with four configurable save modes:disabled
,new_only
(default),changed_only
, andalways
- Circular reference prevention using UUID-based tracking
- Configuration schema with validation constraints
Testing Coverage:
- Comprehensive test suite with 336+ assertions
- All 10 test methods passing with complete coverage
- Tests for all save modes, circular references, multi-level chains, and edge cases
Backward Compatibility:
- 100% backward compatible with default
new_only
mode preserving existing behavior - No breaking changes to existing APIs
- New functionality is purely opt-in via field configuration
AI Assistance Acknowledgment: This code was developed with the assistance of artificial intelligence (AI) tools, especially around the test coverage generation. Commit messages include a marker when the code was generated via AI (Claude Sonnet 4).
Edited by Francesco Placella