#31918 [Opn->Fbk]: unlink($file) permission denied, when php_check_syntax($file) fails

From: Date: Fri, 11 Feb 2005 19:58:59 +0000
Subject: #31918 [Opn->Fbk]: unlink($file) permission denied, when php_check_syntax($file) fails
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73894@lists.php.net to get a copy of this message
 ID:               31918
 Updated by:       tony2001@php.net
 Reported By:      du at bestwaytech dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: Windows XP
 PHP Version:      5.0.3
 New Comment:

Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


Please provide more info and try to make your code simplier.
I can't reproduce it under Linux.


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

[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


Thread (9 messages)

« previous php.bugs (#73894) next »