Don't fatal after failing to load grouped projects in Maniphest

Summary: Fixes T3817. This junk is getting wiped out soon so I'm punting here
and fixing the symptom rather than the root cause.

Auditors: btrahan
Continue not fataling on legacy Maniphest queries

Summary: Ref T3817. See that task for discussion.

Auditors: btrahan
PNG thumbnail compression

Summary: Fixes T3800

Test Plan: upload png and check size

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3800

Differential Revision: https://secure.phabricator.com/D6942
Policy - introduce parentQuery and pass around policy configuration from parent to child

Summary: Ref T603. Ref D6941.

Test Plan: Clicked around all over - looked good. I plan to re-test D6941 to make sure the executeOne case works now as intended

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D6944
Kill PhabricatorObjectDataHandle

Summary: Ref T603. Killing this class is cool because the classes that replace it are policy-aware. Tried to keep my wits about me as I did this and fixed a few random things along the way. (Ones I remember right now are pulling a query outside of a foreach loop in Releeph and fixing the text in UIExample to note that the ace of hearts if "a powerful" card and not the "most powerful" card (Q of spades gets that honor IMO))

Test Plan: tested the first few changes (execute, executeOne X handle, object) then got real mechanical / careful with the other changes.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran, FacebookPOC

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D6941
Fix issue with loadRelativeEdges()

Summary: I'm going to just delete all this code at some point, but fixing it now means piles of single gets, so unbreak it first. I'll file something.

Test Plan: Releeph is less fataley.

Reviewers: andrewjcg, btrahan

Reviewed By: andrewjcg

CC: aran

Differential Revision: https://secure.phabricator.com/D6945
Swap file upload icon on Remarkup Bar

Summary: It's a cloud, with an arrow. Serious. Business.

Test Plan: reload page. marvel at my photosynthesis skillz

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3746

Differential Revision: https://secure.phabricator.com/D6947
Move ManiphestTaskQuery into query/

Summary: Move this into a more consistent location.

Test Plan: Loaded Maniphest.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6949
Add "fulltext" to Maniphest pro search

Summary: Restores this field to the new ApplicationSearch-based search.

Test Plan: Used fulltext search to find tasks.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6950
Restore project filtering to Maniphest "pro" search

Summary: Restores any/all/user/exclude project filters to the new search.

Test Plan: Filtered stuff by projects.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6951
Add date filtering to Maniphest "pro" search

Summary: Adds date created filtering. There's a task for this somewhere that I can't immediately find.

Test Plan: Filtered tasks.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6952
Remove legacy "touched" table and indexing

Summary: Noticed this in the schema. "Touches" were an idea that never really got off the ground, as we built out more/better notification channels instead. Essentially, they recorded any object you'd ever interacted with. Maybe this will be useful some day, but for now it does nothing and can't be interacted with. Nuke it.

Test Plan: `grep`, loaded Maniphest.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6953
Add a "dateCreated" key to Maniphest

Summary: Depends on D6952. Unpunts there since I'm rolling into a swamp full of schema changes.

Test Plan: Issued date-constrained query and saw key as a candidate.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6954
Index projects in the main search index

Summary:
Part one of a large and complicated plot:

  - The last filter for Maniphest "pro" queries is "Group By".
  - This is currently executed in a convoluted and ridiculous way, loading massive amounts of data.
  - The primary reason it works like it does is that we don't have a project name index available in Maniphest, so we can't sort in the DB.
  - So, I want to provide a name index to Maniphest and push this work to the DB.

To do that, my plan is:

  - Index projects in Search.
  - Add a "did update index" event.
  - Have Maniphest listen for it.
  - When projects are updated, update their indexes in Maniphest.
  - Rewrite the giant mess of "group by: project" to be somewhat reasonable.
  - This may also extend to some future "group by: assignee".

This is the first small step down this path, which just indexes projects in search.

Test Plan: Ran `bin/search index --type project`, then searched for projects.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6955
Add event dispatch for updated search indexes

Summary:
See discussion in D6955. Provide an event for applications and users to update secondary search indexes.

Facebook: I don't recall exactly how all the search stuff is rigged up, but this might provide a more practical / less fragile alternative. I think it publishes into ElasticSearch now, and then intern somehow handles the result merge at display time, implictly relying on Phabricator's storage format? A cleaner approach might be to publish a secondary "intern" index in a standard format.

Test Plan: Ran `bin/search index --type proj --trace`, saw events fire.

Reviewers: btrahan

Reviewed By: btrahan

CC: FacebookPOC, aran

Differential Revision: https://secure.phabricator.com/D6956
Provide and populate an object name index for Maniphest

Summary: See discussion in D6955. This provides a table we can JOIN against to (effectively) "ORDER BY project name", populates it intially, and keeps it up to date as projects are edited.

Test Plan:
  - Ran storage upgrade, verified projects populated into the table.
  - Edited a project, verified its entry updated.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6957
Service "Group by: Project" in Maniphest out of a local index

Summary:
See discussion in D6955. Currently, the logic for "Group by: Project" is roughly:

  - Load every possible result.
  - Lots of in-process garbage.

Instead, use the new local project name index (from D6957) to service this query more reasonably. Basically:

  - Join a table which has keyed project names.
  - Order by that table.

Test Plan: {F58033}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6958
Call array_unique() in Handle/Object queries

Summary: I think the old thing did this, but this makes queries a bit less ridiculous. For example, `secure.phabricator.com` currently issues a query for 664 handles on my task list, but only 73 of them are unique (basically, all the projects plus all the authors). This proably is slightly good for performance, but mostly makes the "Services" tab manageable.

Test Plan: Looked at Maniphest and some other pages, saw handles and objects where they were expected to be.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6959
Add "group" to Maniphest "pro" search

Summary: This is the last missing filter.

Test Plan: Grouped results by a bunch of stuff.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6960
Fix icon buttons

Summary: Fix CSS classname

Test Plan: UIExamples

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: Korvin, aran

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