@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)" and "preg_match()" exceptions which block repository creation

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. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

Similarly, `preg_match()` does not accept passing `null` as `$subject` parameter since PHP 8.1.

Closes T15337

Test Plan: Applied these four changes and `/diffusion/4/manage/` finally rendered in web browser.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15337

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

+5 -5
+1 -1
src/applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php
··· 40 40 } 41 41 42 42 $selected = $request->getURIData('panel'); 43 - if (!strlen($selected)) { 43 + if (!phutil_nonempty_string($selected)) { 44 44 $selected = head_key($panels); 45 45 } 46 46
+2 -2
src/applications/diffusion/controller/DiffusionServeController.php
··· 43 43 return null; 44 44 } 45 45 46 - $content_type = $request->getHTTPHeader('Content-Type'); 47 - $user_agent = idx($_SERVER, 'HTTP_USER_AGENT'); 46 + $content_type = $request->getHTTPHeader('Content-Type', ''); 47 + $user_agent = idx($_SERVER, 'HTTP_USER_AGENT', ''); 48 48 $request_type = $request->getHTTPHeader('X-Phabricator-Request-Type'); 49 49 50 50 // This may have a "charset" suffix, so only match the prefix.
+1 -1
src/applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php
··· 219 219 $view->addProperty(pht('Type'), $type); 220 220 221 221 $callsign = $repository->getCallsign(); 222 - if (!strlen($callsign)) { 222 + if (!phutil_nonempty_string($callsign)) { 223 223 $callsign = phutil_tag('em', array(), pht('No Callsign')); 224 224 } 225 225 $view->addProperty(pht('Callsign'), $callsign);
+1 -1
src/applications/repository/editor/PhabricatorRepositoryEditor.php
··· 50 50 // If the repository does not have a local path yet, assign it one based 51 51 // on its ID. We can't do this earlier because we won't have an ID yet. 52 52 $local_path = $object->getLocalPath(); 53 - if (!strlen($local_path)) { 53 + if (!phutil_nonempty_string($local_path)) { 54 54 $local_key = 'repository.default-local-path'; 55 55 56 56 $local_root = PhabricatorEnv::getEnvConfig($local_key);