PHP’s ‘magic_quotes_gpc’ and ‘magic_quotes_runtime’ settings are not supported and must be disabled.

Yesterday I reproted the first problem I encountered during Drupal 8 installation.

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or ‘(‘ in /public_html/core/includes/bootstrap.inc on line 3

Above problem is gone when I upgraded to PHP 5.3.

The next problem I faced is following PHP Error

PHP's 'magic_quotes_gpc' and 'magic_quotes_runtime' settings are not supported and must be disabled.

PHP’s ‘magic_quotes_gpc’ and ‘magic_quotes_runtime’ settings are not supported and must be disabled.

Ok, it’s no big deal, just turn it off in php.ini file either in master file in Linux or local file in the install directory.

However when I checked phpinfo output both of these values are set to off.

magic_quotes_gpc and 'agic_quotes_runtime are Off
magic_quotes_gpc and ‘agic_quotes_runtime are Off

Now this is really weird, when script sees these values Off then why it reports error?

On top of that there is already these settings available in .htaccess file in Drupal root.

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag magic_quotes_sybase off
php_flag register_globals off
php_flag session.auto_start off
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off
</IfModule>

Investigation is still on.

The Solution

It seems setting these values off didn’t work. So the solution was to comment out this checking in Drupal code.

Open /core/includes/bootstrap.inc file search for following code

[sourcecode]// Deny execution with enabled "magic quotes" (both GPC and runtime).
if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
header($_SERVER[‘SERVER_PROTOCOL’] . ‘ 500 Internal Server Error’);
print "PHP’s ‘magic_quotes_gpc’ and ‘magic_quotes_runtime’ settings are not supported and must be disabled.";
exit;
}[/sourcecode]

Comment out entire if statement as shown below
[sourcecode]
// Deny execution with enabled "magic quotes" (both GPC and runtime).
/*if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
header($_SERVER[‘SERVER_PROTOCOL’] . ‘ 500 Internal Server Error’);
print "PHP’s ‘magic_quotes_gpc’ and ‘magic_quotes_runtime’ settings are not supported and must be disabled.";
exit;
}*/
[/sourcecode]