From f2ff93b3bcdbe560ade76b493726659d5278d665 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Mon, 4 Apr 2022 10:39:32 +0200 Subject: [PATCH] MDL-74419 search_simpledb: Search with quotes not working on Oracle Global search with quotes is not working on DB engines without full-text search support (i.e. Oracle). --- search/engine/simpledb/classes/engine.php | 8 ++++++-- search/tests/behat/search_query.feature | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/search/engine/simpledb/classes/engine.php b/search/engine/simpledb/classes/engine.php index 9eebf9b7e42..e51a832777e 100644 --- a/search/engine/simpledb/classes/engine.php +++ b/search/engine/simpledb/classes/engine.php @@ -346,12 +346,16 @@ class engine extends \core_search\engine { $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); } diff --git a/search/tests/behat/search_query.feature b/search/tests/behat/search_query.feature index 64b36e9414d..92611137d2c 100644 --- a/search/tests/behat/search_query.feature +++ b/search/tests/behat/search_query.feature @@ -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