Hack to stop warnings

I’ve found a way to stop the warnings that started to appear two weeks ago — see my post on the 18th. The problem was, that file_exists suddenly started to give a warning when you used it on a file that you didn’t have access to, because [PHP][] is running in ”Safe Mode”. This started when NetSite upgraded to PHP 4.2.3.

The fix was simple, I just added a @ infront of file_exists to suppress the warnings. [PhpWiki][] provides all the PEAR files is need, so things still work. Here comes the patched function:

function _search_path ($file) {
    foreach ($this->_path as $dir) {
        // ensure we use the same pathsep
        if ($this->_pathsep != '/') {
            $dir = $this->slashifyPath($dir);
            $file = $this->slashifyPath($file);
            if (file_exists($dir . $this->_pathsep . $file))
                return $dir;
        } elseif (@file_exists("$dir/$file"))
            return $dir;
    return false;

Where exactly do you change this? (What file?)

I found it… pretty obvious since the path to the file is given in the errors… lib/FileFinder.php.


Leave a comment