From: Operating system: Windows Server 2003 PHP version: 5.2.13 Package: CGI related Bug Type: Bug Bug description:PHP temp files not deleted when also using a CGI script
Description: ------------ This bug is very specific to Windows. When executing a generic file upload using PHP, if at anytime while the file is being uploaded Apache then runs a CGI script like PERL or a C program, and the upload ends while the CGI script is still running, the uploaded file(s) in the temp directory will remain behind forever. In order to avoid this the âphp_do_open_temporary_fileâ routine will have to not use the âVCWD_OPEN_MODEâ routine to open the temp file. A generic Windows âopenâ call allows child processes to inherit their handles. The temp file would need to be opened with a âCreateFileâ call to open the file and specify the pSecurityAttributes option with bInheritHandle set to FALSE so that a child process will not inherit the open file handle. The rub is this call uses a non-compatible handle so everyone who uses this handle has to be modified as well. Test script: --------------- Write or use any simple PHP upload program. Next use CGI program below -- it doesn't need to do anything except take time. So start the PHP upload, then start the CGI program below from a webpage. Make sure the PHP upload completes before the script ends. #include <windows.h> void main(){ Sleep(2*60*1000); // sleep 2 minutes } Expected result: ---------------- The file should be uploaded and the temp file in the temp directory should not be present when done. It should be moved to the destination directory. Actual result: -------------- The temp file remains forever in the temp directory, though the file is copied correctly to the destination directory. -- Edit bug report at http://bugs.php.net/bug.php?id=51802&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51802&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51802&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51802&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51802&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51802&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51802&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51802&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51802&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51802&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51802&r=support Expected behavior: http://bugs.php.net/fix.php?id=51802&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51802&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51802&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51802&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51802&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51802&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51802&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51802&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51802&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51802&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51802&r=mysqlcfg