@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)" exceptions block creating a diff in Differential web interface

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.

```
EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=18554ea76ceb), phorge(head=diffDiff, ref.master=e11c5486c92b, ref.diffDiff=e11c5486c92b)
#0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/infrastructure/diff/view/PHUIDiffTableOfContentsItemView.php:160]
```

Closes T15430

Test Plan:
After applying these two changes, going to `/differential/diff/create/`, pasting the content of a diff file into the "Raw Diff" field, and selecting the "Create Diff" button, `/differential/diff/1/` rendered correctly in web browser.

Also, install xdebug and try again with coverage mode enabled in your php.ini of your PHP cli.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15430

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

+7 -2
+7 -2
src/infrastructure/diff/view/PHUIDiffTableOfContentsItemView.php
··· 42 42 return $this; 43 43 } 44 44 45 + /** 46 + * Get the Coverage, expressed as a string, each letter with this meaning: 47 + * N: Not Executable, C: Covered, U: Uncovered. 48 + * @return string|null 49 + */ 45 50 public function getCoverage() { 46 51 return $this->coverage; 47 52 } ··· 139 144 $not_applicable = '-'; 140 145 141 146 $coverage = $this->getCoverage(); 142 - if (!strlen($coverage)) { 147 + if (!phutil_nonempty_string($coverage)) { 143 148 return $not_applicable; 144 149 } 145 150 ··· 157 162 $not_applicable = '-'; 158 163 159 164 $coverage = $this->getCoverage(); 160 - if (!strlen($coverage)) { 165 + if (!phutil_nonempty_string($coverage)) { 161 166 return $not_applicable; 162 167 } 163 168