Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Book cover image sometimes does not save #773
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.
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.
Line 26, looks like the null is failing the condition check and setting it to 0 on first save?