Warning: SplFileInfo::openFile(/path/to/app/tmp/cache/persistent/~)[splfileinfo.openfile]: failed to open stream: Permission denied in (/path/to/lib/Cake/Cache/Engine/FileEngine.php on line xxx
ってエラーをよく見るようになった。
この解決方法を探してみる。
ネットで調べるとキャッシュの設定時にmaskを0666にすればいいというものがあったので(そしてbootstrap.php内でもそう書いてあったので)、bootstrap.phpで以下のように設定
Cache::config('default', array('engine' => 'File', 'mask' => 0666));
で、ウェブ側からリロード。生成されたキャッシュファイルを確認してみる。
$ ll 合計 12 -rw-rw-r-- 1 apache apache 43 9月 25 15:37 myapp_cake_core_cake_ja -rw-rw-r-- 1 apache apache 5858 9月 25 15:37 myapp_cake_core_file_map
生成されたファイルの権限が664なので、うまく設定が反映されていないっぽい。
なんかうまくいっていないようなので、大元のFilengine.phpを確認してみる。
FileEngine.php内での初期設定は以下のような感じ
public function init($settings = array()) { $settings += array( 'engine' => 'File', 'path' => CACHE, 'prefix' => 'cake_', 'lock' => true, 'serialize' => true, 'isWindows' => false, 'mask' => 0664 ); parent::init($settings); if (DS === '\\') { $this->settings['isWindows'] = true; } if (substr($this->settings['path'], -1) !== DS) { $this->settings['path'] .= DS; } if (!empty($this->_groupPrefix)) { $this->_groupPrefix = str_replace('_', DS, $this->_groupPrefix); } return $this->_active(); }
デフォルトでmaskに設定されているのは664のようなので、おそらくこっちが設定している内容が効いているのだろう。
正しく設定がされていることをトレースするために$settingsをdebugしてみたら
bootstrapで設定した以外のパスで/path/to/tmp/cache/model/と/path/to/tmp/cache/persistent/があったので、他の場所でCacheを指定している内容を確認してみたら、core.phpでこの部分の設定をしていた。
ここにmaskを追加してみたら権限が変わりましたと。
Cache::config('_cake_core_', array( 'engine' => $engine, 'prefix' => $prefix . 'cake_core_', 'path' => CACHE . 'persistent' . DS, 'serialize' => ($engine === 'File'), 'duration' => $duration, 'mask' => 0666 )); Cache::config('_cake_model_', array( 'engine' => $engine, 'prefix' => $prefix . 'cake_model_', 'path' => CACHE . 'models' . DS, 'serialize' => ($engine === 'File'), 'duration' => $duration, 'mask' => 0666 ));
$ ll 合計 12 -rw-rw-rw- 1 apache apache 43 9月 25 16:48 myapp_cake_core_cake_ja -rw-rw-rw- 1 apache apache 5858 9月 25 16:48 myapp_cake_core_file_map