Skip to content

Commit 6e716be

Browse files
committed
Fix deprecation and connection errors for PHP 8.5+
- Prevent null format in sprintf (getJoinLink) - Suppress fwrite warnings on dead sockets
1 parent 347cf58 commit 6e716be

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/GameQ/Query/Native.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,16 @@ public function write($data)
5959
$this->create();
6060
}
6161

62+
if (!is_resource($this->socket)) {
63+
throw new Exception('Socket is not a valid resource');
64+
}
65+
6266
// Send the packet
63-
return fwrite($this->socket, $data);
67+
$bytes = @fwrite($this->socket, $data);
68+
if ($bytes === false) {
69+
throw new Exception('Failed to write to socket');
70+
}
71+
return $bytes;
6472
} catch (\Exception $e) {
6573
throw new Exception($e->getMessage(), $e->getCode(), $e);
6674
}

src/GameQ/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function getJoinLink()
322322
}
323323

324324
// Fill the template to build the final joinLink
325-
return sprintf($joinLink, $this->ip, $this->portClient());
325+
return !isset($this->join_link) ? '' : sprintf($joinLink, $this->ip, $this->portClient());
326326
}
327327

328328
// Socket holding

0 commit comments

Comments
 (0)