Magento/Zend not allowing symbolic links

非 Y 不嫁゛ 提交于 2019-11-29 04:37:29

As of Magento 1.5.1.0 (maybe 1.5.x?) there is an option at System > Configuration > Developer > Template Settings > Allow Symlinks that you can enable.

No need for dirty hacks/workarounds anymore. :-)

This was caused by a change in 1.4.2 where Magento no longer allows symlinked folders. If you look in Template.php

        $includeFilePath = realpath($this->_viewDir . DS . $fileName);
        if (strpos($includeFilePath, realpath($this->_viewDir)) === 0) {
            include $includeFilePath;
        } else {
            Mage::log('Not valid template file:'.$fileName, Zend_Log::CRIT, null, null, true);

        }

you see that it won't load if the template is not under the "viewDir".

found another nice little solution which works for me:

sshfs 192.168.1.12:/srv/www/vhosts/dev.****.*****.de/media/catalog/product/ catalog/product/ -o allow_other

this mounts the remote file system via sshfs, allow_other option is necesarry to make the files mounted from the remote box without the remote box file rights:

This option will allow you to use -o allow_other in your SSHFS command which will allow your non-root user access to the specific resource you're mounting.

hope this helps to anyone of you

I am also using symlinks to my custom code and I managed to overcome this issue by using mount --bind instead of creating symlinks, e.g. custom theme directory: /home/user/workspace/magento/app/design/frontend/default/mytheme

cd <magento dir>/app/design/frontend/default
mkdir mytheme
sudo mount --bind /home/user/workspace/magento/app/design/frontend/default/mytheme mytheme

This method will not work on OSX.

Add some logging code to the base template block

#File: app/code/core/Mage/Core/Block/Template.php
public function fetchView($fileName)
{
    ...
    Mage::Log($this->_viewDir.DS.$fileName); 
    var_dump($this->_viewDir.DS.$fileName);
    include $this->_viewDir.DS.$fileName;
    ...
}

Ultimately, rendering a template block is a call to include with a system path. Once you get the path Magento is constructing to your template, create a one line PHP file

<?php
include('/path/that/was/logged/foo.phtml');

And attempt to load the template. This should allow you to isolate the reason any particular call to include is failing. My immediate guess is a PHP safe mode setting, but it's been a long time since I had to fight shared hosting restrictions.

Good luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!