Vinai/Symlink-Cache — Issue #3: Running Cron Job from outside Magento root
Author: danmshields
Created: 2011-10-13 14:12:17+00:00
State: open

I know that there was a patch for /app/code/community/Netzarbeiter/Cache/Model/Symlink.php however I feel as if there is still a bug here where if you have a cron job for cron.php or other cron jobs and it is running from outside the Magento root, you get the error

PHP Fatal error: Uncaught exception 'Zend_Cache_Exception' with message 'cache_dir must be a directory' in /path/to/site/www/lib/Zend/Cache.php:209
Stack trace:
#0 /path/to/site/www/lib/Zend/Cache/Backend/File.php(154): Zend_Cache::throwException('cache_dir must ...')
#1 /path/to/site/www/lib/Zend/Cache/Backend/File.php(121): Zend_Cache_Backend_File->setCacheDir('var/cache')
#2 /path/to/site/www/app/code/community/Netzarbeiter/Cache/Model/Symlink.php(45): Zend_Cache_Backend_File->__construct(Array)
#3 /path/to/site/www/lib/Zend/Cache.php(153): Netzarbeiter_Cache_Model_Symlink->__construct(Array)
#4 /path/to/site/www/lib/Zend/Cache.php(94): Zend_Cache::_makeBackend('Netzarbeiter_Ca...', Array, true, true)
#5 /path/to/site/www/app/code/local/Mage/Core/Model/Cache.php(123): Zend_Cache::factory('Varien_Cache_Co...', 'Netzarbeiter_Ca...', Array, Array, true, true, true)
#6 /path/to/site/www/app/code/core/Mage/Core/Model/Config.php(1206): Mage_Core_Model_Cache->__const in /path/to/site/www/lib/Zend/Cache.php on line 209

I found that you are forced to set an absolute path in the local.xml for cache_dir, this is due to is_dir looking for the current working directory.

I don't know if this is a bug and happens as intended but should probably be called out to people that if you plan on running cron jobs that don't cd into the Magento root, use an absolute path.