Skip to content

Commit 4e983f3

Browse files
committed
Casting response body to string
1 parent 2e31f4a commit 4e983f3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

administrator/components/com_patchtester/src/Controller/StartfetchController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function execute($task): void
5252
// Make sure we can fetch the data from GitHub - throw an error on < 10 available requests
5353
try {
5454
$rateResponse = Helper::initializeGithub()->getRateLimit();
55-
$rate = json_decode($rateResponse->getBody());
55+
$rate = json_decode((string) $rateResponse->getBody());
5656
} catch (\Exception $e) {
5757
$response = new JsonResponse(new \Exception(Text::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage()), $e->getCode(), $e));
5858
$this->app->sendHeaders();

administrator/components/com_patchtester/src/Model/PullModel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private function retrieveGitHubData(GitHub $github, int $id): stdClass
319319
{
320320
try {
321321
$rateResponse = $github->getRateLimit();
322-
$rate = json_decode($rateResponse->getBody(), false);
322+
$rate = json_decode((string) $rateResponse->getBody(), false);
323323
} catch (UnexpectedResponse $exception) {
324324
throw new RuntimeException(
325325
Text::sprintf(
@@ -347,7 +347,7 @@ private function retrieveGitHubData(GitHub $github, int $id): stdClass
347347
$this->getState()->get('github_repo'),
348348
$id
349349
);
350-
$pull = json_decode($pullResponse->getBody(), false);
350+
$pull = json_decode((string) $pullResponse->getBody(), false);
351351
} catch (UnexpectedResponse $exception) {
352352
throw new RuntimeException(
353353
Text::sprintf(
@@ -587,7 +587,7 @@ private function applyWithGitHub(int $id): bool
587587
urlencode($pull->head->ref)
588588
);
589589
$contents = json_decode(
590-
$contentsResponse->getBody(),
590+
(string) $contentsResponse->getBody(),
591591
false
592592
);
593593
// In case encoding type ever changes
@@ -723,7 +723,7 @@ private function getFiles(int $id, int $page, array $files = []): array
723723
$id,
724724
$page
725725
);
726-
$files = array_merge($files, json_decode($filesResponse->getBody(), false));
726+
$files = array_merge($files, json_decode((string) $filesResponse->getBody(), false));
727727
$lastPage = 1;
728728
$headers = $filesResponse->getHeaders();
729729

0 commit comments

Comments
 (0)