From 6e716be6d03cc68bb714022edc027af6e64841f3 Mon Sep 17 00:00:00 2001 From: Vital Smereka Date: Wed, 4 Mar 2026 16:05:13 +0300 Subject: [PATCH] Fix deprecation and connection errors for PHP 8.5+ - Prevent null format in sprintf (getJoinLink) - Suppress fwrite warnings on dead sockets --- src/GameQ/Query/Native.php | 10 +++++++++- src/GameQ/Server.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/GameQ/Query/Native.php b/src/GameQ/Query/Native.php index af65884e..7073ddba 100644 --- a/src/GameQ/Query/Native.php +++ b/src/GameQ/Query/Native.php @@ -59,8 +59,16 @@ public function write($data) $this->create(); } + if (!is_resource($this->socket)) { + throw new Exception('Socket is not a valid resource'); + } + // Send the packet - return fwrite($this->socket, $data); + $bytes = @fwrite($this->socket, $data); + if ($bytes === false) { + throw new Exception('Failed to write to socket'); + } + return $bytes; } catch (\Exception $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } diff --git a/src/GameQ/Server.php b/src/GameQ/Server.php index fd1dca76..702e0c86 100644 --- a/src/GameQ/Server.php +++ b/src/GameQ/Server.php @@ -322,7 +322,7 @@ public function getJoinLink() } // Fill the template to build the final joinLink - return sprintf($joinLink, $this->ip, $this->portClient()); + return !isset($this->join_link) ? '' : sprintf($joinLink, $this->ip, $this->portClient()); } // Socket holding