@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.

Fix PHP 8.1 "strlen(null)" exception which can block repository imports

Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1.

Interestingly, in upstream they started fixing this yesterday, with just this minimal change:

https://secure.phabricator.com/rPf6214f060e780ecf7b565c5a0edbd28d85c03275#C11580NL1139

Premising counting the length of a string just to answer the question "is this empty?" may be overkill,
but premising that adopting stuff like phutil_nonempty_string() could be too risky, we just do
an explicit cast to string, to answer the question "Is this string empty?" just like it was done
under the hood by the strlen() function.

In short, this is probably nice and more readable than upstream (but not a competition).

Closes T15370

Test Plan:
- create a Mercurial repository
- push some things
- it should conclude the import (or at least unlock a different Exception)

Reviewers: O1 Blessed Committers, speck, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, amit, speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15370

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

+2 -1
+2 -1
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 1137 1137 $viewer = $this->requireViewer(); 1138 1138 1139 1139 $query_key = $request->getValue('queryKey'); 1140 - if (!strlen($query_key)) { 1140 + $is_empty_query_key = phutil_string_cast($query_key) === ''; 1141 + if ($is_empty_query_key) { 1141 1142 $saved_query = new PhabricatorSavedQuery(); 1142 1143 } else if ($this->isBuiltinQuery($query_key)) { 1143 1144 $saved_query = $this->buildSavedQueryFromBuiltin($query_key);