Skip to content

Commit 48b5952

Browse files
authored
Fix GitHub API response handling for Joomla Framework 4 and php 8.4 compatiblity
2 parents 1ff9f09 + f95e99b commit 48b5952

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
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/GitHub/GitHub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class GitHub
4646
*
4747
* @since 3.0.0
4848
*/
49-
public function __construct(Registry $options = null, Http $client = null)
49+
public function __construct(?Registry $options = null, ?Http $client = null)
5050
{
5151
$this->options = $options ?: new Registry();
5252
$this->client = $client ?: HttpFactory::getHttp($options);

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public function requestFromGithub(int $page): array
345345
$page,
346346
$batchSize
347347
);
348-
$pulls = json_decode($pullsResponse->body);
348+
$pulls = json_decode((string) $pullsResponse->getBody());
349349
} catch (UnexpectedResponse $exception) {
350350
throw new RuntimeException(
351351
Text::sprintf(
@@ -387,7 +387,7 @@ public function requestFromGithub(int $page): array
387387
}
388388

389389
// If there are no pulls to insert then bail, assume we're finished
390-
if (count($pulls) === 0) {
390+
if (empty($pulls)) {
391391
return ['complete' => true];
392392
}
393393

manifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<downloads>
8080
<downloadurl type="full" format="zip">https://github.com/joomla-extensions/patchtester/releases/download/5.0.0/com_patchtester_5.0.0.zip</downloadurl>
8181
</downloads>
82-
<sha384>e6bfc039ab4dac753124d79456ff00d51c06d602be84d4b9116d8970fcbd34b7233b592ac9f0ddbc045afa8726c12768</sha384>
82+
<sha384>16f06a344c4584a2defada5aea0217c511a9700a6aad42cb5567b69e1bc2564c53c74782c4095561d155548778159f4e</sha384>
8383
<tags>
8484
<tag>stable</tag>
8585
</tags>

0 commit comments

Comments
 (0)