Skip to content

Commit

Permalink
MDL-74419 search_simpledb: Search with quotes not working on Oracle
Browse files Browse the repository at this point in the history
Global search with quotes is not working on DB engines without
full-text search support (i.e. Oracle).
  • Loading branch information
sarjona committed Apr 6, 2022
1 parent ad6dc71 commit f2ff93b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions search/engine/simpledb/classes/engine.php
Expand Up @@ -346,12 +346,16 @@ protected function get_simple_query($q) {
$DB->sql_like('description1', '?', false, false) . ' OR ' .
$DB->sql_like('description2', '?', false, false) .
')';
$params = array(

// Remove quotes from the query.
$q = str_replace('"', '', $q);
$params = [
'%' . $q . '%',
'%' . $q . '%',
'%' . $q . '%',
'%' . $q . '%'
);
];

return array($sql, $params);
}

Expand Down
15 changes: 15 additions & 0 deletions search/tests/behat/search_query.feature
Expand Up @@ -44,6 +44,21 @@ Feature: Use global search interface
And I follow "ForumName1"
And I should see "ForumName1" in the ".breadcrumb" "css_element"

@javascript
Scenario: Search from search page with quotes
Given I search for "zombies" using the header global search box
And I should see "No results"
When I set the field "id_q" to "\"amphibians\""
# You cannot press "Search" because there's a fieldset with the same name that gets in the way.
And I press "id_submitbutton"
Then I should see "ForumName1"
And I should see "ForumDesc1"
And I should see "PageName1"
And I should see "PageDesc1"
# Check the link works.
And I follow "ForumName1"
And I should see "ForumName1" in the ".breadcrumb" "css_element"

@javascript
Scenario: Search starting from site context (no within option)
When I search for "frogs" using the header global search box
Expand Down

0 comments on commit f2ff93b

Please sign in to comment.