apache segfaults when we have register_globals turned on with php 5.3. I know we should not do that, and we have it off now, but some of our very old code needs it. Anyone have any hints on what to try/look at to solve this?

thanks

link|improve this question

56% accept rate
feedback

2 Answers

up vote 4 down vote accepted

the patchwork approach
You can include some code in the very beginning of the very old script you can use one of the well known register_global compatibility code you can find googling.

An example may be:

// ################# :: Register Globals Compatibility :: #################
$globals_test = @ini_get('register_globals');
if ( isset($globals_test) && empty($globals_test) ) {
// These still need some work :: Cookie|Server|Env are ok now.
if ( !empty($HTTP_GET_VARS) )  { extract($HTTP_GET_VARS, EXTR_SKIP);  }
if ( !empty($HTTP_POST_VARS) ) { extract($HTTP_POST_VARS, EXTR_OVERWRITE); }
define('_GLOBALS', FALSE);
} else {
    define('_GLOBALS', TRUE);
}

The autopatchwork approach

You can add:

php_value   auto_prepend_file  "/path/to/file/with_the_above_code"

to your .htaccess or VirutualHosts section in order to automagically do the job without the need of touch any existing script.

The judicious approach
The best thing of course would be rewrite the old code, as register_globals is a well known evil.

link|improve this answer
feedback

thanks for this. We set it in the .htaccess file for the dir where the old code was, it was luckily contained in one dir. This doesn't seem to crash php, so it is a weird combination of certain code + the setting I'm guessing.

link|improve this answer
so you can accept the answer? :P – AlberT Aug 28 '09 at 17:55
I accepted it, but in our case we used this in the .htaccess: php_value register_globals on – datadevil Sep 15 '09 at 8:56
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.