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

Search Scopes Issue #21

Open
jamesfairhurst opened this issue Mar 7, 2016 · 0 comments
Open

Search Scopes Issue #21

jamesfairhurst opened this issue Mar 7, 2016 · 0 comments

Comments

@jamesfairhurst
Copy link

Trying a very simple search and it's returning 0 results when the Client::SEARCH_SCOPE_ALL is used but has results when using Client::SEARCH_SCOPE_PERSONAL. I would assume that the all scope would bring back the same if not more results.

$search = new \Evernote\Model\Search('Evernote');
$notebook = null;
$scope = \Evernote\Client::SEARCH_SCOPE_PERSONAL; // Has results
//$scope = \Evernote\Client::SEARCH_SCOPE_ALL; // No results
$order = \Evernote\Client::SORT_ORDER_REVERSE | \Evernote\Client::SORT_ORDER_RECENTLY_CREATED;
$maxResult = 5;
$results = $this->service->findNotesWithSearch($search, $notebook, $scope, $order, $maxResult);

Delving into this there are a number of code issues, firstly the usort in findNotes_processResultsWithContext is returning a boolean and not the sorted results, it probably needs to change to this:

        if ($context->requiresLocalMerge) {
            if ($this->isFlagSet($context->sortOrder, self::SORT_ORDER_RECENTLY_CREATED)) {
                usort($context->findMetadataResults, array($this, 'compareByCreated'));
            } elseif ($this->isFlagSet($context->sortOrder, self::SORT_ORDER_RECENTLY_UPDATED)) {
                usort($context->findMetadataResults, array($this, 'compareByUpdated'));
            } else {
                usort($context->findMetadataResults, array($this, 'compareByTitle'));
            }
        }

Then the method can continue to run and return the results.

Secondly the findNotes_nextFindInLinkedScopeWithContext method doesn't return anything so going back up the chain it's returning null and not the results. Probably need to add something like this:

        if (count($context->linkedNotebooksToSearch) == 0) {
            return $this->findNotes_processResultsWithContext($context);
        }

and

$this->findNotes_nextFindInLinkedScopeWithContext($context); // not sure why this is here - would seem to loop recursively 

return $this->findNotes_processResultsWithContext($context);

Again would create a pull request but already got other changes in my fork and not sure how to do multiple forks. Overall a bit disappointing using this official library, it's been a pig to work with and integrate.

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

No branches or pull requests

1 participant