From ea7a06f459844d5158375d6c944797879187901c Mon Sep 17 00:00:00 2001 From: Justin Frydman Date: Thu, 18 Jan 2024 11:33:35 -0700 Subject: [PATCH 1/3] Prevent PHP Warning: Undefined array key 1 --- lib/ConsumerStrategies/SocketConsumer.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/ConsumerStrategies/SocketConsumer.php b/lib/ConsumerStrategies/SocketConsumer.php index 9ee07f6..4ebf959 100644 --- a/lib/ConsumerStrategies/SocketConsumer.php +++ b/lib/ConsumerStrategies/SocketConsumer.php @@ -288,7 +288,11 @@ private function handleResponse($response) { // extract status $line_one_exploded = explode(" ", $lines[0]); - $status = $line_one_exploded[1]; + if ($line_one_exploded === false || ! isset($line_one_exploded[1])) { + $status = "Unable to extract HTTP status from response"; + } else { + $status = $line_one_exploded[1]; + } // extract body $body = $lines[count($lines) - 1]; @@ -301,12 +305,10 @@ private function handleResponse($response) { } } - $ret = array( - "status" => $status, - "body" => $body, + return array( + "status" => $status, + "body" => $body, ); - - return $ret; } From 58dcab3d854fd2ee3e29dbc76e562af9a299c665 Mon Sep 17 00:00:00 2001 From: Justin Frydman Date: Thu, 18 Jan 2024 11:51:42 -0700 Subject: [PATCH 2/3] Fix alignment --- lib/ConsumerStrategies/SocketConsumer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ConsumerStrategies/SocketConsumer.php b/lib/ConsumerStrategies/SocketConsumer.php index 4ebf959..33db6d7 100644 --- a/lib/ConsumerStrategies/SocketConsumer.php +++ b/lib/ConsumerStrategies/SocketConsumer.php @@ -286,8 +286,8 @@ private function handleResponse($response) { } - // extract status - $line_one_exploded = explode(" ", $lines[0]); + // extract status + $line_one_exploded = explode(" ", $lines[0]); if ($line_one_exploded === false || ! isset($line_one_exploded[1])) { $status = "Unable to extract HTTP status from response"; } else { From c25a471eeee7363dcc68f682b33de78caf3804eb Mon Sep 17 00:00:00 2001 From: Justin Frydman Date: Thu, 18 Jan 2024 11:52:32 -0700 Subject: [PATCH 3/3] Fix alignment again --- lib/ConsumerStrategies/SocketConsumer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ConsumerStrategies/SocketConsumer.php b/lib/ConsumerStrategies/SocketConsumer.php index 33db6d7..8e881c3 100644 --- a/lib/ConsumerStrategies/SocketConsumer.php +++ b/lib/ConsumerStrategies/SocketConsumer.php @@ -286,8 +286,8 @@ private function handleResponse($response) { } - // extract status - $line_one_exploded = explode(" ", $lines[0]); + // extract status + $line_one_exploded = explode(" ", $lines[0]); if ($line_one_exploded === false || ! isset($line_one_exploded[1])) { $status = "Unable to extract HTTP status from response"; } else {