php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31918 unlink($file) permission denied, when php_check_syntax($file) fails
Submitted: 2005-02-10 20:11 UTC Modified: 2005-04-06 16:22 UTC
From: du at bestwaytech dot com Assigned: iliaa (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: du at bestwaytech dot com
New email:
PHP Version: OS:

 

 [2005-02-10 20:11 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-22 21:38 UTC] sniper@php.net
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.


 [2005-03-29 01:46 UTC] sniper@php.net
See also bug #30377

 [2005-04-06 16:22 UTC] iliaa@php.net
After extensive code review it was determined that it would take too many engine hacks to make it work properly and the function was removed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC