1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Fix PHP 8.1 "strlen(null)" exceptions which block rendering the People page

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

Use `phutil_nonempty_scalar()` instead in `PhabricatorSearchDateField.php` as
input could only be integer instead of string.

Closes T15297

Test Plan: Applied these four changes (on top of D25144, D25145, D25146) and `/people/` 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: T15297

Differential Revision: https://we.phorge.it/D25147
This commit is contained in:
Andre Klapper 2023-05-01 22:31:09 +02:00
parent aea1d47379
commit 8f669ea082
3 changed files with 13 additions and 4 deletions

View file

@ -29,7 +29,7 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
$request_kind = $request->getURIData('kind');
$is_download = ($request_kind === 'download');
if (!strlen($alt) || $main_domain == $alt_domain) {
if (!phutil_nonempty_string($alt) || $main_domain == $alt_domain) {
// No alternate domain.
$should_redirect = false;
$is_alternate_domain = false;

View file

@ -17,7 +17,7 @@ final class PhabricatorSearchDateField
}
protected function validateControlValue($value) {
if (!strlen($value)) {
if (!phutil_nonempty_scalar($value)) {
return;
}
@ -32,7 +32,7 @@ final class PhabricatorSearchDateField
}
protected function parseDateTime($value) {
if (!strlen($value)) {
if (!phutil_nonempty_scalar($value)) {
return null;
}

View file

@ -92,12 +92,21 @@ final class AphrontSideNavFilterView extends AphrontView {
return $this->getMenuView()->getItem($key);
}
/**
* Add a thing in the menu
*
* @param string $key Internal name
* @param string $name Human name
* @param mixed $uri Destination URI. For example as string or as PhutilURI.
* @param string $type Item type. For example see PHUIListItemView constants.
* @param string $icon Icon name
*/
private function addThing($key, $name, $uri, $type, $icon = null) {
$item = id(new PHUIListItemView())
->setName($name)
->setType($type);
if (strlen($icon)) {
if (phutil_nonempty_string($icon)) {
$item->setIcon($icon);
}