From 3940c8e1f43ae58ac11081dae414c9f42ffb68c5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 18 Mar 2019 14:49:32 -0700 Subject: [PATCH] Make the UI when you use an invalid cursor ("?after=19874189471232892") a little nicer Summary: Ref T13259. Currently, visiting a page that executes a query with an invalid cursor raises a bare exception that escapes to top level. Catch this a little sooner and tailor the page a bit. Test Plan: Visited `/maniphest/?after=335234234223`, saw a nicer exception page. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13259 Differential Revision: https://secure.phabricator.com/D20295 --- src/__phutil_library_map__.php | 4 +++- .../controller/PhabricatorApplicationSearchController.php | 2 ++ .../query/{ => exception}/PhabricatorEmptyQueryException.php | 0 .../exception/PhabricatorInvalidQueryCursorException.php | 4 ++++ .../query/policy/PhabricatorCursorPagedPolicyAwareQuery.php | 4 +--- 5 files changed, 10 insertions(+), 4 deletions(-) rename src/infrastructure/query/{ => exception}/PhabricatorEmptyQueryException.php (100%) create mode 100644 src/infrastructure/query/exception/PhabricatorInvalidQueryCursorException.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 661e9812c3..5725b5330b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3115,7 +3115,7 @@ phutil_register_library_map(array( 'PhabricatorEmojiDatasource' => 'applications/macro/typeahead/PhabricatorEmojiDatasource.php', 'PhabricatorEmojiRemarkupRule' => 'applications/macro/markup/PhabricatorEmojiRemarkupRule.php', 'PhabricatorEmojiTranslation' => 'infrastructure/internationalization/translation/PhabricatorEmojiTranslation.php', - 'PhabricatorEmptyQueryException' => 'infrastructure/query/PhabricatorEmptyQueryException.php', + 'PhabricatorEmptyQueryException' => 'infrastructure/query/exception/PhabricatorEmptyQueryException.php', 'PhabricatorEnumConfigType' => 'applications/config/type/PhabricatorEnumConfigType.php', 'PhabricatorEnv' => 'infrastructure/env/PhabricatorEnv.php', 'PhabricatorEnvTestCase' => 'infrastructure/env/__tests__/PhabricatorEnvTestCase.php', @@ -3392,6 +3392,7 @@ phutil_register_library_map(array( 'PhabricatorInternationalizationManagementExtractWorkflow' => 'infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php', 'PhabricatorInternationalizationManagementWorkflow' => 'infrastructure/internationalization/management/PhabricatorInternationalizationManagementWorkflow.php', 'PhabricatorInvalidConfigSetupCheck' => 'applications/config/check/PhabricatorInvalidConfigSetupCheck.php', + 'PhabricatorInvalidQueryCursorException' => 'infrastructure/query/exception/PhabricatorInvalidQueryCursorException.php', 'PhabricatorIteratedMD5PasswordHasher' => 'infrastructure/util/password/PhabricatorIteratedMD5PasswordHasher.php', 'PhabricatorIteratedMD5PasswordHasherTestCase' => 'infrastructure/util/password/__tests__/PhabricatorIteratedMD5PasswordHasherTestCase.php', 'PhabricatorIteratorFileUploadSource' => 'applications/files/uploadsource/PhabricatorIteratorFileUploadSource.php', @@ -9355,6 +9356,7 @@ phutil_register_library_map(array( 'PhabricatorInternationalizationManagementExtractWorkflow' => 'PhabricatorInternationalizationManagementWorkflow', 'PhabricatorInternationalizationManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorInvalidConfigSetupCheck' => 'PhabricatorSetupCheck', + 'PhabricatorInvalidQueryCursorException' => 'Exception', 'PhabricatorIteratedMD5PasswordHasher' => 'PhabricatorPasswordHasher', 'PhabricatorIteratedMD5PasswordHasherTestCase' => 'PhabricatorTestCase', 'PhabricatorIteratorFileUploadSource' => 'PhabricatorFileUploadSource', diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index 286158c4fb..067b07512a 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -351,6 +351,8 @@ final class PhabricatorApplicationSearchController $exec_errors[] = $ex->getMessage(); } catch (PhabricatorSearchConstraintException $ex) { $exec_errors[] = $ex->getMessage(); + } catch (PhabricatorInvalidQueryCursorException $ex) { + $exec_errors[] = $ex->getMessage(); } // The engine may have encountered additional errors during rendering; diff --git a/src/infrastructure/query/PhabricatorEmptyQueryException.php b/src/infrastructure/query/exception/PhabricatorEmptyQueryException.php similarity index 100% rename from src/infrastructure/query/PhabricatorEmptyQueryException.php rename to src/infrastructure/query/exception/PhabricatorEmptyQueryException.php diff --git a/src/infrastructure/query/exception/PhabricatorInvalidQueryCursorException.php b/src/infrastructure/query/exception/PhabricatorInvalidQueryCursorException.php new file mode 100644 index 0000000000..8a87745f9a --- /dev/null +++ b/src/infrastructure/query/exception/PhabricatorInvalidQueryCursorException.php @@ -0,0 +1,4 @@ +