Change record status: 
Project: 
Introduced in branch: 
8.x
Introduced in version: 
8.x
Description: 

The query extender class \Drupal\search\SearchQuery has been updated as follows:

a) Users of SearchQuery will need to check query status using the new getStatus() method and warn the user accordingly, instead of having the messages generated in SearchQuery itself. Previously, SearchQuery called drupal_set_message() and drupal_form_error(), and it instead now saves status messages internally. After executing a query, users should check the getStatus() method to see if any messages were generated, and act accordingly.

Status messages are reported using numeric flag constants that are defined on the SearchQuery class, such as SearchQuery::EXPRESSIONS_IGNORED

The \Drupal\node\Plugin\Search\NodeSearch::execute() method provides a good example of how to get the status:

...
      ->execute();
 
    // Check query status and set messages if needed.
    $status = $query->getStatus();

    if ($status & SearchQuery::EXPRESSIONS_IGNORED) {
      drupal_set_message($this->t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => $this->searchSettings->get('and_or_limit'))), 'warning');
    }
...

b) The misleadingly-named, mostly-internal executeFirstPass() method in SearchQuery is renamed prepareAndNormalize(). There are actually no core calls to this method, as of the referenced issue, and there are probably not going to need to be contrib calls to it either, so this should not affect users. The recommendation is just to call execute(), which will end execution early if there is a problem in the preparation step.

Again, see NodeSearch::execute() for an example of how to use the extender.

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done