Reputation: 1
I am encountering a very strange problem after moving to PHP55.
I have a working environment both locally and deployed on PHP. After following instructions sent by Google on migrating to PHP55:
To take advantage of these new features, find your ‘app.yaml’ file and change the line that reads runtime: php to runtime: php55
The new functionality will automatically be enabled in the local development server, and in production once your application is deployed. You will be able to switch back to the old runtime at any time for the next two months by reverting the configuration in your app.yaml file. Some features such as cURL support may require additional configuration in order to be enabled.*
I hit the famous Error establishing a database connection
error.
As soon as I revert the PHP55 back to PHP in my app.yaml
file, the error goes away and the webpages load again.
Any feedback is greatly appreciated. I can share the wp-config.php if needed.
Here is the entries in app.yaml :
application: sxxxx-xxxxx version: 5 runtime: php55 api_version: 1 threadsafe: yes
handlers: - url: /(..(htm|html|css|js))$ static_files: \1 upload: ..(htm|html|css|js)$ application_readable: true
- url: /wp-content/(.*\.(ico|jpg|png|gif))$
static_files: wp-content/\1
upload: wp-content/.*\.(ico|jpg|png|gif)$
application_readable: true
- url: /(.*\.(ico|jpg|png|gif))$
static_files: \1
upload: .*\.(ico|jpg|png|gif)$
- url: /wp-admin/(.+)
script: wp-admin/\1
secure: never
- url: /wp-admin/
script: wp-admin/index.php
secure: never
- url: /wp-login.php
script: wp-login.php
secure: never
- url: /wp-cron.php
script: wp-cron.php
login: admin
- url: /xmlrpc.php
script: xmlrpc.php
- url: /wp-(.+).php
script: wp-\1.php
- url: /(.+)?/?
script: index.php
=============
Here is my unchanged wp-config.php which works with php in app.yaml, but with php55 in app.yaml, gives me the Error :
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
/** Google App Engine Settings */
define('DB_NAME', 'sadhusanga');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', ':/cloudsql/sadhu-sanga:gaura');
}
else
{
/** Local Settings */
define('DB_NAME', 'sadhusanga');
define('DB_USER', 'root');
define('DB_PASSWORD', 'xxxxxxxx');
define('DB_HOST', 'localhost');
}
Upvotes: 0
Views: 151
Reputation: 81
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.
Upvotes: 0