Skip to content
Snippets Groups Projects
Commit 2954836f authored by Kjartan Mannes's avatar Kjartan Mannes
Browse files

- Fixed empty searches being performed.

- Fixed empty searches being logged.
- Trim whitespace from start and end of search key.
parent 5cd37157
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -339,13 +339,14 @@ function search_view($keys) { ...@@ -339,13 +339,14 @@ function search_view($keys) {
$output .= "<br />". $help_link ."<br />"; $output .= "<br />". $help_link ."<br />";
} }
// Log the search keys: // Only perform search if there is non-whitespace search term:
watchdog("search", "search: '$keys'", l("view results", "search", NULL, "keys=". urlencode($keys))); if (trim($keys)) {
// Log the search keys:
watchdog("search", "search: '$keys'", l("view results", "search", NULL, "keys=". urlencode($keys)));
// Collect the search results: // Collect the search results:
$results = search_data($keys); $results = search_data($keys);
if ($keys) {
if ($results) { if ($results) {
$output .= theme("box", t("Search Results"), $results); $output .= theme("box", t("Search Results"), $results);
} }
......
...@@ -339,13 +339,14 @@ function search_view($keys) { ...@@ -339,13 +339,14 @@ function search_view($keys) {
$output .= "<br />". $help_link ."<br />"; $output .= "<br />". $help_link ."<br />";
} }
// Log the search keys: // Only perform search if there is non-whitespace search term:
watchdog("search", "search: '$keys'", l("view results", "search", NULL, "keys=". urlencode($keys))); if (trim($keys)) {
// Log the search keys:
watchdog("search", "search: '$keys'", l("view results", "search", NULL, "keys=". urlencode($keys)));
// Collect the search results: // Collect the search results:
$results = search_data($keys); $results = search_data($keys);
if ($keys) {
if ($results) { if ($results) {
$output .= theme("box", t("Search Results"), $results); $output .= theme("box", t("Search Results"), $results);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment