PHP Fatal error: Unsupported operand types in /Users/mahfuz/drush/includes/sitealias.inc on line 1467
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Unsupported operand types in
/Users/mahfuz/drush/includes/sitealias.inc, line 1467

function drush_convert_db_from_db_url($db_url) {
  if (is_array($db_url)) {
    $url = parse_url($db_url['default']);
  }
  else {
    $url = parse_url($db_url);
  }
  // Fill in defaults to prevent notices.
  $url += array(
    'driver' => NULL, 
    'user' => NULL, 
    'pass' => NULL, 
    'host' => NULL, 
    'port' => NULL, 
    'path' => NULL, 
    'database' => NULL,
  );
  $url = (object) array_map('urldecode', $url);
  return array(
    'driver' => $url->scheme == 'mysqli' ? 'mysql' : $url->scheme, 
    'username' => $url->user, 
    'password' => $url->pass, 
    'port' => $url->port, 
    'host' => $url->scheme == 'sqlite' ? '' : $url->host,
    // Remove leading / character from database names, unless we're installing
    // to SQLite (which won't have a slash there unless it's part of a path). 
    'database' => $url->scheme == 'sqlite'  ? $url->host  . $url->path : substr($url->path, 1),
  );
}

$url += array(

its creating problem

Comments

greg.1.anderson’s picture

Status: Active » Postponed (maintainer needs more info)

What version of php are you running? If you rewrite this as $url = $url + array(, does it fix your problem?

MechanicJay’s picture

I just upgraded from drush 4.5 to 5.1 and am getting this error as well.

[code]
-bash-4.1$ php --version
PHP 5.3.3 (cli) (built: Feb 3 2012 02:39:26)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[/code]

I have tried the above fix and that has no effect.

This failure was seemingly random for me, sometimes showing up, other times I was getting an exception about not being able to contact the database.

What was causing the error is the randomly generated mysql user password I am passing to drush via the --db-url parameter. If the password has characters other than a-z,A-Z,0-9, drush may, and many times does choke. The character "/" appears to be the culprit, but I've seen spaces do it as well.

This behavior did not occur with drush 4.5.

MechanicJay’s picture

My apologies, This fails with drush 4.5 as well -- apparently, I was lucky enough not to have had a "/" in any of my random passwords for quite some time.

Regardless, perhaps some error checking upfront on the inputs might help here.

greg.1.anderson’s picture

Considering that the format of a db-url is mysql://user:password@localhost/dbname, you would, it seems, have to have problems if you replaced "password" with a string that included a non-escaped slash. Are you perhaps escaping the slash? I would expect drush-4 to fail otherwise as well. I am using non-alphanumeric mysql passwords with Drush-5, and they work fine. Perhaps you could provide the exact commandline you are entering to cause this failure?

kotnik’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

This error pops up when Drush gets wrong db-url parameter. Happened to me when I typed mysql://user:password@localhost:dbname (notice semicolon instead of /) by mistake.

ckhung’s picture

Version: » 7.x-5.4
Issue summary: View changes

In my case it was caused by special characters in mysql password. In my original mysql password there were these special characters ';/[]' and I saw exactly the same error message '... line 1467'. After changing the password to something else more acceptable (containing these other special characters ':?{}' by the way), this error message goes away and I am able to install with the command drush site-install ... --db-url=mysql://root:'ACCEPTABLE_PASSWORD'@localhost/drupal7