Migration to PHP55 : Error Establishing a database connection

0 views
Skip to first unread message

Bitmash via StackOverflow

unread,
May 4, 2015, 8:03:35 PM5/4/15
to google-appengin...@googlegroups.com

I'll take a stab at this.

Wordpress will use MySQLi when it detects that you are using PHP >= 5.5. See https://github.com/WordPress/WordPress/blob/master/wp-includes/wp-db.php#L627 for what I mean. WP attempts to duplicate the socket detection that mysql_real_connect makes, and it does an okay job with your existing DB_HOST configuration; however, it leaves the host variable as an empty string rather than NULL after moving it to socket. mysqli_real_connect requires NULL or "localhost" for the hostname when using a socket connection. See http://php.net/manual/en/mysqli.real-connect.php about what I mean.

Doing a var_dump on the variables after the WP socket detection gives us:

array(4) { ["initial_host"]=> string(30) ":/cloudsql/project-id:instance" ["new_host"]=> string(0) "" ["port"]=> NULL ["socket"]=> string(29) "/cloudsql/project-id:instance" }

I just ran a test on my GAE app and it did throw a DB connection error because of the empty string for hostname.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/29061827/migration-to-php55-error-establishing-a-database-connection/30042049#30042049
Reply all
Reply to author
Forward
0 new messages