级联的奇怪行为包括(2 个服务器的行为不同)
我们重现了我们的一台生产服务器上发生的一种错误。事情是这样的:
我们有 3 个 PHP 文件
test1.php :
Test 1
<?php require_once('test2.php'); ?>
test2.php :
Test 2
<?php require_once('test3.php'); ?>
test3.php
Test 3
include_path在两台服务器上都是相同的,并且由于其他原因不包含点:
php_value include_path /var/www/xxxxxx/php/ZendFramework/1.11.x/:/var/www/xxxxxx/php/
On我们的开发服务器一切都很好(输出 Test 1 Test 2 Test 3),在线,当我们上传文件时,第一次加载 /test1.php,没问题,第二次调用,依此类推,我们得到:
测试 1 测试 2
警告:require_once(test3.php) [function.require-once]: 失败 打开流:第 2 行没有此类文件或目录
致命错误:require_once() [function.require]:打开失败 需要“test3.php” (include_path='/var/www/xxxxxx/php/ZendFramework/1.11.x/:/var/www/xxxxxx/php/') 在第 2 行
除了 include_path 之外,还有其他我们应该知道的事情会影响 PHP 中包含文件的行为吗?由于我目前无法访问服务器配置文件,因此我必须区分可能发生的情况。为什么它第一次在生产服务器上运行并且之后失败?我只是无法解释它可能是什么。
编辑:有时我们还会在错误消息中收到奇怪的字符(以及每次刷新时的更改):
[...] 第 4 行 °µ4ª 中没有此类文件或目录
We reproduced a kind of error that occurs on one of our production servers. Here how it goes :
We have 3 PHP files
test1.php :
Test 1
<?php require_once('test2.php'); ?>
test2.php :
Test 2
<?php require_once('test3.php'); ?>
test3.php
Test 3
include_path is the same on both servers, and the dot is not included in it for other reasons :
php_value include_path /var/www/xxxxxx/php/ZendFramework/1.11.x/:/var/www/xxxxxx/php/
On our dev server everything is fine (outputs Test 1 Test 2 Test 3), online, when we upload files, the first time we load /test1.php, it is ok, the second call and so on we get :
Test 1 Test 2
Warning: require_once(test3.php) [function.require-once]: failed to
open stream: No such file or directory in on line 2Fatal error: require_once() [function.require]: Failed opening
required 'test3.php'
(include_path='/var/www/xxxxxx/php/ZendFramework/1.11.x/:/var/www/xxxxxx/php/')
in on line 2
Are there any other things we should know about that affects the behaviour of including files in PHP, other than include_path? It's had for me to distinguish what can happen as I don't have access to servers config files for the moment. And why it works the very first time on production server and fails after ? I just can't explain what it could be.
Edit : We also get strange characters sometimes in the error message (and the change at each refresh):
[...] No such file or directory in °µ4ª on line 4
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用什么版本控制软件?过去我们在使用 Perforce 时遇到过问题,其中我们从开发集成到产品,并且文件没有复制到所有负载均衡器。第一次进行故障排除很棘手,因为这似乎是一个不一致的 PHP 错误,并且根据您正在检查的生产服务器,该文件很可能在那里。
What version control software are you using? We've had issues in the past with Perforce in which we integrate from dev to prod and the file doesn't get copied to all of the load balancers. It's tricky to troubleshoot the first time because it seems to be an inconsistent PHP error and depending on what production server you are checking, the file will most likely be there.