Quantcast
Channel: Windows Cache Extension for PHP
Viewing all articles
Browse latest Browse all 197

Files not deleted if fcache is enabled and files are on network share.

$
0
0

Using this test script with apache 2.2 + fastcgi + php 5.4.11 nts (with functionality taken from \Symfony\Component\Filesystem\Filesystem), trying to delete a directory on "Z:", a network share, the directories are never removied and an exception is thrown, and the files are marked as open by php-cgi:

 <?php

class filer {

private function toIterator($files)
{
if (!$files instanceof \Traversable) {
$files = new \ArrayObject(is_array($files) ? $files : array($files));
}

return $files;
}

public function remove($files)
{
$files = iterator_to_array($this->toIterator($files));
$files = array_reverse($files);
foreach ($files as $file) {
echo("removing $file");
if (!file_exists($file) && !is_link($file)) {
echo("file $file doesn't exist or is a link?");
continue;
}

if (is_dir($file) && !is_link($file)) {
echo("I think $file is a " . (is_dir($file)? "directory" : "link") );
$this->remove(new \FilesystemIterator($file));

if (true !== @rmdir($file)) {
throw new \Exception(sprintf('Failed to remove directory %s', $file));
}
} else {
// https://bugs.php.net/bug.php?id=52176
if (defined('PHP_WINDOWS_VERSION_MAJOR') && is_dir($file)) {
if (true !== @rmdir($file)) {
throw new \Exception(sprintf('Failed to remove file %s', $file));
}
} else {
if (true !== @unlink($file)) {
throw new \Exception(sprintf('Failed to remove file %s', $file));
}
}
}
}
}
}

$f = new filer();
try {
$f->remove("Z:/testdir"); //testdir has sub directories and files
} catch (\Exception $e) {
echo $e->getMessage();
}


Viewing all articles
Browse latest Browse all 197

Latest Images

Trending Articles



Latest Images