silverstripe / cwp-pdfexport

Adds PDF export capability for CWP pages
BSD 3-Clause "New" or "Revised" License
4 stars 5 forks source link

"File not found" error from a page with generated PDF after re-publishing the page #13

Open robbieaverill opened 6 years ago

robbieaverill commented 6 years ago

Migrated from GitLab

cc @michalkleiner

The issue occurs when a user visits a page that had a previously generated PDF file. In that case, the $PdfLink variable holds a direct link to the file from the /assets/_generated_pdfs/.

When a CMS editor re-publishes the page during this time, the PDF is flushed until it's generated next time. At this point, the user will get the error, e.g. after reading a long page and deciding to download a PDF at the end.

A solution would be direct the action through a controller function or similar and check if the file still exists. Alternatively, the link can always lead to the downloadpdf action. The page behaves safely when reloaded between each step, the issue is only when the file is removed unexpectedly (from the users perspective, after loading the site linking to the file).

robbieaverill commented 6 years ago

Alternatively, the link can always lead to the downloadpdf action

I like this idea best, that way the controller can decide where it wants to direct the user's request to dynamically.

For reference - in SS4/CWP2 this is in the cwp/cwp-pdfexport module