I have successfully installed and configured Drush and i am able to work with it.

Unfortunately, I am getting an error like this:

The following restricted PHP modes have non-empty values: magic_quotes_gpc. This configuration is incompatible with drush.

I have tried this

magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off

in my php.ini and still I am getting the error. What could be the reason? How can I fix this?

  • 1
    I know this is obvious, but just to double-check: you did reboot Apache after updating php.ini, right? – Patrick Kenny Jan 21 '13 at 7:50
  • @PatrickKenny, i tried and also uninstall Drush but i cant find any tuts to uninstall Drush – niksmac Jan 21 '13 at 8:45
  • @PatrickKenny you shouldn't need to restart Apache as drush is a command line tool - no web server needed. – Christian May 21 '13 at 2:31
  • @Christian You don't normally need to reboot Apache to use Drush but Apache only reads the php.ini file (which is part of Apache, not Drush) upon boot, so if you edit that file, you DO need to reboot Apache for Apache to pick up the changes. – Patrick Kenny May 21 '13 at 3:05
  • @PatrickKenny thats not actually correct. PHP does not need Apache at all when its being used on the command line. Do php -i on cli, get the ini being loaded, vim the ini and make some change (mem limit, sessions, whatever,) then php -i again - you'll see the changes without a restart. Apache needs to reload so that its HTTP server can see changes, cli uses no such server. – Christian May 21 '13 at 4:40

Be sure you are editing the right php.ini file. As far as I recall the file used from PHP CLI could be different from the one used from PHP when running as Apache module; plus, Drush could use a completely different file, basing on its options, or settings.

To see which php.ini file Drush is using, use drush status. Drush can use a php.ini file that is saved in the $HOME/.drush, or /etc/drush directory; it can also use a drush.ini file present in the same directories. Alternatively, the path of a php.ini, or drush.ini file to use are taken respectively from the PHP_INI, and DRUSH_INI environment variables. (See the content of the README.txt file for more information.)

The function that checks the PHP settings in the php.ini file is _drush_environment_check_php_ini(), which contains the following code.

  // Test to insure that certain php ini restrictions have not been enabled
  $prohibited_list = array();
  foreach ($ini_checks as $prohibited_mode => $disallowed_value) {
    $ini_value = ini_get($prohibited_mode);
    $invalid_value = FALSE;
    if (empty($disallowed_value)) {
      $invalid_value = !empty($ini_value);
    else {
      foreach ($disallowed_value as $test_value) {
        if (strstr($ini_value, $test_value) !== FALSE) {
          $invalid_value = TRUE;
    if ($invalid_value) {
      $prohibited_list[] = $prohibited_mode;

On my computer, the directive for which the error message is reported is set with the following line.

magic_quotes_gpc = Off

When I execute dpm(ini_get('magic_quotes_gpc')); I get 0 as output.

  • This is from my drush.ini export PHP_INI='/Applications/MAMP/bin/php/php5.4.4/conf/php.ini' and i got this ini by loading phpinfo(); – niksmac Jan 21 '13 at 8:47

Here is how i managed to fix it.

Go to drush/includes/environment.inc

Changed the line 91 from

$ini_checks = array('safe_mode' => '', 'open_basedir' => '', 
'disable_functions' => array('exec', 'system'), 'disable_classes' => '', 
'magic_quotes_gpc' => '', 'magic_quotes_runtime' => '');


$ini_checks = array('safe_mode' => '', 'open_basedir' => '', 
'disable_functions' => array('exec', 'system'));
  • This sounds like it is a bug in drush with php 5.4. I would ask this in the issue queue. – mpdonadio Feb 2 '13 at 22:27
  • 1
    @MPD Whats next ? a patch or a bug report ? Is that mean there should be some checking according to the PHP version ? – niksmac Feb 3 '13 at 3:32
  • I would open a bug report in the issue queue. When you do, post the link to the issue as a comment so people can track it. – mpdonadio Feb 3 '13 at 13:52
  • out of curiosity, Whats your OS? – saadlulu Apr 24 '13 at 13:20
  • MAC OSX 10.8.0, its very cool.. :) – niksmac Apr 24 '13 at 13:21

As your path suggests you are using PHP 5.4.4. and since PHP 5.4.0 the magic quotes are removed, so you should not even have this settings in you php.ini.

Try to comment them out and see if it helps.

Source: http://www.php.net/manual/en/security.magicquotes.php

  • I tried it and restarted MAMP. Same issue. – niksmac Feb 1 '13 at 10:54
  • Check which php.ini is actually used by drush (in other words via PHP for CLI). Type: drush st Should return something like: PHP configuration : /etc/php5/cli/php.ini (with your path) – Marcus Farrington Feb 1 '13 at 11:30

I had to make sure to put the following in my ~/.drush/drush.ini file.

magic_quotes_gpc = 0

instead of

magic_quotes_gpc = Off

While I know this is old and has been answered by some people, I have just installed the beta2 of Drush 6 and no longer have this issue.

pear channel-discover pear.drush.org
pear install drush/drush
pear install drush/drush-6.0.0

See http://drupal.org/project/drush for more info.


I know this is an old question. I was trying to setup Drupal 7.28 with Drush and facing same issue on my GoDaddy hosting. This is what I found and how I solved it:


GoDaddy uses /web/config/php.ini which has set magic_quotes_gpc = On. Even when I switch between PHP 5.2 and 5.3 cli, it uses same .ini.

Did not work:

  1. Overwriting magic_quotes_gpc = Off, alsomagic_quotes_gpc = 0 in /drush.ini, but still same error
  2. Copied /web/config/php.ini to ~/html/drush-cli-php.ini (~/html is web root in GoDaddy), commented out/removed magic_quotes_gpc statement, and used php command:

    php -c ~/html/drush-cli-php.ini

    to make php use this new ini. drush uses this php. But php -i still showed /web/config/php.ini was the first config file.

What worked:

Now I explicitly coded magic_quotes_gpc = Off in ~html/drush-cli-php.ini, and viola, it worked! This was the only parameter I coded in this ini, btw.

What I observed was, if the magic_quotes_gpc was overwritten to Off in drush.ini, it didn't work, possibly because the validation failure in drush happens before the override.

Hope this helps somebody. :)


I know this old post but what remove the error message for me was commenting out the "disable_functions =" in the "Language Options"

  • 1
    How could magic_quotes_gpc problem be solved by commenting out disable_functions? For me it looks like coincidence, or some kind of magic, unless you can provide some reasons behind that. – Mołot Nov 17 '14 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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