Page MenuHomePhabricator

Search shows document types corresponding to disabled apps
Closed, ResolvedPublic

Description

(Observed on Phacility)

We have Diviner and others disabled on our instance, but when using the Search app and restricting the set of document types to search, the UI still shows these apps:

pasted_file (441×620 px, 59 KB)

Event Timeline

epriestley added a subscriber: epriestley.

To reach this dialog, mash some text into the search field in the global menu bar, then hit enter.

Now, click the button next to the "Document Types" field. The dialog looks a little different in the modern codebase than it does in the screenshot above (and, uh, kind of worse/uglier) because of changes in T11034, but it should be recognizable.

Now, go into ApplicationsDivinerConfig (for example) and click "Uninstall" to uninstall it.

Pull up the dialog again -- you'll still see "Diviner Atom", "Diviner Book", etc, but should not, because the underlying application has been uninstalled.

This dialog is backed by PhabricatorSearchDocumentTypeDatasource. You can review results from this source in this secret developer UI that isn't linked anywhere:

https://secure.phabricator.com/typeahead/class/PhabricatorSearchDocumentTypeDatasource/

To correct the datasource, I think it's sufficient to pass $viewer to PhabricatorSearchApplicationSearchEngine::getIndexableDocumentTypes(); in PhabricatorSearchDocumentTypeDatasource. It looks like this causes the method to do viewer checks to see if the applications are installed.

You can get $viewer by calling $this->getViewer().

After adding $viewer, reloading the internal result page or pulling up the dialog should no longer show document types for uninstalled applications (e.g., Diviner in the example above).

Perhaps in a separate change, it would be nice to maybe show the application name under the more modern document types -- for example, show "Diffusion" here:

diffusion.png (480×665 px, 30 KB)

You can do this by calling setAttribute() on the PhabricatorTypeaheadResult constructed in PhabricatorSearchDocumentTypeDatasource. For example, if you add ->setAttribute('quack') that should be reflected in the UI.

To get the application names it's a little bit of work:

  • Grab all PHID types with PhabricatorPHIDType::getAllTypes().
  • Convert that into a map from type constant to PHIDType object:
$map = mpull(PhabricatorPHIDType::getAllTypes(), null, 'getTypeConstant');
  • In the loop, look up the type in the map:
$type_object = idx($types, $type);
if (!$type_object) {
  continue;
}
  • Get the application class from it:
$application_class = $type_object->getPHIDTypeApplicationClass();
  • Get the actual application object from that:
$application = PhabricatorApplication::getByClass($application_class);
  • Finally, get the application name:
$application_name = $application->getName();
  • Now you can setAttribute() that. Clean up setIcon() to just do $type_object->getTypeIcon() and this should make the dialog look a little nicer.