From 5cc91a9b2325f4bbbdb6d4005b3342be31e92a1e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 7 Sep 2024 20:10:02 +0200 Subject: [PATCH] [MIRROR] Fix in game pr announce. (#29668) Fix in game pr announce. (#86505) This php file will auto-update once this pr is merged. Co-authored-by: Kyle Spier-Swenson --- tools/WebhookProcessor/github_webhook_processor.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/WebhookProcessor/github_webhook_processor.php b/tools/WebhookProcessor/github_webhook_processor.php index 0aea0a6cc69..87aec4adb75 100644 --- a/tools/WebhookProcessor/github_webhook_processor.php +++ b/tools/WebhookProcessor/github_webhook_processor.php @@ -485,8 +485,10 @@ function game_announce($action, $payload, $pr_flags) { $msg = '['.$payload['pull_request']['base']['repo']['full_name'].'] Pull Request '.$action.' by '.htmlSpecialChars($payload['sender']['login']).': '.htmlSpecialChars('#'.$payload['pull_request']['number'].' '.$payload['pull_request']['user']['login'].' - '.$payload['pull_request']['title']).''; $game_servers = filter_announce_targets($servers, $payload['pull_request']['base']['repo']['owner']['login'], $payload['pull_request']['base']['repo']['name'], $action, $pr_flags); - - $msg = '?announce='.urlencode($msg).'&payload='.urlencode(json_encode($payload)); + $game_payload = array(); + $game_payload['pull_request'] = array(); + $game_payload['pull_request']['id'] = $payload['pull_request']['id']; + $msg = '?announce='.urlencode($msg).'&payload='.urlencode(json_encode($game_payload)); foreach ($game_servers as $serverid => $server) { $server_message = $msg; @@ -789,7 +791,7 @@ function game_server_send($addr, $port, $str) { /* --- Create a socket and connect it to the server --- */ $server = socket_create(AF_INET,SOCK_STREAM,SOL_TCP) or exit("ERROR"); socket_set_option($server, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 2, 'usec' => 0)); //sets connect and send timeout to 2 seconds - if(!socket_connect($server,$addr,$port)) { + if(!@socket_connect($server,$addr,$port)) { return "ERROR: Connection failed"; } @@ -807,8 +809,8 @@ function game_server_send($addr, $port, $str) { } /* --- Idle for a while until received bytes from game server --- */ - $result = socket_read($server, 10000, PHP_BINARY_READ); - socket_close($server); // we don't need this anymore + $result = @socket_read($server, 10000, PHP_BINARY_READ); + @socket_close($server); // we don't need this anymore if($result != "") { if($result[0] == "\x00" || $result[1] == "\x83") { // make sure it's the right packet format