我有PHP filemtime函数的问题.在我的webapp中,我使用Smarty模板引擎和缓存选项.在我的webapp中,我可以做一些产生错误的动作,但是我们只关注一个动作.当我点击页面上的链接时,一些内容会更新 - 我可以点击几次,一切正常但是10上的一个请求失败了.发生以下错误:
filemtime() [<a href='function.filemtime'>function.filemtime</a>]: stat failed for
Run Code Online (Sandbox Code Playgroud)
以及导致问题的那一行:
return ($_template->getCachedFilepath() && file_exists($_template->getCachedFilepath())) ? filemtime($_template->getCachedFilepath()) : false ;
Run Code Online (Sandbox Code Playgroud)
如您所见,文件存在,因为它已被选中.
有问题的代码行包含在smarty_internal_cacheresource_file.php(Smarty lib v3.0.6的一部分)中
App在UNIX系统上运行,外部托管.
有任何想法吗?我应该发布更多细节吗?
phi*_*hag 10
file_exists内部使用access系统调用来检查权限作为真实用户,而filemtimeuses stat则执行检查作为有效用户.因此,问题可能源于有效用户==真实用户的假设,这是不成立的.另一种解释是文件在两次调用之间被删除.
由于$_template->getCachedFilepath()文件的结果和存在都可以在系统调用之间发生变化,为什么要调用file_exists呢?相反,我建议只是
return @filemtime($_template->getCachedFilepath());
Run Code Online (Sandbox Code Playgroud)
如果$_template->getCachedFilepath()可以设置为虚拟值false,请使用以下命令:
$path = $_template->getCachedFilepath();
if (!$path) return false;
return @filemtime($path);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23886 次 |
| 最近记录: |