I wrote a cakeshell script which I plan to use it using cronjob. while having run it manually (during testing), sometimes my site will throw SplFileInfo Warning e.g:
Warning: SplFileInfo::openFile(/var/www/flat/app/tmp/cache/persistent/myapp_cake_core_file_map):
failed to open stream: Permission denied in /var/www/flat/lib/Cake/Cache/Engine/FileEngine.php on line 313
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list):
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): _cake_model_ cache was unable to write 'default_flat_list' to File cache [CORE/Cake/Cache/Cache.php, line 309]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/persistent/myapp_cake_core_method_cache) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/persistent/myapp_cake_core_method_cache) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list) [http://php.net/splfileinfo.openfile]:
failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 313]
Warning (512): _cake_model_ cache was unable to write 'default_flat_list' to File cache [CORE/Cake/Cache/Cache.php, line 309]
What happened? and how to fix this?
If I check the tmp directory on cache and persistent some of the file are under root permissions. Is this the cause?
[root@Apps103 persistent]# ls
total 40K
-rw-rw-r-- 1 apache 43 Apr 22 17:49 myapp_cake_core_cake_
-rw-rw-r-- 1 root 43 Apr 23 10:01 myapp_cake_core_cake_console_
-rw-rw-r-- 1 root 43 Apr 23 10:01 myapp_cake_core_cake_dev_
-rw-rw-r-- 1 apache 43 Apr 23 10:26 myapp_cake_core_cake_dev_en-us
-rw-rw-r-- 1 apache 43 Apr 23 10:26 myapp_cake_core_cake_en-us
-rw-rw-r-- 1 apache 43 Apr 23 10:26 myapp_cake_core_default_en-us
-rw-rw-r-- 1 root 4.3K Apr 23 10:01 myapp_cake_core_file_map
-rw-rw-r-- 1 root 4.3K Apr 23 10:01 myapp_cake_core_method_cache
I tried the solution from this link SplFileInfo::openFile(/app/tmp/cache/persistent/cake_core_cake_console_):failed to open stream:Permission denied in /lib/.../FileEngine.php line 293
I put this in bootstrap
Cache::config('default', array(
'engine' => 'File',
'mask' => 0666,
));
// short
Cache::config('short', array(
'engine' => 'File',
'duration' => '+1 hours',
'path' => CACHE,
'prefix' => 'cake_short_'
));
// long
Cache::config('long', array(
'engine' => 'File',
'duration' => '+1 week',
'probability' => 100,
'path' => CACHE . 'long' . DS,
));
but it does not work. Usually I clean up the whole tmp directory to remove the warning. then it will work fine again. I'm not sure why, but if I ran the shell, the warning error does not show, until the next day. My tmp directory (flat/app/tmp) is under apache permission.