Realpath doesn't resolve symlinks properly
This is in regards to https://github.com/fuel/fuel/blob/1.1/develop/public/index.php
define('APPPATH', realpath(__DIR__.'/../fuel/app/').DIRECTORY_SEPARATOR);
define('PKGPATH', realpath(__DIR__.'/../fuel/packages/').DIRECTORY_SEPARATOR);
define('COREPATH', realpath(__DIR__.'/../fuel/core/').DIRECTORY_SEPARATOR);
I'm not sure if it's related to this bug in PHP or not. This post and this post lead me to believe it's not that bug, it's the issues with caching. The issue seems to be stemming from realpath() and it's caching of paths, which might actually change if symlinks are moved or folder structures are modified. This caching happens per thread. I'm not sure if there's a better solution than realpath here or not though. The recommended solution is to restart apache in between upgrades to fully clear the cache.
I'm on 5.3.8 btw:
jesse@Jesse-Debian:/var/www/fuel$ php -v PHP 5.3.8-2 with Suhosin-Patch (cli) (built: Sep 12 2011 07:28:26)
Does that mean that if you add a clearstatcache() to your index.php, the issue is solved?
I believe that will only fix it for that particular thread.
It turns out realpath()’s cache is per-thread, so even though I was clearing it in the apache thread that was doing the upgrade, it still had old data in other apache threads.
True, but if you add it to index.php, it will flush the cache for that thread before realpath() is used.
Downside is that it will permanently disable file stat caching, which might have other side effects.
clearstatcache's first argument needs to be set to true to clear the realpath cache and clearstatcache's second argument can clear the cache for a specific file
So base on the documentation, I think 3 calls to clearstatcache could do the trick, no?
I think we should just document this in the troubleshooting section, so people that use symlinks can add this to the index.php themselfs. I don't feel this kind of workarounds should be in the framework. @dhorrigan?
We have decided not to add any code to the framework to fix this for the few users that have this problem.
A paragraph is added to the troubleshooting section of the documentation, explaining this issue and providing possible solutions.