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.]

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

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?

markus_petrux’s picture

Priority: Critical » Normal
Status: Active » Closed (duplicate)
Vacilando’s picture

@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.inc is 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.

markus_petrux’s picture

Status: Closed (duplicate) » Fixed

@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:

 function 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.

Vacilando’s picture

@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.

markus_petrux’s picture

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.

Vacilando’s picture

Project: Content Construction Kit (CCK) » Memcache API and Integration
Version: 6.x-2.5 » 6.x-1.x-dev
Component: content.module » Code
Status: Fixed » Active

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: php
require_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
kenorb’s picture

The same problem.
When cache is cleared, memcache trying to execute theme() function on shutdown:

9	2.5519	9357860	memcache_admin_shutdown( )	../memcache_admin.module:0
10	2.5523	9357860	theme( 'item_list', array () )	../memcache_admin.module:238

On Apache, current dir is changed on shutdown and it's not pointing to Drupal directory (it's by design).
Possible solutions:
- this theme() function should be removed
- this function shouldn't be called on shutdown
- directory should be changed back to Drupal root, but it doesn't make sense to theme something on shutdown

Equinger’s picture

Subscribed.

Macronomicus’s picture

Same thing here. >_<

iestevao’s picture

I've detected a few days ago the same error after installing memcache and enable statistics at the bottom of each page.
I have Drupal 6.16 and Memcache Admin 6.x-1.4 installed.
Add the following condition to theme registry:

if (function_exists('theme_get_registry') && theme_get_registry()) {
        foreach ($_memcache_statistics as $stat => $value) {
          $stats[] = "<strong>$stat:</strong> ". theme('item_list', $value);
        }
        if (!empty($stats)) {
          $output = theme('item_list', $stats);

          // this makes sure all of the HTML is within the <body> even though this <script> is outside it
          print '<div id="memcache-devel"><h2>'. t('Memcache statistics'). '</h2>'. $output. '</div>';
        }
}
chrishaslam’s picture

I've experienced the same issue here, disabling 'show memcache statistics at the bottom of each page' at admin/settings/memcache fixed the issue for me.

Daniel Norton’s picture

++

kenorb’s picture

Priority: Normal » Critical

The same problem again. This time my website is broken and is not loading.
Why you theme anything on shutdown?

webwriter’s picture

Same issue. Subscribe.

webwriter’s picture

Ok, I've now spent HOURS trying to put my site back together after this error. No matter what I do, turning on CCK now gives me the error and whitescreen.

I do not see a memcache admin table in my database. I have deleted the module code, removed the reference to it in my system table, removed the info from my settings.php file and I am still unable to turn CCK on.

Where else has this module modified my installation?

Argh!!

Nevermind, I'm going to restore from 2 nights ago backup. This is just insane.

dalejung’s picture

Here's the fix that iestevao posted but written as a simple guard.

http://bitbucket.org/dalejung/hookdrupal/changeset/416545384c68

kenorb’s picture

Status: Active » Needs work
kenorb’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

FileSize
954 bytes

Here's dalejung's change as a patch file.

eric.chenchao’s picture

Subscribed

robertDouglass’s picture

FileSize
949 bytes

I don't think we should be calling theme_get_registry() from our stats shutdown function. So if the theme function ain't there, we get the heck out and just don't show stats.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #22 doesn't work, as the theme_get_registry() function should always available by this point; we also need to ensure the registry is not empty to avoid the error, which the patch in #20 does - in D6, theme_get_registry() is just a static cache function, it doesn't invoke any hooks.

Devel uses the same approach in its shutdown handler: http://drupalcode.org/viewvc/drupal/contributions/modules/devel/devel.mo...

Marking #20 as RTBC for D6. Is this also an issue in D7? theme_get_registry() is more complicated there and I'm not sure the same fix is viable.

bibo’s picture

subscribe.

It seems I have (almost) the same error with the latest 6.x-1.x-dev (and 1.6):
require_once(./sites/default/modules/contrib/date/date/date.theme) [function.require-once]: failed to open stream: No such file or directory in file xxxx/sites/default/modules/contrib/date/date/date.module on line 260.

It stops when i disable memcache_admin. I wonder why there arent more people reporting the same issue?

geerlingguy’s picture

Same problem here. Annoying as heck. I'll try the patch in #22 and see if that fixes it.

[Edit: Patch in #22 didn't fix the problem... but disabling memcache_admin did. Go figure. This seems to happen only when I clear all the caches via admin_menu, or when my cron script hits the cron.php file.]

[Edit 2: (thanks to longwave's suggestion below) Patch in #20 fixes the problem.]

longwave’s picture

@geerlingguy: the patch in #22 doesn't work, try #20 instead.

forestmonster’s picture

Subscribing, thanks.

Jeremy’s picture

Priority: Critical » Major
Status: Reviewed & tested by the community » Needs work

I confirmed that a similar patch is in the devel module, and applied it locally:
http://drupal.org/cvs?commit=438212

However in further testing, I realized that the stats were _never_ showing up, so I backed the patch back out:
http://drupal.org/cvs?commit=438216

There appears to be another unrelated issue in which the theme is getting broken, not introduced by this patch (it happens with or without this patch being applied.)

longwave’s picture

Status: Needs work » Needs review
FileSize
1.07 KB

@Jeremy: your commit didn't work because the logic test is backwards. The attached patch reverses this and fixes the problem.

The easiest way to test this is with both CCK and Memcache installed on a site, disable the statistics at /admin/settings/memcache, save changes, enable the statistics and save changes again. Without the patch, a require_once error is logged to the watchdog, but with the patch in place the error does not occur.

stacysimpson’s picture

Status: Needs review » Reviewed & tested by the community

This error started showing up on our site after installing memcache. I can confirm that the patch in #29 resolves the issue for our scenario.

mkinnan’s picture

I can also confirm that I started getting this error as soon as memcache was installed. The patch in #29 was applied and the error is now gone.

catch’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed this to 6.x, moving to 7.x in case it's also needed there.

catch’s picture

Status: Patch (to be ported) » Fixed

Committed to 7.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.