Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | provision-check_connect_in_verify_server_cmd-connect_return.patch | 458 bytes | helmo |
provision-check_connect_in_verify_server_cmd.patch | 1.09 KB | helmo |
Comments
Comment #1
helmo CreditAttribution: helmo commentedAfter 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.
Comment #2
anarcat CreditAttribution: anarcat commentedPlease 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?
Comment #3
helmo CreditAttribution: helmo commented$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.Comment #4
anarcat CreditAttribution: anarcat commentedMakes sense - it's good to have the db object anyways. Fixed and merged in stable.