Problem/Motivation

aving a flipbook entity can fail with a DB integrity error when flipbook_cover is present but its width/height values are empty.
Observed error:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'flipbook_cover__width' cannot be null
This happens on entity save/update when the image field item is written without dimensions.k

Steps to reproduce

nstall and enable flipbook (11.0.1) on Drupal 10/11.
Load an existing flipbook entity with a flipbook_cover target file.
Save the entity with a flipbook_cover item that includes target_id but no explicit width/height values.
Save fails with flipbook_cover__width / flipbook_cover__height null constraint violation.

Proposed resolution

Add a preSave() safeguard in Flipbook entity class:
If flipbook_cover exists and dimensions are missing:
Try to compute width/height from the referenced file via image.factory.
If dimensions still cannot be determined, set safe fallback values (0/0) to avoid SQL NOT NULL failure.

Comments

betoaveiga created an issue. See original summary.

betoaveiga’s picture

These are patches I created with AI to fix the issue when saving flipbook entities.
These patches are for versions 11.0.1 and 10.0.1

betoaveiga’s picture

Title: lipbook save fails when cover image width/height are empty (SQLSTATE 23000: flipbook_cover__width cannot be null) » Flipbook save fails when cover image width/height are empty (SQLSTATE 23000: flipbook_cover__width cannot be null)
kushal bansal’s picture

Thanks betoaveiga for looking into it. I will test this patch and see how it goes.