Issues when having a DB with custom port

Community Support for Booked Scheduler
Post Reply
Posts: 1
Joined: Wed Oct 21, 2020 7:28 pm

Issues when having a DB with custom port

Post by dsferruzza »


Today I experienced an issue when moving my MySQL database to a new server.
The new server is not on the default MySQL port, so I used mydomain:myport in $conf['settings']['database']['hostspec'].

After that, everything got weird: loading was hanging and I saw some PHP FPM timeouts.
I found this issue:
I managed to fix it the same way and it seems to works now!

Here is the diff of what I did:

Code: Select all

diff --git a/lib/Database/MySQL/MySqlConnection.php b/lib/Database/MySQL/MySqlConnection.php
index f8df9b5e5b5f2edfd13d9baf3364de52e37d09b7..0027caf575adfb37839a2bf22c9cc6839097ad1d 100644
--- a/lib/Database/MySQL/MySqlConnection.php
+++ b/lib/Database/MySQL/MySqlConnection.php
@@ -50,14 +50,15 @@ class MySqlConnection implements IDbConnection
 		$port = null;
+		$hostSpec = $this->_hostSpec;
 		if (BookedStringHelper::Contains($this->_hostSpec, ':'))
             $parts = explode(':', $this->_hostSpec);
-            $this->_hostSpec = $parts[0];
+            $hostSpec = $parts[0];
             $port = intval($parts[1]);
-		$this->_db = @mysqli_connect($this->_hostSpec, $this->_dbUser, $this->_dbPassword, $this->_dbName, $port);
+		$this->_db = @mysqli_connect($hostSpec, $this->_dbUser, $this->_dbPassword, $this->_dbName, $port);
 		$selected = @mysqli_select_db($this->_db, $this->_dbName);
 		@mysqli_set_charset($this->_db, 'utf8');
Could you consider fixing this issue in the next release? (I could not find where to make a PR)

Post Reply