tags:

views:

451

answers:

4

I have tried both

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

in the code itself and also

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

in the .htaccess file.

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.

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.

A: 

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

+3  A: 

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.

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)

iAn
A: 

I have exactly the same problem! Was there ever an answer?

I find that in some requests, Apache does not set the include path and it is only filled with "." current directory. In those requests it is impossible to set_include_path().

I have a script that outputs: get_include_path();

then sets with: set_include_path([a path]);

then outputs is again with: get_include_path();

I have the same ratio; about 60% of requests succeed, but the rest fails because of an empty include-path and the inability to re-set the include path. It must be an Apache or Apache+PHP error, but I do'n know where to start looking...

FreeBSD 6.3-RELEASE-p2

Server version: Apache/2.0.61 Server built: Dec 11 2007 12:19:26

PHP Version 5.2.5

(it's a Plesk machine by the way)

Help!

Ramon de la Fuente
A: 

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

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.

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

Ramon de la Fuente