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

Issue Type: Bug Created: 2007-09-22T10:24:17.000+0000 Last Updated: 2008-03-21T16:25:37.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Mike N (zerox) Assignee: Fabien MARTY (fab) Tags: - Zend_Cache

Related issues: Attachments:


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?

<pre class="highlight">
public function _flush($data)
    chdir(dirname($_SERVER['SCRIPT_FILENAME'])); // <-- added
    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


Posted by Darby Felton (darby) on 2007-09-26T15:02:52.000+0000

Assigning to [~fab] to initiate issue review.

Posted by Fabien MARTY (fab) on 2007-10-23T12:18:43.000+0000

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));" ?


Posted by Fabien MARTY (fab) on 2007-10-23T12:35:07.000+0000

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

Posted by Mike N (zerox) on 2007-10-25T11:08:06.000+0000

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.

Posted by Fabien MARTY (fab) on 2007-10-25T12:07:17.000+0000

thanks for the feedback

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.