Hi, I am having an issue with autoload almost identical to this one: #337615: require_once failure on cron with modules that have a register_shutdown_function.

In short, I have a register_shutdown_function() in use within a Drupal module. It's an extension of the imageinfo_cache module. Here's what happens.

In my shutdown function, I am implementing Drupal Queue API, which in D6 requires me to do a drupal_queue_include(), which in turn calls autoload.

Autoload navigates down to about line 201 to here:

if ($file) {
  require_once './' . $file;
  return TRUE;
}

If I add a debug getcwd() statement in there, the working directory is "/", which means it is trying to do a require_once from the root directory instead of my drupal dir, which in turn results in this:

[Mon Oct 24 01:53:07 2011] [error] [client 1.2.3.4] PHP Fatal error:  require_once() [<a href='function.require'>function.require</a>]: Failed opening required './sites/all/modules/drupal_queue/drupal_queue.inc' (include_path='.:/usr/share/pear:/usr/share/php') in /path/to/drupal/sites/all/modules/autoload/autoload.module on line 201, referer: http://mysite.com/batch?op=start&id=3203

So... not quite sure how to solve this yet. D7 has a DRUPAL_ROOT constant but D6 does not appear to have a standardized way to get the root dir of the installed site.

Thoughts?

Comments

rjbrown99’s picture

As a workaround, since we can't add any new constants to D6 how about something in the autoload.install file that sets a variable?

variable_set('autoload_drupal_root', dirname(realpath(__FILE__)));

Then it could be an if statement to check that variable if the getcwd = / or something like that.

Edit: Hm no that just gives us the full path to the module dir. Something like that may work, though.

More options here but they seem non-ideal. This seems to be the state-of-the-art at the moment, but it seems like a relatively heavy lift in terms of what it does.

makangus’s picture

I was having the same problem with autoload loading from /.

Then somehow I decided to run the cron and it was fixed. I wonder what fixed it in the cron.