I've been working on a site for about a month and I recently tried to bake something and now I'm really stuck with the cache permission problem that just popped up. I've read everything on stackoverflow on this issue for example:
Cakephp Permission denied Fileengine.php
Including the bug/non-bug: http://cakephp.lighthouseapp.com/projects/42648/tickets/2172
But I still can not stop this error from appearing during a plugin's load of a javascript asset using the HTML->script helper.
Warning: SplFileInfo::openFile(/var/www/2tli/app/tmp/cache/persistent/myapp_cake_core_cake_console_): failed to open stream: Permission denied in /var/www/2tli/lib/Cake/Cache/Engine/FileEngine.php on line 314
Call Stack: 0.0009 352948 1. {main}() /var/www/2tli/app/webroot/index.php:0
0.0045 446644 2. include('/var/www/2tli/lib/Cake/bootstrap.php') /var/www/2tli/app/webroot/index.php:92 0.0327 1174292 3. Configure::bootstrap() /var/www/2tli/lib/Cake/bootstrap.php:171 0.0427 1406772 4. include('/var/www/2tli/app/Config/core.php') /var/www/2tli/lib/Cake/Core/Configure.php:78 0.0494 1512200 5. Cache::config() /var/www/2tli/app/Config/core.php:336 0.0495 1512940 6. Cache::_buildEngine() /var/www/2tli/lib/Cake/Cache/Cache.php:136 0.0562 1635708 7. FileEngine->gc() /var/www/2tli/lib/Cake/Cache/Cache.php:169 0.0562 1635796 8. FileEngine->clear() /var/www/2tli/lib/Cake/Cache/Engine/FileEngine.php:102 0.0617 1637516 9. FileEngine->_setKey() /var/www/2tli/lib/Cake/Cache/Engine/FileEngine.php:236 0.0627 1657060 10. trigger_error() /var/www/2tli/lib/Cake/Cache/Engine/FileEngine.php:314
I am running PHP 5.3.10. Cake 2.3.7. I have the following in my bootstrap.php:
// Setup a 'default' cache configuration for use in the application.
Cache::config('default', array('engine' => 'File', 'mask' => 0666));
And in core.php:
/**
* Configure the cache used for general framework caching. Path information,
* object listings, and translation cache files are stored with this configuration.
*/
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
));
My plugin also has a bootstrap.php with:
Cache::config('UserPlugin', array(
'engine' => 'File',
'duration'=> '+3 months',
'path' => CACHE,
'prefix' => 'UserPlugin_',
'mask'=>0666
));
I have put all the app/tmp files and folders as my apache owner www-data and set to 777 (I also tried 666 to match the mask).
I've deleted and rebuilt the app/tmp directory too.
Does anyone have any ideas?
EDIT: I don't know quite what to make of this, but I noticed the commenting out the Html->script helper sometimes wouldn't remove the error (and the raw html still showed the include for the script). So I stared deleting caches and setting the cache duration time down to 1 second. Only occasionally did it behave as expected because the html seemed cached. The only way I found to consistently get it to work as expected (either when commenting in or out the line) was to delete the cache and restart the browser (firefox). Then whenever I would put in the html->script again after restarting firefox, cake would work without the permission error. I'm sure the problem will come back, because I can't seem to find the root cause.