-
-
Notifications
You must be signed in to change notification settings - Fork 49
Fix GitHub API response handling after Framework Update #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d732f48
0ad5ea3
42e3522
57eb805
09f5c17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
| */ | ||||||
|
|
||||||
|
|
@@ -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); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| $error = $body->error ?? ($body->message ?? 'Unknown Error'); | ||||||
|
|
||||||
| throw new UnexpectedResponse( | ||||||
| $response, | ||||||
| $error, | ||||||
| $response->code | ||||||
| $response->getStatusCode() | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
| */ | ||||||
|
|
||||||
|
|
@@ -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); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } catch (UnexpectedResponse $exception) { | ||||||
| throw new RuntimeException( | ||||||
| Text::sprintf( | ||||||
|
|
@@ -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); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } catch (UnexpectedResponse $exception) { | ||||||
| throw new RuntimeException( | ||||||
| Text::sprintf( | ||||||
|
|
@@ -587,7 +587,7 @@ private function applyWithGitHub(int $id): bool | |||||
| urlencode($pull->head->ref) | ||||||
| ); | ||||||
| $contents = json_decode( | ||||||
| $contentsResponse->body, | ||||||
| $contentsResponse->getBody(), | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| false | ||||||
| ); | ||||||
| // In case encoding type ever changes | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.