While running:

drush.php @server_master provision-verify

This resulted in a stacktrace with:

SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'aegirvm01' (110)
PHP Fatal error:  Call to a member function quote() on a non-object in ~/.drush/provision/db/db.drush.inc on line 329
verify_server_cmd

This would have been more clear if the connection error had been handled. I've attached a patch to do this.

Adding a new error message for this seems over the top, as connect() already reports the error. I've however grown a bit paraniod since I discovered in #1102620: provision-deploy fails silently on unavailable database that a connection attempt to the _null service is silently ignored.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

helmo’s picture

After fixing the underlying firewall issue I noticed that the above patch still reports an error.

I had just assumed connect() would have a positive return value on success. It unfortunately didn't :(

I've attached an additional patch which shows the problem area, but this opens up a more fundamental discussion ....

My point is that I don't want to get a "Call to a member function quote() on a non-object" fatal error when my database is unreachable.

anarcat’s picture

Status: Active » Needs review
Issue tags: +aegirWTF

Please set patches to need review when you submit them.

I agree this is a fairly common "aegir WTF" that should be fixed. Maybe we want to make sure the object returned by PDO is correct? Is $this->conn a valid truth value as things stand?

helmo’s picture

$this->conn is an object of class PDO, I has kind of assumed it to be a MySQL link identifier.
As this evaluates to true it still has the desired effect.

But in the spirit of OO I guess we could just return ($this->conn instanceof PDO); which is more explicit anyway.

anarcat’s picture

Status: Needs review » Fixed

Makes sense - it's good to have the db object anyways. Fixed and merged in stable.

Status: Fixed » Closed (fixed)
Issue tags: -aegirWTF

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