Fatal error opening required theme.inc in content.module
| Project: | Memcache API and Integration |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Since a few days, maybe since D6.14 or some module updates, not sure about the precise timing, my logs are full of lines such as the following one:
[27-Oct-2009 03:35:59] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required './sites/all/modules/cck/theme/theme.inc' (include_path='.:/usr/share/pear:/usr/share/php') in /PATHTOMYSITE/sites/all/modules/cck/content.module on line 177
Disabled some modules I thought could cause this but haven't found the culprit. Any ideas?
[Btw, there's a related post #615760: Enabling views crashes whole site - only plain text error message (smoking ruin) for the case that this is a D6.14 and not CCK problem.]

#1
I think both issues are the same. So marking this one as a dup of #615760: Enabling views crashes whole site - only plain text error message (smoking ruin)
AFAICT, CCK code is correct. The file should be there (it is included in the package), and it should be accesible with that statement (Drupal executes from the Drupal root, and ./sites/all/modules/cck/theme/theme.inc is relative from there), unless something odd is happening in your system. Maybe the file is not there (caused while upgrading from an earlier version? ), or maybe another module has changed the current working directory, or maybe it is a filesystem issue, permissions?
#2
#3
@markus_petrux, in fact, as thomasmurphy noted (at #615760: Enabling views crashes whole site - only plain text error message (smoking ruin)) the issue I've reported above is related to CCK while his is about Views.
Not wanting to keep toggling the status, could I ask you to reconsider and reopen this issue.
Indeed,
./sites/all/modules/cck/theme/theme.incis there on the server; checked.Filesystem perms are just like for any other file there.
No other errors like that - always this one error msg repeated in the log (see above).
If it were any less important module I'd disable it until a new version, but I obviously need CCK. So what do you recommend - what can I check for, how to find out what causes this. Thanks.
#4
@vacilando: looking at that issue, moved to the Views queue, you'll see how merlinofchaos also states it's not a problem with the module, but something else. He says, it's user error. I also add that it could be caused by another software component, or even hardware related. Please, read my second paragraph in #1.
I'm switching the issue to "fixed" so that it is more visible in the queue, but still nothing to do with CCK itself, otherwise it would be failing to everyone else, which is not the case. The require_once invocation is correct. So the problem may come from something else.
- Check the file is there.
- Check file permissions.
If that's seems correct, then it could be that another module has changed the current working directory of the process. We (and any other code in Drupal) assume the current working directory is the same directory where Drupal itself is installed, aka Drupal root. So we should be able to use relative paths that work everywhere.
Line 177 in content.module is part of content_theme() function. This is implementation of hook_theme() in content module. This function is invoked when Drupal rebuilds the Theme registry. To check if the current working directory is still Drupal root, you could do this:
<?phpfunction content_theme() {
$path = drupal_get_path('module', 'content') .'/theme';
+ drupal_set_message(t('Current working directory at content_theme() is: @cwd', array('@cwd' => getcwd())));
+ drupal_set_message(t('The real path of file @file is @path', array('@file' => "./$path/theme.inc", '@path' => realpath("./$path/theme.inc"))));
+ if (!file_exists("./$path/theme.inc")) {
+ drupal_set_message(t('File not found. @path', array('@path' => realpath("./$path/theme.inc"))));
+ }
+ elseif (!is_readable("./$path/theme.inc")) {
+ drupal_set_message(t('File is not readable. @path', array('@path' => realpath("./$path/theme.inc"))));
+ }
require_once "./$path/theme.inc";
?>
The quickest way I know of to force a Theme registry rebuild is from the icon menu in Administration menu.
#5
@markus_petrux, thanks for your exhaustive answer.
Yes, I did read your 2nd paragraph in #1, and answered it in my 3rd paragraph in #3 :-)
The solution that worked in the other issue does not apply to me as all of the files are indeed uploaded.
This leaves just one possibility, that is that something else is altering the path.
But what? What kind of modules could tinker with the current working directory? Perhaps Memcache API module which I am using? Other ideas?
Btw: all modules are up to date on my system.
Yes, I did clear the theme registry.
Thanks a lot.
#6
First thing would be to try the code I posted in #4. That should reveal if the cwd has been changed, and where it has been set.
Another thing would be to look at the Drupal logs and find these errors. Are all related to the same URL? Can you see a pattern here?
Another thing: scan the code of all module in your site for code that may alter the current working directory. Function chdir()?
Another thing: if you know how to reproduce the error, then start a debug session to find out where the cwd is being changed. This could be done adding drupal_set_message(__FILE__ .' - '. __LINE__ .' - '. getcwd()) here and there.
#7
Thanks for all recommendations. I think I've found the problem thanks to backtrace in PHP. The problem seems to be caused by Memcache API. Moving this to that module's issue queue.
Type: phprequire_once(./sites/all/modules/cck/theme/theme.inc) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /PATHTOMYSITE/sites/all/modules/cck/content.module on line 177.
Backtrace: content_theme()[content.module:177] <=content_theme(...)[theme.inc:266] <=_theme_process_registry(...)[theme.inc:399] <=_theme_build_registry(...)[theme.inc:225] <=_theme_load_registry(...)[theme.inc:179] <=_init_theme(...)[theme.inc:59] <=init_theme(Array)[theme.inc:584] <=theme(...)[memcache_admin.module:238] <=memcache_admin_shutdown(Array)[:] <=index.php