Skip to content

ResultPager::fetchAll() doesn't work with the search API #253

Closed

Description

@parhamdoustdar

THis piece of code returns only 4 results:

        $searchString = "location:Tehran language:php";
        $pager = new ResultPager($this->client);

        return $pager->fetchAll($this->client->search(), 'users', [$searchString]);

The reason this is happening is the use of array_merge() on line 78 of ResultPager:

$result = array_merge($result, $this->fetchNext());

Since the search results are put in the items key of the returned result, it gets overridden using array_merge(). I unfortunately do not know enough about the GitHub API results to suggest an improvement, but maybe adding an optional argument to ResultPager::fetchAll() that would be the key that needs to be merged might help. For example, my call would look like this:

return $pager->fetchAll($this->client->search(), 'users', [$searchString], 'items');

One other thing that could help is to override values if they are not arrays, and merge them if they are.

Activity

  1. cursedcoder commented on May 18, 2015

    @cursedcoder
    Contributor

    @parhamdoustdar that's right ResultPager is not compatible with search api.

    We are working on it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions