ID:               31918
 Updated by:       [EMAIL PROTECTED]
 Reported By:      du at bestwaytech dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         Filesystem function related
-Operating System: win32 only
+Operating System: *
-PHP Version:      5CVS-2005-03-06
+PHP Version:      5CVS-2005-03-22
-Assigned To:      
+Assigned To:      iliaa
 New Comment:

This happens because of this, found in main/main.c:1746-1755

zend_try {
  op_array = zend_compile_file(file, ZEND_INCLUDE...
  zend_destroy_file_handle(file TSRMLS_CC);
...
} zend_end_try

The zend_destroy_file_handle() is never called if there are any parse
errors in the file as zend_compile_file() throw a zend_bailout(). 

Assigned to Ilia.




Previous Comments:
------------------------------------------------------------------------

[2005-02-28 21:08:46] du at bestwaytech dot com

Just tried Feb 28 CVS snapshot provided by that link. I am still
getting the same error unfortunately and file doesn't get deleted, when
php syntax is wrong.

I also tried PHP 5.0.3 on Win2000 with IIS (this one is WinXP) and it
also generates the same error.

------------------------------------------------------------------------

[2005-02-28 20:45:37] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-02-12 01:24:38] du at bestwaytech dot com

You are correct, this code does work under linux for me as well.
However under WinXP Pro SP2, IIS, PHP 5.0.3 it causes an error and does
NOT delete the created file. The error is printed when I try to unlink
it.

Making code simpler:

$function = '<?php function test1(){ $x = 1 } ?>';
$file = tempnam("c:", "scr");
$handle = fopen($file, "w+");
fwrite($handle, $function);
if (!php_check_syntax($file)) {
    echo "syntax error";
}
fclose($handle);
unlink($file);

Expected result:
file deleted
Expected output:
syntax error

Actual result:
file not deleted
Actual output:
syntax error
Warning: Unknown: Permission denied in Unknown on line 0

------------------------------------------------------------------------

[2005-02-10 20:13:22] du at bestwaytech dot com

Sorry, forgot to change the first line in example to:
$function = '<?php function test1(){ $x = 1 } ?>';

(Or you can use some other syntax error)

------------------------------------------------------------------------

[2005-02-10 20:11:01] du at bestwaytech dot com

Description:
------------
In order to load custom functions I write them to temporary file, check
syntax and load only if syntax correct. When syntax validates,
everything is fine. When syntax is incorrect, I am unable to delete the
created temporary file.

Reproduce code:
---------------
$function = '<?php function test1(){ $x = 1; } ?>';
$file = tempnam("c:", "scr");
$handle = fopen($file, "w+");
fwrite($handle, $function);
if (!php_check_syntax($file)) {
    echo "syntax error - ";
} else {
    echo "syntax ok - ";
}
if (fclose($handle)) {
    echo "closed - ";
} else {
    echo "not closed - ";
}
if (unlink($file)) {
    echo "deleted";
} else {
    echo "not deleted";
}

Expected result:
----------------
syntax error - closed - deleted

Actual result:
--------------
syntax error - closed -
Warning: Unknown: Permission denied in Unknown on line 0
not deleted


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31918&edit=1

Reply via email to