I was originally poking T360701: Autocomplete project proposals in Maniphest search form don't always offer "any" and "not" options but at some point wanted a more self-contained testcase.
In my local test instance, I created two projects named LuaSandbox and Wikibase-Lua.
When typing Lua into a Projects field in the Maniphest search, I'd expect prefix search (self::PHASE_PREFIX) to find LuaSandbox and then token search to find Wikibase-Lua.
And that's what my local instance does for http://phorge.localhost/typeahead/class/?class=PhabricatorProjectDatasource&q=lua
Our production instance only behaves correctly for the prefix search.
Afterwards the token search throws 100 random projects at us.
Comparing the executed SQL queries things take a completely different turn than on my local instance.
It basically looks like production skips the PhabricatorProjectDatasource::withNameTokens() query _completely_ (I assumed that maybe $tokens is null?), so $projs = $this->executeQuery($query); is executed with no parameters in PhabricatorProjectQuery.
Comparing the involved source code files, I found custom downstream https://phabricator.wikimedia.org/rPHAB9e9b2d958736c0fc39776a284890e3c78cd98095 and https://phabricator.wikimedia.org/rPHABb5bcd9123b502249d0d4931a558efa594ed7b984 for T150965: phabricator close to saturate its database connections .
That code removes any input with less than 4 letters.
Like lua.
And then runs a query with no conditions for projects.
