douhan5547 2013-01-09 15:48
浏览 91

Zend Cache异常:'cache_dir“/home/(...)/application/../data/tmp/”不可写'

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
  • 写回答

3条回答 默认 最新

  • dpchen2004 2013-01-09 15:48
    关注

    As I was writing this question I noticed my mistake, the tmp directory is writable by myself and other users of the same group, apparently Zend will access the files as another user. The solution was to chmod 777 on the folder, making it writable.

    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB动图的问题
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名