Book cover image sometimes does not save #621

Closed
opened 2026-02-04 21:28:19 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @ssddanbrown on GitHub (Mar 30, 2018).

Originally assigned to: @ssddanbrown on GitHub.

Been noticing a strange effect on my Work BookStack instance. Every so often, On seemingly first try, When setting a cover image for a book it does not seem to actually save the new cover image against the book.

Often works when going back to the book and re-trying. Tricky to re-produce.

Originally created by @ssddanbrown on GitHub (Mar 30, 2018). Originally assigned to: @ssddanbrown on GitHub. Been noticing a strange effect on my Work BookStack instance. Every so often, On seemingly first try, When setting a cover image for a book it does not seem to actually save the new cover image against the book. Often works when going back to the book and re-trying. Tricky to re-produce.
OVERLORD added the 🐛 Bug label 2026-02-04 21:28:19 +03:00
Author
Owner

@ghost commented on GitHub (Mar 30, 2018):

@ssddanbrown
I just set book covers on all my books and it happened almost every time-- but only to books I had created prior to 19.0.

So it looks like the problem was that if the image_id column in books is NULL then the first save creates the value as 0. Then the second save updates the value with the correct id.

I replicated this by creating a new book and then setting the image_id to NULL and can reproduce the behavior. Maybe the next upgrade can include a change the column to make it NOT NULL with a default value of 0 and all the existing NULLs people have will be udpated. Otherwise, it doesn't look like an issue going forward if this is the real cause and might not be worth fixing retroactively?

Anyone with this issue can fix it by updating all NULL values in that column with a 0 prior to setting images.

@ghost commented on GitHub (Mar 30, 2018): @ssddanbrown I just set book covers on all my books and it happened almost every time-- but only to books I had created prior to 19.0. So it looks like the problem was that if the image_id column in books is NULL then the first save creates the value as 0. Then the second save updates the value with the correct id. I replicated this by creating a new book and then setting the image_id to NULL and can reproduce the behavior. Maybe the next upgrade can include a change the column to make it NOT NULL with a default value of 0 and all the existing NULLs people have will be udpated. Otherwise, it doesn't look like an issue going forward if this is the real cause and might not be worth fixing retroactively? Anyone with this issue can fix it by updating all NULL values in that column with a 0 prior to setting images.
Author
Owner

@ghost commented on GitHub (Mar 30, 2018):

https://github.com/BookStackApp/BookStack/blob/master/resources/views/books/form.blade.php

Line 26, looks like the null is failing the condition check and setting it to 0 on first save?

@ghost commented on GitHub (Mar 30, 2018): https://github.com/BookStackApp/BookStack/blob/master/resources/views/books/form.blade.php Line 26, looks like the null is failing the condition check and setting it to 0 on first save?
Author
Owner

@ssddanbrown commented on GitHub (Mar 31, 2018):

Thank you @dsaundersWizmo so much for finding the root issue. Was going a bit mad why I could not reproduce this in dev but it totally makes sense now.

Instead of doing any database updates I've tweaked how the existing image gets set in the view which effectively solves the issue: 7f437c2e3c

@ssddanbrown commented on GitHub (Mar 31, 2018): Thank you @dsaundersWizmo so much for finding the root issue. Was going a bit mad why I could not reproduce this in dev but it totally makes sense now. Instead of doing any database updates I've tweaked how the existing image gets set in the view which effectively solves the issue: 7f437c2e3cf111aebee4454a3c6fea79f7fbded7
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#621