I'm really new to Zend, few days of use.
I'm getting a fatal error message:
Fatal error: Uncaught exception 'Zend_Cache_Exception' with message 'cache_dir "/home/[REDACTED]/application/../data/tmp/" is not writable' in /home/[REDACTED]/library/Zend/Cache.php:209 Stack trace: #0 /home/[REDACTED]/library/Zend/Cache/Backend/File.php(181): Zend_Cache::throwException('cache_dir "/hom...') #1 /home/[REDACTED]/library/Zend/Cache/Backend/File.php(129): Zend_Cache_Backend_File->setCacheDir('/home/user/Proj...') #2 /home/[REDACTED]/library/Zend/Cache.php(153): Zend_Cache_Backend_File->__construct(Array) #3 /home/[REDACTED]/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('File', Array, false, false) #4 /home/[REDACTED]/application/Bootstrap.php(42): Zend_Cache::factory('Core', 'File', Array, Array) #5 /home/[REDACTED]/library/Zend/Application/Bootstrap/BootstrapAbstract.php(669): Bootstrap->_initCache() #6 /home/[REDACTED]/library/Zend/Applica in /home/[REDACTED]/library/Zend/Cache.php on line 209
According to the error message, I would expect a folder permissions issue on the tmp
directory. The directory is, however, writable:
user@[REDATCED]:~/[REDATCED]/data$ ls -hal total 24K drwxrwxr-x 6 user user 4,0K Jan 7 18:40 . drwxr-xr-x 12 user user 4,0K Jan 9 12:50 .. drwxrwxr-x 3 user user 4,0K Dez 17 11:42 locales drwxrwxr-x 2 user user 4,0K Dez 17 11:42 logs drwxrwxr-x 2 user user 4,0K Dez 17 11:42 sessions drwxrwxr-x 2 user user 4,0K Jan 7 18:40 tmp
The workaround is to comment the following lines on application/Bootstrap.php
:
protected function _initCache() { $frontendOptions = array( 'lifetime' => 7200, // cache lifetime of 2 hours 'automatic_serialization' => true ); $backendOptions = array( 'cache_dir' => APPLICATION_PATH . '/../data/tmp/' // Directory where ); // getting a Zend_Cache_Core object $this->cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Registry::set('cache', $this->cache); Zend_Date::setOptions(array( 'cache' => $this->cache ));
This workaround was suggested by a coworker, I have no idea what I'm doing here or even if this code is part of Zend or our codebase. I don't like ugly hacks, or "fixing" stuff by commenting out code, or doing anything without knowing what I'm doing, or the reason behind it.
Besides, the code seems to be working on my coworkers' machines. And every time I pull their code commits from the repository I get an uncommented copy anyway.
I probably could exclude the file from the repository or anything like that (I'm new to git as well), but I really prefer:
- Knowing the cause for the error
- Knowing the solution