PHP中的设置包含路径间歇性失败

时间:2022-08-27 23:14:26

I have tried both of :

我试过了两个:

ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes');

and also :

并且 :

php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes"

in the .htaccess file.

在.htaccess文件中。

Both methods actually do work but only intermittently. That is, they will work fine for about 37 pages requests and then fail about 42 pages requests resulting in an require() call to cause a fatal error effectively crashing the site.

这两种方法实际上都是有效的,但只是间歇性的。也就是说,它们可以在大约37页的请求中正常工作,然后大约42页请求失败,导致require()调用导致致命错误,从而有效地使站点崩溃。

I'm not even sure where to begin trying to find out what is going on!

我甚至不确定从哪里开始试图找出发生了什么!


@cnote

Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.

看起来您复制了包含路径中的当前目录。尝试从字符串中删除其中一个'。:'。

The in script version was originally

脚本版本最初是

ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'classes');

and thus the .:.: was coming from the existing path:

因此。:。:来自现有的道路:

ini_get('include_path')

I tried removing it anyway and the problem persists.

无论如何我尝试删除它,问题仍然存在。

3 个解决方案

#1


3  

It turned out the issue was related to a PHP bug in 5.2.5

原来这个问题与5.2.5中的PHP错误有关

Setting an "admin_flag" for include_path caused the include path to be empty in some requests, and Plesk sets an admin_flag in the default config for something or other. An update of PHP solved the issue.

为include_path设置“admin_flag”会导致某些请求中的include路径为空,而P​​lesk会在默认配置中为某些内容设置admin_flag。 PHP的更新解决了这个问题。

http://bugs.php.net/bug.php?id=43677

#2


4  

Have you tried set_include_path()?. As a benefit this returns false on failure, allowing you to at least catch the occurence and generate some meaningful debug data. Additionally, you should be using the constant PATH_SEPARATOR as it differs between windows / *nix.

你试过set_include_path()吗?作为一个好处,它在失败时返回false,允许您至少捕获出现并生成一些有意义的调试数据。此外,您应该使用常量PATH_SEPARATOR,因为它在windows / * nix之间不同。

As a specific example:

作为一个具体的例子:

set_include_path('.' . PATH_SEPARATOR . './app/lib' . PATH_SEPARATOR . get_include_path());

(the get_include_path() on the end means whatever your ini / htaccess path is set to will remain)

(末尾的get_include_path()意味着你的ini / htaccess路径设置为将保留)

#3


0  

Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.

看起来您复制了包含路径中的当前目录。尝试从字符串中删除其中一个'。:'。

#1


3  

It turned out the issue was related to a PHP bug in 5.2.5

原来这个问题与5.2.5中的PHP错误有关

Setting an "admin_flag" for include_path caused the include path to be empty in some requests, and Plesk sets an admin_flag in the default config for something or other. An update of PHP solved the issue.

为include_path设置“admin_flag”会导致某些请求中的include路径为空,而P​​lesk会在默认配置中为某些内容设置admin_flag。 PHP的更新解决了这个问题。

http://bugs.php.net/bug.php?id=43677

#2


4  

Have you tried set_include_path()?. As a benefit this returns false on failure, allowing you to at least catch the occurence and generate some meaningful debug data. Additionally, you should be using the constant PATH_SEPARATOR as it differs between windows / *nix.

你试过set_include_path()吗?作为一个好处,它在失败时返回false,允许您至少捕获出现并生成一些有意义的调试数据。此外,您应该使用常量PATH_SEPARATOR,因为它在windows / * nix之间不同。

As a specific example:

作为一个具体的例子:

set_include_path('.' . PATH_SEPARATOR . './app/lib' . PATH_SEPARATOR . get_include_path());

(the get_include_path() on the end means whatever your ini / htaccess path is set to will remain)

(末尾的get_include_path()意味着你的ini / htaccess路径设置为将保留)

#3


0  

Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.

看起来您复制了包含路径中的当前目录。尝试从字符串中删除其中一个'。:'。