php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32412 register_shutdown_function, stop access to files
Submitted: 2005-03-22 17:24 UTC Modified: 2005-03-22 18:32 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: alexandre_langlois at hotmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.10 OS: Windows XP Pro
Private report: No CVE-ID: None
 [2005-03-22 17:24 UTC] alexandre_langlois at hotmail dot com
Description:
------------
I use register_shutdown_function to simulate a destructor, but, in this destructor, I cannot check if a file exist, this function (file_exists) like is_reading, is_file ... always return FALSE... To verify if it's a problem with my file, I put the same check in the constructor, and it work, the file exist, so, I put clearstatcache() in the constructor to remove file information in the cache because, in the destructor, php will say, that file exist, I saw it before, but PHP will not really check if the file exist.

BUT, if, in the destructor, I put the absolute path to check the file (like E:/tpls/debug.tpl), the destructor see the file... WHY ???

Reproduce code:
---------------
<?php
class test
{
	function test()	{
	if (file_exists('tpls/debug.tpl')) {
		clearstatcache(); 
		echo 'CONSTRUCTOR: FILE > TRUE';
	} else {
		echo 'CONSTRUCTOR: FILE > FALSE';
		}
	register_shutdown_function(array(&$this,'_test'));
	}

	function _test() {
	if (file_exists('tpls/debug.tpl')) { 
		echo ' DESTRUCTOR: FILE > TRUE';
	} else {
		echo ' DESTRUCTOR: FILE > FALSE';
		}
	}
}

$test =& new test();
?>

Expected result:
----------------
CONSTRUCTOR: FILE > TRUE DESTRUCTOR: FILE > TRUE

Actual result:
--------------
CONSTRUCTOR: FILE > TRUE DESTRUCTOR: FILE > FALSE

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-22 18:32 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed May 25 00:03:38 2022 UTC