Page MenuHomePhabricator

Custom fields in saved searches are not passed a viewer
Closed, ResolvedPublic

Description

When custom fields are asked to apply their search constraints to a query in applyCustomFieldsToQuery (possibly elsewhere, I haven't dug), applyApplicationSearchConstraintToQuery is called before a viewer is set.

A minimal failing test case (drop in src/extensions and try to search for something in Maniphest): {F133066}

This can be fixed with something like $field->setViewer($this->requireViewer()); in that foreach loop, but I don't really understand the implications of doing that well enough to send you a diff.

My particular use case here is to allow a custom search field to use the viewer's timezone to parse a time.

Event Timeline

carl raised the priority of this task from to Needs Triage.
carl updated the task description. (Show Details)
carl added a subscriber: carl.

Not sure how custom this custom field is, but if the standard date control would be satisfactory (but for the lack of search support) we can also add that, it's just a legwork issue and not a technical or product issue. (See also T4659, although that primarily discusses sorting rather than filtering.)

Even if it's fairly custom, it might be simpler to implement with range queries against custom field storage supported by the upstream.

It's 80% boilerplate and 20% sketchy code for "snap to previous monday and format it as %Y-%m-d" (this is to implement barebones weekly milestone support). A date control with search and sorting/grouping support would have been about 100 times more cargo-cultable (or proxyable), but the code is already written :P

Relatedly, I discovered that custom date fields weren't supported in search by accidentally stumbling upon a TODO while writing the above. It would be nice to maybe mention this in the custom field docs :)

(Sounds like it's moot in your case, but that at least fixes the need to fix the documentation.)