HomePhabricator

(stable) Allow typeaheads to pass nonscalar data to datasources

Authored by epriestley on Mon, Feb 11, 2:48 PM.

Description

(stable) Allow typeaheads to pass nonscalar data to datasources

Summary:
Ref T13250. Currently, datasources have a setParameters(...) method. This method accepts a dictionary and adds the key/value pairs to the raw HTTP request to the datasource endpoint.

Since D20049, this no longer works. Since D20116, it fatals explicitly.

In general, the datasource endpoint accepts other values (like query, offset, and limit), and even before these changes, using secret reserved keys in setParameters(...) would silently cause program misbehavior.

To deal with this, pass parameters as a JSON string named "parameters". This fixes the HTTP query issue (the more pressing issue affecting users today) and prevents the "shadowing reserved keys" issue (a theoretical issue which might affect users some day).

(I may revisit the phutil_build_http_querystring() behavior and possibly let it make this work again, but I think avoiding the duplicate key issue makes this change desirable even if the querystring behavior changes.)

Test Plan:

  • Used "Land Revision", selected branches.
  • Configured a custom Maniphest "users" field, used the search typeahead, selected users.
  • Manually browsed to /typeahead/class/PhabricatorPeopleDatasource/?query=hi&parameters=xyz to see the JSON decode exception.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13250

Differential Revision: https://secure.phabricator.com/D20134