From:             du at bestwaytech dot com
Operating system: Windows XP
PHP version:      5.0.3
PHP Bug Type:     Filesystem function related
Bug description:  unlink($file) permission denied, when php_check_syntax($file) 
fails

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 bug report at http://bugs.php.net/?id=31918&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31918&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31918&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31918&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31918&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31918&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31918&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31918&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31918&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31918&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31918&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31918&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31918&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31918&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31918&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31918&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31918&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31918&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31918&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31918&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31918&r=mysqlcfg

Reply via email to