Zend Cache Error – Silverstripe 2.4 admin
Posted: June 20th, 2010 | Author: Ed | Filed under: Blog, Coding, Content Management Systems, PHP, Silverstripe | Tags: Bug Fix, Silverstripe, Silverstripe 2.4, Zend Cache | No Comments »After uploading a new site built on Silverstripe 2.4 to my shared host, the following error reared it’s head when trying to access the admin area.
[User Error] Uncaught Zend_Cache_Exception: cache_dir is not writable
After some searching through the Silvstripe forums, I finally ended up at finding a resolved support ticket that showed an easy solution in the mysite/_config.php.
First, check the silverstripe-cache folder exists in your site’s root directory, and ensure it is writable.
Then add the following line anywhere in your _config.php file.
$_SERVER['TMPDIR'] = '/absolute_path_to_your_cache_foler/silverstripe-cache';
Finally revisit your admin with flushed cache (/admin?flush=1)
This fix worked fine for me but I have seen it hasn’t worked for others. A last case solution for those that need a quick fix would be to edit the cache directory in /sapphire/thirdparty/Zend/Cache/Backend/File.php. Change:
protected $_options = array( 'cache_dir' => 'CHANGE_TO_CACHE_DIR', 'file_locking' => true, 'read_control' => true, 'read_control_type' => 'crc32', 'hashed_directory_level' => 0, 'hashed_directory_umask' => 0700, 'file_name_prefix' => 'zend_cache', 'cache_file_umask' => 0600, 'metadatas_array_max_size' => 100 );
The file is part of the Sapphire core so this solution is not advised as a long term fix, and could quick easily be overwritten in future updates.