Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function execute($task): void
// Make sure we can fetch the data from GitHub - throw an error on < 10 available requests
try {
$rateResponse = Helper::initializeGithub()->getRateLimit();
$rate = json_decode($rateResponse->body);
$rate = json_decode($rateResponse->getBody());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$rate = json_decode($rateResponse->getBody());
$rate = json_decode((string) $rateResponse->getBody());

} catch (\Exception $e) {
$response = new JsonResponse(new \Exception(Text::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage()), $e->getCode(), $e));
$this->app->sendHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2025 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/

Expand Down Expand Up @@ -166,15 +166,15 @@ protected function processResponse(
int $expectedCode = 200
): Response {
// Validate the response code.
if ($response->code != $expectedCode) {
if ($response->getStatusCode() != $expectedCode) {
// Decode the error response and throw an exception.
$body = json_decode($response->body);
$body = json_decode((string) $response->getBody(), true);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$body = json_decode((string) $response->getBody(), true);
$body = json_decode((string) $response->getBody());

$error = $body->error ?? ($body->message ?? 'Unknown Error');

throw new UnexpectedResponse(
$response,
$error,
$response->code
$response->getStatusCode()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2025 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/

Expand Down Expand Up @@ -319,7 +319,7 @@ private function retrieveGitHubData(GitHub $github, int $id): stdClass
{
try {
$rateResponse = $github->getRateLimit();
$rate = json_decode($rateResponse->body, false);
$rate = json_decode($rateResponse->getBody(), false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$rate = json_decode($rateResponse->getBody(), false);
$rate = json_decode((string) $rateResponse->getBody(), false);

} catch (UnexpectedResponse $exception) {
throw new RuntimeException(
Text::sprintf(
Expand Down Expand Up @@ -347,7 +347,7 @@ private function retrieveGitHubData(GitHub $github, int $id): stdClass
$this->getState()->get('github_repo'),
$id
);
$pull = json_decode($pullResponse->body, false);
$pull = json_decode($pullResponse->getBody(), false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$pull = json_decode($pullResponse->getBody(), false);
$pull = json_decode((string) $pullResponse->getBody(), false);

} catch (UnexpectedResponse $exception) {
throw new RuntimeException(
Text::sprintf(
Expand Down Expand Up @@ -587,7 +587,7 @@ private function applyWithGitHub(int $id): bool
urlencode($pull->head->ref)
);
$contents = json_decode(
$contentsResponse->body,
$contentsResponse->getBody(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$contentsResponse->getBody(),
(string) $contentsResponse->getBody(),

false
);
// In case encoding type ever changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,27 @@
endif; ?>
</td>
<td class="text-center">
<?php $hideButton = function($labels) {
foreach ($labels as $label) {
if (in_array(strtolower($label->name), ['npm resource changed', 'composer dependency changed', 'rtc'])) {
return true;
}
}
<?php $hideButton = function ($labels) {
foreach ($labels as $label) {
if (in_array(strtolower($label->name), ['npm resource changed', 'composer dependency changed', 'rtc'])) {
return true;
}
}

return false;
};?>
<?php if ($this->settings->get('advanced', 0) || !$hideButton($item->labels)) : ?>
<?php if ($item->applied) :
?>
<?php if ($item->applied) :
?>
<button type="button" class="btn btn-sm btn-success submitPatch"
data-task="revert" data-id="<?php echo (int) $item->applied; ?>"><?php echo Text::_('COM_PATCHTESTER_REVERT_PATCH'); ?></button>
<?php
else :
?>
<?php
else :
?>
<button type="button" class="btn btn-sm btn-primary submitPatch"
data-task="apply" data-id="<?php echo (int) $item->pull_id; ?>"><?php echo Text::_('COM_PATCHTESTER_APPLY_PATCH'); ?></button>
<?php
endif; ?>
<?php
endif; ?>
<?php endif; ?>
</td>
</tr>
Expand Down