diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadFunctionHelpController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadFunctionHelpController.php index 3084b2d434..27b30a6278 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadFunctionHelpController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadFunctionHelpController.php @@ -19,9 +19,25 @@ final class PhabricatorTypeaheadFunctionHelpController return new Aphront404Response(); } - $source = $sources[$class]; + $raw_parameters = $request->getStr('parameters'); + if ($raw_parameters) { + $parameters = phutil_json_decode($raw_parameters); + } else { + $parameters = array(); + } + + $source = id(clone $sources[$class]) + ->setParameters($parameters); + + // This can fail for some types of datasources (like the custom field proxy + // datasources) if the "parameters" are wrong. Just fail cleanly instead + // of fataling. + try { + $application_class = $source->getDatasourceApplicationClass(); + } catch (Exception $ex) { + return new Aphront404Response(); + } - $application_class = $source->getDatasourceApplicationClass(); if ($application_class) { $result = id(new PhabricatorApplicationQuery()) ->setViewer($this->getViewer()) diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php index 2f55c26384..e0ba9a763b 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php @@ -226,6 +226,12 @@ final class PhabricatorTypeaheadModularDatasourceController if ($source->getAllDatasourceFunctions()) { $reference_uri = '/typeahead/help/'.get_class($source).'/'; + $parameters = $source->getParameters(); + if ($parameters) { + $reference_uri = (string)id(new PhutilURI($reference_uri)) + ->setQueryParam('parameters', phutil_json_encode($parameters)); + } + $reference_link = phutil_tag( 'a', array( diff --git a/src/infrastructure/customfield/datasource/PhabricatorCustomFieldApplicationSearchAnyFunctionDatasource.php b/src/infrastructure/customfield/datasource/PhabricatorCustomFieldApplicationSearchAnyFunctionDatasource.php index 9560620db4..31f189988c 100644 --- a/src/infrastructure/customfield/datasource/PhabricatorCustomFieldApplicationSearchAnyFunctionDatasource.php +++ b/src/infrastructure/customfield/datasource/PhabricatorCustomFieldApplicationSearchAnyFunctionDatasource.php @@ -22,7 +22,7 @@ final class PhabricatorCustomFieldApplicationSearchAnyFunctionDatasource 'summary' => pht('Find results with any value.'), 'description' => pht( "This function includes results which have any value. Use a query ". - "like this to find results with any value:\n\n%s". + "like this to find results with any value:\n\n%s", '> any()'), ), );