@Hello.respond_to do |welcome|
  welcome.to_my_blog
end

Zend Cache Error – Silverstripe 2.4 admin

Posted: June 20th, 2010 | Author: Ed | Filed under: Blog, Coding, Content Management Systems, PHP, Silverstripe | Tags: , , , | 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.


Allowed memory size error in Silverstripe

Posted: June 19th, 2010 | Author: Ed | Filed under: Blog, Coding, PHP | Tags: , , | No Comments »

Silverstripe have made great improvements in the memory consumption in version 2.4 but the admin area can still get the frustrating error message.

Fatal error: Allowed memory size of 268435456 bytes exhausted

There are a few options to fix the issue:

  1. In mysite/_config.php – Add ini_set(“memory_limit“, “64M”)
  2. In .htaccess – Add php_value memory_limit 64M

Personally, I have found the 2nd option to be the best and most reliable throughout the website.

Some shared hosts lock down the options to increase memory limits so some digging around the support docs might be required if the above don’t work.