-
Notifications
You must be signed in to change notification settings - Fork 7.9k
readfile() problems if user closes browser tab #16422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, this may be a Windows specific issue. Anyhow, did you try to set ignore_user_abort=1 or call ignore_user_abort(); that should (if it works) alleviate the problem. And for the general case, there may be nothing more we can do. For |
@cmb69 - thank you for these suggestions!! I was not aware of this option.
https://www.php.net/manual/en/function.tmpfile.php says "Caution: If the script terminates unexpectedly, the temporary file may not be deleted. ". that is the observed behavior. Are you proposing the change that ? Personally I don't see anything wrong in I'm fine with that solution; leaving this ticket open for others to judge if correction is needed in |
Hmm, no further feedback for month, so I'm closing this ticket. |
Description
Normal situation:
Abnormal situation causing the problem:
Expectations:
What actually happens if the user closes the target tab before the PDF is returned:
error_get_last()
returns nothing__destruct()
method on the PDF-generation class runs, but is unable to delete the temp PDF because the file is LOCKEDAnalysis:
unlink()
; then use Windows Resource Monitor to find out which process is locking the temp PDF file: apache httpd is holding a lock on the temp file.readfile()
fails since the browser connection no longer exists; but it has obtained a lock on the temp PDF file which is not released until execution finishesPROBLEMS:
readfile()
when the browser tab is closed:a. cannot be caught
b. is not reported by
error_get_last()
c. does not show in any log file
readfile()
obtains a lock on the file to be returned, but does not release the lock when the fatal condition occursCAVEAT:
The following code can be used to replicate the problem:
PHP Version
PHP 8.3.11 x64
Operating System
Windows 10 Pro; apache httpd 2.4.62
The text was updated successfully, but these errors were encountered: