@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 for "/bin/almanac register" without parameter

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.

This patch also fixes two similar strlen() occurrences in the same source file.

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php:41]
```

Test Plan: Run `../phorge/bin/almanac register`: Get no `strlen()` error anymore but only expected output `Usage Exception: Specify a device with --device.`

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

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

+3 -3
+3 -3
src/applications/almanac/management/AlmanacManagementRegisterWorkflow.php
··· 38 38 $viewer = $this->getViewer(); 39 39 40 40 $device_name = $args->getArg('device'); 41 - if (!strlen($device_name)) { 41 + if (!phutil_nonempty_string($device_name)) { 42 42 throw new PhutilArgumentUsageException( 43 43 pht('Specify a device with --device.')); 44 44 } ··· 55 55 $identify_as = $args->getArg('identify-as'); 56 56 57 57 $raw_device = $device_name; 58 - if (strlen($identify_as)) { 58 + if (phutil_nonempty_string($identify_as)) { 59 59 $raw_device = $identify_as; 60 60 } 61 61 ··· 70 70 } 71 71 72 72 $private_key_path = $args->getArg('private-key'); 73 - if (!strlen($private_key_path)) { 73 + if (!phutil_nonempty_string($private_key_path)) { 74 74 throw new PhutilArgumentUsageException( 75 75 pht('Specify a private key with --private-key.')); 76 76 }