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

Missed errors in search method #444

Closed
ikarol opened this issue Dec 30, 2019 · 0 comments · Fixed by #445
Closed

Missed errors in search method #444

ikarol opened this issue Dec 30, 2019 · 0 comments · Fixed by #445

Comments

@ikarol
Copy link

ikarol commented Dec 30, 2019

Hi,
It's my first time posting there, so please forgive for any mistake made.

I've recently encountered a weird error when I was doing search with Since date condition(that returned 0 messages as a result, which is incorrect in my case):

PHP Notice: Unknown: SEARCH Database is not full text indexed (errflg=2) in Unknown on line 0

It appears to be a system caused issue and was resolved by our admins.
However, I think it will be better if this library will gracefully catch and address all similar errors.

So, we could move error checking logic above like this


public function getMessages(ConditionInterface $search = null, int $sortCriteria = null, bool $descending = false, string $charset = null): MessageIteratorInterface
    {
        ...
       if (false !== ($error = \imap_last_error())) {
            throw new InvalidSearchCriteriaException(\sprintf('Invalid search criteria [%s] - %s', $query, $error));
       }
       if (false === $messageNumbers) {
            // imap_search can also return false
            $messageNumbers = [];
        }

        return new MessageIterator($this->resource, $messageNumbers);
    }

This way any unexpected error will be reported right away without producing imprecise results.

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 a pull request may close this issue.

1 participant