From 23ed41535e822141156a0faee944ff6a748f9ff6 Mon Sep 17 00:00:00 2001 From: Marc Roberts Date: Tue, 7 Feb 2023 23:14:00 +0100 Subject: [PATCH 1/2] Handle PSR Response before json decode In the case that the result of getResponse() the result must be handled differently when passing to json_decode --- Classes/UpdateAliasJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/UpdateAliasJob.php b/Classes/UpdateAliasJob.php index 129526c..0e5c7a0 100644 --- a/Classes/UpdateAliasJob.php +++ b/Classes/UpdateAliasJob.php @@ -137,7 +137,7 @@ protected function cleanupOldIndices(): void } } } catch (ApiException $exception) { - $response = json_decode($exception->getResponse(), true, 512, JSON_THROW_ON_ERROR); + $response = json_decode($exception->getResponse() instanceof ResponseInterface ? $exception->getResponse()->getBody()->__toString() : (string) $exception->getResponse(), true, 512, JSON_THROW_ON_ERROR); if ($response->error instanceof \stdClass) { $this->logger->error(sprintf('Old indices for alias %s could not be removed. ElasticSearch responded with status %s, saying "%s: %s"', $this->indexPostfix, $response->status, $response->error->type, $response->error->reason), LogEnvironment::fromMethodName(__METHOD__)); } else { From eb3fc9d64083cd812c733df70e8e9cb525d349be Mon Sep 17 00:00:00 2001 From: Marc Roberts Date: Tue, 7 Feb 2023 23:14:51 +0100 Subject: [PATCH 2/2] Update UpdateAliasJob.php --- Classes/UpdateAliasJob.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Classes/UpdateAliasJob.php b/Classes/UpdateAliasJob.php index 0e5c7a0..1a4a9b0 100644 --- a/Classes/UpdateAliasJob.php +++ b/Classes/UpdateAliasJob.php @@ -21,6 +21,7 @@ use Neos\Flow\Annotations as Flow; use Neos\Flow\Log\Utility\LogEnvironment; use Neos\Flow\Utility\Algorithms; +use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; class UpdateAliasJob implements JobInterface