First to Site
Release 3.4

Estate Delete & Attachment Safety

Fixed FK constraint failures on estate delete and hardened orphaned attachment rendering in 3.4.0

Overview

v3.4.0 fixed two related issues: estate deletion failing with foreign key constraint errors, and attachment templates crashing when their source order had been deleted.

FK Constraint Fix

Deleting an Estate via EasyAdmin would fail because other tables (projects, documents, etc.) reference the estate through foreign keys. Rather than implementing a complex cascade strategy, the fix disables both Action::DELETE and Action::BATCH_DELETE in EstateCrudController::configureActions(), preventing admins from triggering the cascade failure entirely.

Orphaned Attachment Rendering

The document_and_order_attachment_override.html.twig template was accessing value.sourceOrderAttachmentSafe and value.sourceOrder directly to get the order attachment object and project order. When the source order or attachment had been deleted, these property accesses would fail or return stale data.

The fix:

  • Removed the three lines that fetched orderAttachmentObj, orderAttachmentId, and projectOrder from entity relation properties
  • Replaced all checks with the simpler hasOrderSource boolean (derived from value.sourceOrderId - a plain scalar that survives even when the related entity is gone)
  • Affected three template locations: the order badge display, the delete button title, and the download/action conditional

Files Touched

FileChange
Controller/Admin/EstateCrudController.phpModified - disabled delete actions
templates/themes/document_and_order_attachment_override.html.twigModified - safe scalar checks

Changelog Reference

  • fix: prevent estate delete FK errors and orphaned attachment rendering (d76feac)