From 9d89decc5667b4244975124be3189322b96cd3c6 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 16 Jul 2024 09:03:44 +0200 Subject: [PATCH] ObjectSuggestions: Fix exotic columns match These columns should only be shown if expicitely given by user. Previously, columns with a similar suffix were also found, e.g. the search for `id` also showed `uuid` as search suggestion. --- .../Web/Control/SearchBar/ObjectSuggestions.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php index 6ca9b208..2a4d674f 100644 --- a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php @@ -232,9 +232,8 @@ protected function queryTags(Model $model, string $searchTerm): Query protected function matchSuggestion($path, $label, $searchTerm) { if (preg_match('/[_.](id)$/', $path)) { - // Only suggest exotic columns if the user knows about them - $trimmedSearch = trim($searchTerm, ' *'); - return substr($path, -strlen($trimmedSearch)) === $trimmedSearch; + // Only suggest exotic columns if the user knows the full column path + return substr($path, strrpos($path, '.') + 1) === trim($searchTerm, ' *'); } return parent::matchSuggestion($path, $label, $searchTerm);