From 87da4d2a33e6381af47be8a32404384b1c27f4b5 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 22 May 2025 12:08:30 +0200 Subject: [PATCH] Fix project typeahead query with columns when string is not name prefix Summary: Avoid an AphrontParameterQueryException when running a typeahead project name query with `mustHaveColumns` when the search string is not the `prefix` of the project name. Since rP9a1d59ad5bd51ef4bf56533db260cc9e11a54fe6, Phorge runs queries in two phases: First `prefix`, then `content`, to sort project results accordingly. `PhabricatorTypeaheadDatasource::loadResultsForPhase()` first goes for the `prefix` phase. This query may return zero results. Current code does not correctly handle this situation. Thus make the code smoothly skip to the `content` query phase and not run a `PhabricatorProjectColumnQuery` with an empty project PHID array parameter to end up in an exception. Closes T16068 Test Plan: * Have a parent project named `Foo` with a milestone named `Sprint Chocolate Cake` * Create a project workboard for that milestone named `Sprint Chocolate Cake` * In a project with no workboard yet, select "Import Columns" to end up on http://phorge.localhost/project/board/1/import/ * See that typing the second string token (`Chocolate`) shows no autocomplete project proposals * Click the Magnifier button to `Browse Projects` * Start typing `Chocolate` and get an AphrontParameterQueryException * Apply the patch * See that typing the second string token (`Chocolate`) now shows autocomplete project proposals * Click the Magnifier button to `Browse Projects` * Start typing `Chocolate` and get project search results Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16068 Differential Revision: https://we.phorge.it/D26030 --- .../project/typeahead/PhabricatorProjectDatasource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php index ea2ba48b09..af9dc7a9eb 100644 --- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php +++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php @@ -51,7 +51,7 @@ final class PhabricatorProjectDatasource $projs = mpull($projs, null, 'getPHID'); $must_have_cols = $this->getParameter('mustHaveColumns', false); - if ($must_have_cols) { + if ($must_have_cols && $projs) { $columns = id(new PhabricatorProjectColumnQuery()) ->setViewer($viewer) ->withProjectPHIDs(array_keys($projs))