BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.43k stars 1.94k forks source link

update-url command does not affect draft urls #5292

Closed Tassleh0ff closed 1 week ago

Tassleh0ff commented 3 weeks ago

Describe the Bug

Moving around my Bookstack instance between different hostnames and adding a context to it I noticed a problem that feels like a bug to me and involves the bookstack:update-url command.

It seems like that the bookstack:update-url do not affect resources urls added to a draft page prior to the bookstack:update-url (plus cache:clear and change to the APP_URL variable in the Bookstack configuration).

Steps to Reproduce

  1. create a new page adding an image and save it ( example url http://bookstack.domain.tld:6875/uploads/images/gallery/2024-10/image.png )
  2. edit the page and add a second image (url http://bookstack.domain.tld:6875/uploads/images/gallery/2024-10/cetimage.png )
  3. save the draft without saving the page
  4. change APP_URL config variable to the new url ( http://newbookstack.domain.tld:6875 )
  5. update resources urls in the database docker exec -it bookstack php /app/www/artisan bookstack:update-url http://bookstack.domain.tld:6875 http://newbookstack.domain.tld:6875
  6. clear cache docker exec -it bookstack php /app/www/artisan cache:clear
  7. restart Bookstack container to apply the new APP_URL config variable (in case you're using a container env variable)

Opening the page (the last saved version of the page with only the first image) the image url is ok ( http://newbookstack.domain.tld:6875/uploads/images/gallery/2024-10/image.png ).

If you edit the page Bookstack recovers the latest draft with the two images, if you save the page turning the latest draft into the new page version the url of the two images keep using the old url as the update-url command did not affected them.

As a result the two images ends up having urls http://bookstack.domain.tld:6875/uploads/images/gallery/2024-10/image.png http://bookstack.domain.tld:6875/uploads/images/gallery/2024-10/cetimage.png

instead of http://newbookstack.domain.tld:6875/uploads/images/gallery/2024-10/image.png http://newbookstack.domain.tld:6875/uploads/images/gallery/2024-10/cetimage.png

Expected Behaviour

After running the update-url command the saved draft should also update their resources url to the new url, so in this case the new page version (after a draft recovery) should have image urls using the new APP_URL value.

Screenshots or Additional Context

No response

Browser Details

All browsers

Exact BookStack Version

v24.10

ssddanbrown commented 1 week ago

Thanks for raising @Tassleh0ff.

This seemed like a significant omission, so I've been trying to think why the revisions table was left out. Maybe to respect that state of history as authoritive? But that doesn't seem a great reason since there's a chance of leading to wider issues, and since we show plenty of warnings of changes when running the command.

I've now applied 7017a1cae59353fd3d94683ae8f30a98bad5c559 so that the revisions (which includes user drafts) are considered by this command. This will be part of the next patch release.

Tassleh0ff commented 1 week ago

No, thanks to you @ssddanbrown for the excellent work!