Skip to content

Fix type error in ResultPager::fetch - #1132

Merged
acrobat merged 1 commit into
KnpLabs:masterfrom
nunoplopes:patch-1
Sep 23, 2024
Merged

Fix type error in ResultPager::fetch#1132
acrobat merged 1 commit into
KnpLabs:masterfrom
nunoplopes:patch-1

Conversation

@nunoplopes

Copy link
Copy Markdown
Contributor

When using etags, the reply from github may be empty and the underlying APIs will return an empty string. We need to flip those to empty arrays.
e.g.:

$github_builder
->addPlugin(newHttp\Client\Common\Plugin\HeaderSetPlugin([
'If-None-Match' => $etag,
]));
$api = $github_client->user('user');
$paginator = new \Github\ResultPager($github_client);
$data = $paginator->fetch($api, 'events', [$username]);
// $data should be [] if $etag is the latest

@acrobatacrobat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@nunoplopes thanks for the PR! Can you also add a test for this to avoid any regressions in the future? Thanks!

See: https://github.com/KnpLabs/php-github-api/blob/master/test/Github/Tests/ResultPagerTest.php

When using etags, the reply from github may be empty and the underlying APIs will return an empty string.
We need to flip those to empty arrays.
e.g.:
```
$github_builder
->addPlugin(new Http\Client\Common\Plugin\HeaderSetPlugin([
'If-None-Match' => $etag,
]));
$api = $github_client->user('user');
$paginator = new \Github\ResultPager($github_client);
$data = $paginator->fetch($api, 'events', [$username]);
// $data should be [] if $etag is the latest
```
@nunoplopes
nunoplopes requested a review from acrobatMarch 25, 2024 09:27
@nunoplopes

Copy link
Copy Markdown
ContributorAuthor

added tests + redone the fix based on the fix committed for #1135

@acrobat
acrobat merged commit 3db6f27 into KnpLabs:masterSep 23, 2024
@acrobat

Copy link
Copy Markdown
Collaborator

Thank you @nunoplopes

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@nunoplopes@acrobat