From 5ee1341b974bf15a9749978265ee586d9efb4dd4 Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 14 Mar 2012 19:07:24 -0700 Subject: [PATCH] Be able to search for Differential and other short strings Summary: I wanted to search for D1234 in texts of other documents. But search tool always redirects me. I've left the redirect behavior for simple search forms (header and home) and removed it from full search form. I don't consider this complete because the first result in search for D1234 should be of course D1234 which is not the case currently. I am not sure how to solve it: - We can display a special result in this case. - We can index the documents so that they will be searchable also for short strings. I tend to use the first solution because revisions can be truncated at arbitrary length (rX1f1f1f should display revision rX1f1f1f1f1f1f1f). Test Plan: Search for D1234, rX123, T4. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley, ddfisher Differential Revision: https://secure.phabricator.com/D1905 --- .../controller/search/PhabricatorSearchController.php | 11 ++++++++++- .../search/controller/search/__init__.php | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/applications/search/controller/search/PhabricatorSearchController.php b/src/applications/search/controller/search/PhabricatorSearchController.php index 1fd9d966a0..23456c2f85 100644 --- a/src/applications/search/controller/search/PhabricatorSearchController.php +++ b/src/applications/search/controller/search/PhabricatorSearchController.php @@ -46,7 +46,8 @@ final class PhabricatorSearchController $query_str = $request->getStr('query'); $pref_jump = PhabricatorUserPreferences::PREFERENCE_SEARCHBAR_JUMP; - if ($user && $user->loadPreferences()->getPreference($pref_jump, 1)) { + if ($request->getStr('jump') != 'no' && + $user && $user->loadPreferences()->getPreference($pref_jump, 1)) { $response = PhabricatorJumpNavHandler::jumpPostResponse($query_str); } else { $response = null; @@ -156,6 +157,14 @@ final class PhabricatorSearchController $search_form ->setUser($user) ->setAction('/search/') + ->appendChild( + phutil_render_tag( + 'input', + array( + 'type' => 'hidden', + 'name' => 'jump', + 'value' => 'no', + ))) ->appendChild( id(new AphrontFormTextControl()) ->setLabel('Search') diff --git a/src/applications/search/controller/search/__init__.php b/src/applications/search/controller/search/__init__.php index ebb1630dc5..a2fd9df50d 100644 --- a/src/applications/search/controller/search/__init__.php +++ b/src/applications/search/controller/search/__init__.php @@ -27,6 +27,7 @@ phutil_require_module('phabricator', 'view/form/control/text'); phutil_require_module('phabricator', 'view/form/control/tokenizer'); phutil_require_module('phabricator', 'view/layout/panel'); +phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils');