lighttpd/xcache — pull request #1 by Ferengee (2012-09-24 14:30:02+00:00)
Title: Swap file stream wrapper

I had an issue with a proxy file stream wrapper and xcache version 2.0.1 enabled
The file stream wrapper looks like this:
class FileStreamWrapper
{
private static $modified_paths = array();

private $path = null;
private $handle = null;
private $modified = false;

public static function wrap()
{
stream_wrapper_unregister('file');
if (!stream_wrapper_register('file', __CLASS__))
throw new Exception('Failed to register');
}

public static function unwrap()
{
//echo "unwrap
\n";
stream_wrapper_restore('file');
}

public static function getModifiedPaths()
{
return array_unique(self::$modified_paths);
}

public static function addModifiedPath($path)
{
self::$modified_paths[] = $path;
}

public function stream_write($data)
{
if (!$this->modified)
{
$this->modified = true;
self::$modified_paths[] = $this->path;
}

return fwrite($this->handle, $data);
}
... and the rest of the interface implemented

Between stream_wrapper_unregister('file'); and stream_wrapper_register('file', __CLASS__); php could not find any class files (including the Exception which we try to throw if registering fails)

My current solution is to explicitly use the php_plain_files_wrapper in xcache.

Thanks in advance, i love using xcache