PHP filemtime函数 – “stat failed for”

前端之家收集整理的这篇文章主要介绍了PHP filemtime函数 – “stat failed for”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有 PHP filemtime函数的问题.在我的webapp中,我使用Smarty模板引擎和缓存选项.在我的webapp中,我可以做一些产生错误的动作,但是我们只关注一个动作.当我点击页面上的链接时,某些内容会更新 – 我可以点击几次,一切正常但是10上的一个请求失败了.发生以下错误
filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat Failed for

以及导致问题的那一行:

return ($_template->getCachedFilepath() && file_exists($_template->getCachedFilepath())) ? filemtime($_template->getCachedFilepath()) : false ;

如您所见,文件存在,因为它已被选中.

有问题的代码行包含在smarty_internal_cacheresource_file.PHP中(Smarty lib v3.0.6的一部分)

App在UNIX系统上运行,外部托管.

有任何想法吗?我应该发布更多细节吗?

file_exists在内部使用 access系统调用,它将权限检查为真实用户,而filemtime使用 stat,它将检查作为有效用户.因此,问题可能源于有效用户==真实用户的假设,而这种用户并不成立.另一种解释是文件在两次调用之间被删除.

由于$_template-> getCachedFilepath()的结果和文件的存在都可以在系统调用之间发生变化,为什么要调用file_exists呢?相反,我建议只是

return @filemtime($_template->getCachedFilepath());

如果$_template-> getCachedFilepath()可以设置为虚拟值,例如false,请使用以下命令:

$path = $_template->getCachedFilepath();
if (!$path) return false;
return @filemtime($path);
原文链接:https://www.f2er.com/php/137699.html

猜你在找的PHP相关文章