Allow typeaheads to pass nonscalar data to datasources

Authored by epriestley <git@epriestley.com> on Mon, Feb 11, 3:48 PM.

Description

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

Details

Committed
epriestley <git@epriestley.com>Mon, Feb 11, 7:53 PM
Parents
rPHABRICATORa20f10803412: When an edit overrides an object lock, note it in the transaction record
Branches
Unknown
Tags
Unknown
epriestley <git@epriestley.com> committed rPHABRICATOR711871f6bc74: Allow typeaheads to pass nonscalar data to datasources (authored by epriestley <git@epriestley.com>).Mon, Feb 11, 7:53 PM