Hi,

After an upgrade to PHP5.3 on Omega8 I got the following error on a live website:

Fatal error: Call to undefined function list_themes() in /data/disk/o4843680964/static/heritage-1.0/sites/all/modules/contrib/xautoload/lib/DrupalExtensionSystem.php on line 10

I solved the issue by manually loading theme.inc at the top of xautoload.module:

require_once DRUPAL_ROOT . '/includes/theme.inc';

Does this seems a reliable solution to you? Is it possible to include this in the module?

cheers,

Thomas

Comments

donquixote’s picture

Title: Fatal error on Omega8 hosting » Premature calling of list_themes()

Interesting.

XAutoload tries to be clever when deciding what to do at which time.
E.g. it tries to have the boot modules already available, even while the other modules are still loading.

In case of themes, this apparently is not implemented correctly. I should add a function_exists(), or some other way to make sure that themes are available when I call list_themes().

Which module was it that tries to load a class at this time?

If we figure this out quickly, I might produce a hotfix in the next days.

donquixote’s picture

Also, consider the following situation:

1. Bootrap phase, no themes available, class_exists() returns false.
2. xautoload remembers that the class does not exist, or even that a theme with this name does not exist.
3. Themes are loaded.
4. Another time you try class_exists(), and this time the class should exist, but xautoload still remembers that it originally failed.

So...
- whenever new namespaces are added, xautoload cache needs to "forget" any previous lookups within those namespaces.
- whenever the state of drupal changes, so that new modules or themes become available, xautoload needs to forget previous lookups on those modules and themes.

This is all possible, but I need to think more about it.

donquixote’s picture

Status: Active » Needs review
StatusFileSize
new443 bytes

Here is a minimal patch.

In the only case where the patch makes a difference, it would crash otherwise.
So it should not have any side effects.

Can you test?
We probably need to do more thinking here, but as a hotfix this seems reasonable.
(hotfix = to make a new stable with this fix included within the next days)

Anonymous’s picture

Hi donquixote,

Thank you for your amazingly quick reply. I'll check it today and let you know.

Anonymous’s picture

Hi donquixote,

Your patch seems to work. You can check the working site at http://dev.xautoload.o4843680964.v242a.ams.host8.biz/

cheers,

Thomas

donquixote’s picture

Thanks for testing! And nice website :)

What do you use xautoload for? Module dependencies? External libraries?
What is it that wants to load a class before themes are set up?
The more information I have about use cases, the better I can make this module :)

donquixote’s picture

Title: Premature calling of list_themes() » Premature calling of list_themes() (caused Fatal error)
Status: Needs review » Fixed
Anonymous’s picture

Thanks for the hotfix!

We currently use X Autoload for the module Menupoly. It integrates very well with Crumbs :-)

I'm not very sure what wants to load classes before the themes. Perhaps it's a caching algorythm at Omega8 that makes this happen, but I'm just guessing in the dark. They use PHP-FPM 5.3.17 with APC, Memcached, UploadProgress, ImageMagick, Suhosin and ionCube, combined with Nginx. Could that be the cause?

EDIT: Btw, the fatal error didn't occur on our development server. To compare, we use Apache 2.2 + PHP-FPM 5.3.10-1ubuntu3.4 with Suhosin-Patch over FastCGI, combined with some APC and Memcached.

Status: Fixed » Closed (fixed)

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