Skip to content

Commit 408f0b7

Browse files
Merge branch '2.x' into 952-integration-doc-update
2 parents 1b853a3 + 90e695e commit 408f0b7

File tree

8 files changed

+38
-2
lines changed

8 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 2.19.1
4+
5+
### Fixed
6+
- ExceptionThrower: adjust rate limit detection ([glaubinix](https://github.com/glaubinix)) [#959](https://github.com/KnpLabs/php-github-api/issues/959)
7+
8+
## 2.19.0
9+
10+
### Added
11+
- Mark some classes as final ([acrobat](https://github.com/acrobat)) [#954](https://github.com/KnpLabs/php-github-api/issues/954)
12+
313
## 2.18.0
414

515
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"prefer-stable": true,
4545
"extra": {
4646
"branch-alias": {
47-
"dev-2.x": "2.18.x-dev",
47+
"dev-2.x": "2.19.x-dev",
4848
"dev-master": "3.0.x-dev"
4949
}
5050
}

lib/Github/HttpClient/Message/ResponseMediator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use Github\Exception\ApiLimitExceedException;
66
use Psr\Http\Message\ResponseInterface;
77

8+
/**
9+
* @final since 2.19
10+
*/
811
class ResponseMediator
912
{
1013
/**

lib/Github/HttpClient/Plugin/Authentication.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Add authentication to the request.
1313
*
1414
* @author Tobias Nyholm <[email protected]>
15+
* @final since 2.19
1516
*/
1617
class Authentication implements Plugin
1718
{

lib/Github/HttpClient/Plugin/GithubExceptionThrower.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/**
1818
* @author Joseph Bielawski <[email protected]>
1919
* @author Tobias Nyholm <[email protected]>
20+
* @final since 2.19
2021
*/
2122
class GithubExceptionThrower implements Plugin
2223
{
@@ -36,7 +37,7 @@ public function doHandleRequest(RequestInterface $request, callable $next, calla
3637

3738
// If error:
3839
$remaining = ResponseMediator::getHeader($response, 'X-RateLimit-Remaining');
39-
if (null !== $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) {
40+
if ((429 === $response->getStatusCode()) && null !== $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) {
4041
$limit = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Limit');
4142
$reset = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Reset');
4243

lib/Github/HttpClient/Plugin/History.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* A plugin to remember the last response.
1111
*
1212
* @author Tobias Nyholm <[email protected]>
13+
* @final since 2.19
1314
*/
1415
class History implements Journal
1516
{

lib/Github/HttpClient/Plugin/PathPrepend.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Prepend the URI with a string.
1111
*
1212
* @author Tobias Nyholm <[email protected]>
13+
* @final since 2.19
1314
*/
1415
class PathPrepend implements Plugin
1516
{

test/Github/Tests/HttpClient/Plugin/GithubExceptionThrowerTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,25 @@ public static function responseProvider()
177177
),
178178
'exception' => new \Github\Exception\RuntimeException('Field "xxxx" doesn\'t exist on type "Issue", Field "dummy" doesn\'t exist on type "PullRequest"'),
179179
],
180+
'Grapql requires authentication' => [
181+
'response' => new Response(
182+
401,
183+
[
184+
'content-type' => 'application/json',
185+
'X-RateLimit-Limit' => 0,
186+
'X-RateLimit-Remaining' => 0,
187+
'X-RateLimit-Reset' => 1609245810,
188+
'X-RateLimit-Used' => 0,
189+
],
190+
json_encode(
191+
[
192+
'message' => 'This endpoint requires you to be authenticated.',
193+
'documentation_url' => 'https://docs.github.com/v3/#authentication',
194+
]
195+
)
196+
),
197+
'exception' => new \Github\Exception\RuntimeException('This endpoint requires you to be authenticated.', 401),
198+
],
180199
];
181200
}
182201
}

0 commit comments

Comments
 (0)