I want to upload a Zend Framework Project to a site where “safe_mode” is on and I can’t controll it.
I get the following warning message from PHP:
PHP Warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid/gid is 954/815 is not allowed to access /tmp owned by uid/gid 0/0 in /blabla/phpapps/include/library/Zend/Cache/Backend.php on line 185
I don’t use Zend_Cache, so why is safe_mode angry about my script?
How do I set a default /tmp directory in my project to avoid this error?
thx
Because
Zend_Cacheis also used internally from some other ZF components (Zend_Db,Zend_Translateand so on).You have two choices here:
Zend_Cacheand configure it to use a custom instance of cache with a defined backend which doesn’t use/tmpstorage (check for Apc or Memcached)Zend_Cache_Backendimplementation near line 185 and update your code to avoid that error.I would choose option 1 for better performances (apc or memcached are faster storage than filesystem) and for having more control on what’s happening in your project. However this could require more than one change for your project, because there could be more than one component which need to be configured.
If you choose option 2 you could hack the whole thing with a single change and it will reflect all the components which uses a default cache instance, but since your hacking your code to work with an internal implementation future releases of ZF could break your code. That said you could achieve this by defining an
ENVorSERVERvariable with one of the keys that ZF checks for. These are the lines before where your warning is raised:So a code like this in the bootstrap will solve your issue: