Skip to content
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

Fix type error in ResultPager::fetch #1132

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

nunoplopes
Copy link
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(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

Copy link
Collaborator

@acrobat acrobat left a comment

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
Copy link
Contributor Author

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

@acrobat acrobat merged commit 3db6f27 into KnpLabs:master Sep 23, 2024
10 checks passed
@acrobat
Copy link
Collaborator

acrobat commented Sep 23, 2024

Thank you @nunoplopes

Sign up for free to 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