Some spl tests fail on windows as of unlink error

From: Date: Thu, 09 Dec 2010 12:29:19 +0000
Subject: Some spl tests fail on windows as of unlink error
Groups: php.qa 
Request: Send a blank email to php-qa+get-65706@lists.php.net to get a copy of this message
Hi, The following spl tests: SplFileObject_fwrite_variation_001 SplFileObject_fwrite_variation_002 SplFileObject_fwrite_variation_003 fail as of unexpected unlink error, such as: 002+ Warning: unlink(C:\inetpub\wwwroot\php-5.3.3\ext\spl\tests/SplFileObject_fwrite_variation_001.txt): Permission denied in C:\inetpub\wwwroot\php-5.3.3\ext\spl\tests\SplFileObject_fwrite_variation_001.php on line 10 The above errors occur as the file cannot be deleted in windows as long as the SplFileObject handle is in use. Here's one of the tests (just the actual --FILE-- part): 1 <?php 2 $file = dirname(__FILE__).'/SplFileObject_fwrite_variation_001.txt'; 3 if(file_exists($file)) {
  4         unlink($file);
5 } 6 $obj = New SplFileObject($file,'w'); 7 $obj->fwrite('test_write',4); 8 var_dump(file_get_contents($file)); 9 if(file_exists($file)) {
 10         unlink($file);
11 } 12 ?> considering 2 alternative ways to solve the problem (both make the test pass): 1) remove lines 9-11 - as these tests unlink anyhow on lines 3-5 2) unset($obj) before the second removal What do you consider the best approach here? thx, Eyal

« previous php.qa (#65706) next »