Commit f1a7a8ee authored by ekes's avatar ekes Committed by borisson_

Issue #2863015 by ekes, borisson_: Core search facets break with non-letter searches

parent a2bdf80a
......@@ -76,15 +76,11 @@ class FacetsQuery extends SearchQuery {
->groupBy('i.sid')
->having('COUNT(*) >= :matches', [':matches' => $this->matches]);
// For complex search queries, add the LIKE conditions.
/*if (!$this->simple) {
$this->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type');
$this->condition($this->conditions);
}*/
// Add conditions to query.
$this->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type AND i.langcode = d.langcode');
$this->condition($this->conditions);
if (count($this->conditions)) {
$this->condition($this->conditions);
}
// Add tag and useful metadata.
$this
......
......@@ -188,6 +188,39 @@ class IntegrationTest extends CoreSearchFacetsTestBase {
$this->deleteUnusedFacet($facet_id, $facet_name);
}
/**
* Tests non-letter searches.
*/
public function testNonLetterSearches() {
$node = Node::load(1);
$node->setTitle('Foo!');
$node->save();
// Index the content.
\Drupal::service('plugin.manager.search')
->createInstance('node_search')
->updateIndex();
search_update_totals();
$facet_id = 'cassiopeia';
$this->addFacet($facet_id, 'Cassiopeia');
$this->blocks[$facet_id] = $this->createBlock($facet_id);
$this->setShowAmountOfResults($facet_id, TRUE);
$this->drupalGet('search/node', ['query' => ['keys' => 'Foo']]);
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Foo!');
$this->drupalGet('search/node', ['query' => ['keys' => '!']]);
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Your search yielded no results.');
$this->drupalGet('search/node', ['query' => ['keys' => '! Foo']]);
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Foo!');
}
/**
* Creates a new facet.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment