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

Conduit: Fix PHP 8.1 "strlen/trim(null)" exceptions in differential.parsecommitmessage

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.

Passing `null` to `trim()` is deprecated since PHP 8.1.

```
ERROR 8192: trim(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/differential/parser/DifferentialCommitMessageParser.php:162]
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/differential/field/DifferentialTestPlanCommitMessageField.php:32]
```

Closes T16422

Test Plan:
* PHP 8.1+
* Go to http://phorge.localhost/conduit/method/differential.parsecommitmessage/
* Press the "Call Method" button

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

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

Maniphest Tasks: T16422

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

+2 -2
+1 -1
src/applications/differential/field/DifferentialTestPlanCommitMessageField.php
··· 29 29 $is_required = PhabricatorEnv::getEnvConfig( 30 30 'differential.require-test-plan-field'); 31 31 32 - if ($is_required && !strlen($value)) { 32 + if ($is_required && !phutil_nonempty_string($value)) { 33 33 $this->raiseValidationException( 34 34 pht( 35 35 'You must provide a test plan. Describe the actions you performed '.
+1 -1
src/applications/differential/parser/DifferentialCommitMessageParser.php
··· 159 159 160 160 $seen = array(); 161 161 162 - $lines = trim($corpus); 162 + $lines = $corpus === null ? $corpus : trim($corpus); 163 163 $lines = phutil_split_lines($lines, false); 164 164 165 165 $field_map = array();