@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PHP 8.5: Search: Do not pass an empty query key to isBuiltinQuery()

Summary:
Going to http://phorge.localhost/maniphest/query/advanced/, after `if ($this->queryKey == 'advanced') { $query_key = $request->getStr('query');` in `PhabricatorApplicationSearchController::processSearchRequest()`, `$query_key` remains null. Afterwards, `if ($engine->isBuiltinQuery($query_key))` calls PhabricatorApplicationSearchEngine::isBuiltinQuery($query_key) which tries `$builtins[$query_key]`.

Setting null as an array key is deprecated since PHP 8.5 per https://www.php.net/releases/8.5/en.php: "Using null as an array offset or when calling array_key_exists() is now deprecated. Use an empty string instead."

```
ERROR 8192: Using null as an array offset is deprecated, use an empty string instead at [/var/www/html/phorge/phorge/src/applications/search/engine/PhabricatorApplicationSearchEngine.php:757]
```

Closes T16361

Test Plan:
Go to http://phorge.localhost/maniphest/query/advanced/. Enter a term, run a query, save it.
Go to http://phorge.localhost/mail/query/advanced/ which triggers the issue.

Reviewers: O1 Blessed Committers, valerio.bozzolan, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16361

Differential Revision: https://we.phorge.it/D26530

+16 -15
+16 -15
src/applications/search/controller/PhabricatorApplicationSearchController.php
··· 148 148 $query_key = $engine->getDefaultQueryKey(); 149 149 } 150 150 } 151 + if (phutil_nonempty_string($query_key)) { 152 + if ($engine->isBuiltinQuery($query_key)) { 153 + $saved_query = $engine->buildSavedQueryFromBuiltin($query_key); 154 + $named_query = idx($engine->loadEnabledNamedQueries(), $query_key); 155 + } else { 156 + if (strlen($query_key) !== PhabricatorHash::INDEX_DIGEST_LENGTH) { 157 + return new Aphront404Response(); 158 + } 159 + $saved_query = id(new PhabricatorSavedQueryQuery()) 160 + ->setViewer($user) 161 + ->withQueryKeys(array($query_key)) 162 + ->executeOne(); 151 163 152 - if ($engine->isBuiltinQuery($query_key)) { 153 - $saved_query = $engine->buildSavedQueryFromBuiltin($query_key); 154 - $named_query = idx($engine->loadEnabledNamedQueries(), $query_key); 155 - } else if ($query_key) { 156 - if (strlen($query_key) !== PhabricatorHash::INDEX_DIGEST_LENGTH) { 157 - return new Aphront404Response(); 158 - } 159 - $saved_query = id(new PhabricatorSavedQueryQuery()) 160 - ->setViewer($user) 161 - ->withQueryKeys(array($query_key)) 162 - ->executeOne(); 164 + if (!$saved_query) { 165 + return new Aphront404Response(); 166 + } 163 167 164 - if (!$saved_query) { 165 - return new Aphront404Response(); 168 + $named_query = idx($engine->loadEnabledNamedQueries(), $query_key); 166 169 } 167 - 168 - $named_query = idx($engine->loadEnabledNamedQueries(), $query_key); 169 170 } else { 170 171 $saved_query = $engine->buildSavedQueryFromRequest($request); 171 172