From 4acb275224a5c0002b57551e85b379e49eaee196 Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:34:00 +0100 Subject: [PATCH 1/2] fix failed connection for ":/var/lib/mysql/mysql.sock" which is used to force the sock instead of TCP --- ludicrousdb/includes/class-ludicrousdb.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ludicrousdb/includes/class-ludicrousdb.php b/ludicrousdb/includes/class-ludicrousdb.php index c125dcd..49c8c7c 100644 --- a/ludicrousdb/includes/class-ludicrousdb.php +++ b/ludicrousdb/includes/class-ludicrousdb.php @@ -1303,7 +1303,8 @@ protected function single_db_connect( $dbhname, $host, $user, $password ) { $socket = substr( $maybe_socket, 1 ); } } else { - $socket = $port_or_socket; + // otherwise it will fail if the host is specified originally like ':/var/lib/mysql/mysql.sock', since we will have a port appended here still + $socket = strtok( $port_or_socket, ':' ); } } From 6a01fb4b109c0841266dcd86997ab151b5cf5a21 Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:34:41 +0100 Subject: [PATCH 2/2] fix invalid fsockopen for ports since syntax is different to mysql_real_connect --- ludicrousdb/includes/class-ludicrousdb.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ludicrousdb/includes/class-ludicrousdb.php b/ludicrousdb/includes/class-ludicrousdb.php index 49c8c7c..239557e 100644 --- a/ludicrousdb/includes/class-ludicrousdb.php +++ b/ludicrousdb/includes/class-ludicrousdb.php @@ -2296,6 +2296,11 @@ public function check_tcp_responsiveness( $host, $port, $float_timeout ) { $errno = 0; $errstr = ''; + if ( strstr( $host, ':' ) !== false ) { + $host = 'unix://' . substr( $host, strpos( $host, ':' ) + 1 ); + $port = -1; + } + // Try to get a new socket // phpcs:disable $socket = $this->is_debug()