johnSTK Posted April 18, 2008 Share Posted April 18, 2008 I recently installed APC on my development server so that I could optimize my PHP code in the context of APC running. I found that when I use an include() statement with a relative path, PHP will generate a warning that it can't find the specified file as it tries each path in the include_path settings, until it finally finds it. This doesn't happen when APC is not installed, since PHP expects that the specified file to include won't be found in every path in the include_path! I can suppress the warnings, but I would rather show all real warnings while I'm developing. Is there any way to prevent these warnings from being generated, or are my only options to either ignore the warnings or use the absolute path? Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/ Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 This issue seems to be a 3rd party issue. Maybe you would have better luck in that forum. Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/#findComment-520727 Share on other sites More sharing options...
johnSTK Posted April 18, 2008 Author Share Posted April 18, 2008 This issue seems to be a 3rd party issue. Maybe you would have better luck in that forum. Hi jonsjava, Thanks for replying -- Could you help me by specifying which one do you mean? It's not really a third party script and there doesn't appear to be a forum for alternative PHP cache or for help with 3rd party extensions. Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/#findComment-520737 Share on other sites More sharing options...
jonsjava Posted April 18, 2008 Share Posted April 18, 2008 Third Party PHP Scripts Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/#findComment-520738 Share on other sites More sharing options...
PFMaBiSmAd Posted April 18, 2008 Share Posted April 18, 2008 APC is not a script. It is an official PHP language extension. This is not really any different than asking a GD image question. If you were to post a sample script and the actual error message generated by that script, someone already using APC could duplicate the problem and perhaps pin down if this is specific to your system or an APC/PHP problem. Also, what operating system, web server and version, is php installed as a server module or a CGI wrapper, and php version? Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/#findComment-520757 Share on other sites More sharing options...
johnSTK Posted April 18, 2008 Author Share Posted April 18, 2008 APC is not a script. It is an official PHP language extension. This is not really any different than asking a GD image question. If you were to post a sample script and the actual error message generated by that script, someone already using APC could duplicate the problem and perhaps pin down if this is specific to your system or an APC/PHP problem. Also, what operating system, web server and version, is php installed as a server module or a CGI wrapper, and php version? I thought third-party scripting was an odd place for the question -- after all, APC is not only an extension, but is going to be included with PHP 6. Well here's an example: document root is: /var/www/vhosts/myhostname/httpdocs/ testinclude.php is in library, or more specificically /var/www/vhosts/myhostname/httpdocs/library index.php includes testinclude.php and is in /var/www/vhosts/myhostname/httpdocs Absolute path (no problems): include('/var/www/vhosts/myhostname/httpdocs/library/testinclude.php'); Relative path (problems only with APC installed): set_include_path(get_include_path() . PATH_SEPARATOR . '/var/www/vhosts/myhostname/httpdocs/library'); include 'testinclude.php'; it generates these two messages before it finally finds the file in the library folder from the include path Warning: include() [function.include]: Unable to access ./testinclude.php in /var/www/vhosts/myhostname/subdomains/beta/httpdocs/index.php on line 5 Warning: include() [function.include]: Unable to access /testinclude.php in /var/www/vhosts/myhostname/subdomains/beta/httpdocs/index.php on line 5 So it checks ./testinclude.php and /testinclude.php before checking paths inside include_path, as expected, but generates error messages, which are not expected. If I turn off APC, the warning messages go away. System: Linux 2.6.9-023stab044.4-enterprise Server Software: Apache 2.2.3 (CentOS) PHP version: 5.2.5 APC version: 3.0.18 PHP is a server module This is my /etc/php.d/apc.ini file: extension = apc.so apc.enabled = 1 apc.shm_size = 48 apc.include_once_override = 0 apc.mmap_file_mask = /tmp/apc.XXXXXX apc.stat = 1 Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/#findComment-520771 Share on other sites More sharing options...
PFMaBiSmAd Posted April 18, 2008 Share Posted April 18, 2008 I recommend not bothering with the include_path. I suspect the problem is a bug (I searched for those symptoms and did not find any matching bug report) in getting/using the cwd and the code forgetting it is actually searching the include_path and it is not an error unless it does not find the file on any of the paths. Use $_SERVER['DOCUMENT_ROOT'] and your path/file - include($_SERVER['DOCUMENT_ROOT'] . '/library/testinclude.php'); Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/#findComment-520823 Share on other sites More sharing options...
johnSTK Posted April 19, 2008 Author Share Posted April 19, 2008 I recommend not bothering with the include_path. I suspect the problem is a bug (I searched for those symptoms and did not find any matching bug report) in getting/using the cwd and the code forgetting it is actually searching the include_path and it is not an error unless it does not find the file on any of the paths. Use $_SERVER['DOCUMENT_ROOT'] and your path/file - include($_SERVER['DOCUMENT_ROOT'] . '/library/testinclude.php'); Hi PFMaBiSmAd, Thanks for the response. I also couldn't find any bug reports about this. What you suggest works OK for my own files, but doesn't work easily if I want to use third party frameworks. For example, the Zend Framework has many different require_once() calls throughout the framework. It's still feasible (e.g. with a search and replace through all of the files each time a new version of the framework is used), but a bit of a pain. What I've decided to do instead is rather than displaying all errors when I am in debug mode is turn on a custom error handler for warnings and basically filter out this style of warning. Hopefully this will eventually get fixed (and I'll try to report it as a bug to the project). Link to comment https://forums.phpfreaks.com/topic/101776-apc-generates-unnecessary-php-warnings-with-include/#findComment-520877 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.