When the Devel module is enabled, the _background_process_cwdfix() function throws this error: "Warning: include_once(./includes/unicode.entities.inc): failed to open stream: No such file or directory in /path/to/drupal/includes/unicode.inc on line 339".

This led to some amusing heisen-bugs in some AJAX I was trying to debug today.

The problem seems to be related to the use of $_SERVER['PHP_SELF'] to determine the current working directory, though I haven't determined why it breaks with Devel enabled but not without. Devel doesn't apparently manipulate server variables, but it does do strange things like registering shutdown functions in hook_exit.

This can be fixed by using $_SERVER['SCRIPT_FILENAME'] to calculate the current directory instead. Patch attached.

p.s. Thanks for the great work on Background Process and Ultimate Cron. They really saved my bacon on my current project.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gielfeldt’s picture

Assigned: Unassigned » gielfeldt

Hi David

Glad to hear my modules are useful,

It's funny regarding PHP_SELF, because I actually started out using SCRIPT_FILENAME. However, I read that SCRIPT_FILENAME might not always be available as it is webserver dependent, whereas PHP_SELF is supposed to always be available as it is set by the PHP interpreter.

I'll look into the matter to see what the problem is and/or if I can switch to SCRIPT_FILENAME or perhaps store PHP_SELF somewhere in an earlier phase.

gielfeldt’s picture

Hmmm... having looked at it more closely, I don't see how this cwdfix function can work at all :-)

I may have to switch to SCRIPT_FILENAME as you suggest.

Investigation in progress ...

gielfeldt’s picture

FileSize
697 bytes

Hi again

Could you try this patch? I've tried to adopt the Drupal 7 way of dealing with this issue.

EDIT: The reason I want to avoid using SCRIPT_FILENAME is because of potential platform issues.

patrickd’s picture

what about
isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['PHP_SELF']?

gielfeldt’s picture

Yes, I thought about that. The problem is that PHP_SELF doesn't really work I think. It doesn't contain the full path (at least not on my system), so that's why I don't understand it has worked at all :-)

I'm more inclined to lean towards the Drupal 7 way, as this probably has been thought through (or at least I hope so :-))

davideads’s picture

I will try the patch when I'm at work, which looks like the right way to go.

I don't think using PHP_SELF will work at all, as it is relative to the document root. I also remain baffled that I saw the error with devel enabled but not without. I'd say it was something to do with the error handler, but in my dev environment I've got the PHP error settings set to print darn near everything.

davideads’s picture

The new patch appears to be working fine.

gielfeldt’s picture

Great. I will commit it soon. Be aware, that if you update to 6.x-1.x-dev, there are some changes that requires that no there are no cron jobs running while updating.

gielfeldt’s picture

Status: Active » Fixed

Committed to 6.x-1.x-dev

orjantorang’s picture

6.x-1.x-dev works perfect.
I had trouble on WampServer (Windows 7, PHP 5.3.4) and on one Debian server running LiteSpeed with PHP 5.2.17, but 6.x-1.10 was working perfectly on a Debian with LiteSpeed and PHP 5.3.3-7+squeeze3.

Now it's running on all my servers, thanks for a great module!

Status: Fixed » Closed (fixed)

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