mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 02:02:41 +01:00
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
This commit is contained in:
parent
0cbcb110b0
commit
dd24c94b07
1 changed files with 7 additions and 2 deletions
|
@ -42,6 +42,11 @@ final class PHUIDiffTableOfContentsItemView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Coverage, expressed as a string, each letter with this meaning:
|
||||
* N: Not Executable, C: Covered, U: Uncovered.
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCoverage() {
|
||||
return $this->coverage;
|
||||
}
|
||||
|
@ -139,7 +144,7 @@ final class PHUIDiffTableOfContentsItemView extends AphrontView {
|
|||
$not_applicable = '-';
|
||||
|
||||
$coverage = $this->getCoverage();
|
||||
if (!strlen($coverage)) {
|
||||
if (!phutil_nonempty_string($coverage)) {
|
||||
return $not_applicable;
|
||||
}
|
||||
|
||||
|
@ -157,7 +162,7 @@ final class PHUIDiffTableOfContentsItemView extends AphrontView {
|
|||
$not_applicable = '-';
|
||||
|
||||
$coverage = $this->getCoverage();
|
||||
if (!strlen($coverage)) {
|
||||
if (!phutil_nonempty_string($coverage)) {
|
||||
return $not_applicable;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue