ZF-1983: Zend_Cache_Frontend_Page when using a cache_dir that has a relative path

Description

When you use the Zend_Cache_Frontend_Page and your cache_dir has a relative path, the caching doesn't work. If we add chdir(dirname($_SERVER['SCRIPT_FILENAME'])); to the _flush callback, we can fix the problem. Is there any other solution?


public function _flush($data)
{
    chdir(dirname($_SERVER['SCRIPT_FILENAME'])); // <-- added
    $this->save($data);
    return $data;
}

Explaination :

Some web servers (e.g. Apache) change the working directory of a script when calling the callback function. You can change it back by e.g. chdir(dirname($_SERVER['SCRIPT_FILENAME'])) in the callback function.

p.s. Testing server: WinXP Apache HTTPD 2.2.4 + Openssl 0.9.8e PHP 5.2.3

Comments

Assigning to [~fab] to initiate issue review.

can you try to open the Zend/Cache/Backend/File.php file and to change the line "$this->setOption('cache_dir', $value);" (function setCacheDir()) with "$this->setOption('cache_dir', realpath($value));" ?

thanks

sorry it's the line "$value = rtrim($value, '\/') . DIRECTORY_SEPARATOR;" which have to be replaced by "$value = rtrim(realpath($value), '\/') . DIRECTORY_SEPARATOR;"

Meanwhile I got a new computer with a different OS so I can't test it on the same configuration. Well.. on Vista it works OK without adding the realpath function & it works also with the added realpath function.

thanks for the feedback