@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 numerous PHP 8.1 "strlen(null)" exceptions preventing homepage to display

Summary:
Fix numerous PHP 8.1 RuntimeExceptions caused by the deprecation of strlen(null).

The strlen() was used in Phabricator to check if a generic value was a non-empty string.
For this reason, Phorge adopts phutil_nonempty_string() that checks that.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If your phutil_nonempty_string() throws an exception, just
report it to Phorge to evaluate and fix together that specific corner case.

Closes T15264

Test Plan: Phorge homepage is displayed on PHP 8.1 after applying these changes

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

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

Maniphest Tasks: T15264

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

+14 -13
+1 -1
src/applications/config/check/PhabricatorDaemonsSetupCheck.php
··· 53 53 } 54 54 55 55 $expect_user = PhabricatorEnv::getEnvConfig('phd.user'); 56 - if (strlen($expect_user)) { 56 + if (phutil_nonempty_string($expect_user)) { 57 57 58 58 try { 59 59 $all_daemons = id(new PhabricatorDaemonLogQuery())
+1 -1
src/applications/files/view/PhabricatorGlobalUploadTargetView.php
··· 67 67 require_celerity_resource('global-drag-and-drop-css'); 68 68 69 69 $hint_text = $this->getHintText(); 70 - if (!strlen($hint_text)) { 70 + if (!phutil_nonempty_string($hint_text)) { 71 71 $hint_text = "\xE2\x87\xAA ".pht('Drop Files to Upload'); 72 72 } 73 73
+1 -1
src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
··· 31 31 PhabricatorProfileMenuItemConfiguration $config) { 32 32 $name = $config->getMenuItemProperty('name'); 33 33 34 - if (strlen($name)) { 34 + if (phutil_nonempty_string($name)) { 35 35 return $name; 36 36 } 37 37
+1 -1
src/applications/search/engine/PhabricatorProfileMenuEngine.php
··· 1308 1308 // render the default view instead. 1309 1309 1310 1310 $selected_view = null; 1311 - if (strlen($item_id)) { 1311 + if (phutil_nonempty_string($item_id)) { 1312 1312 $item_views = $view_list->getViewsWithItemIdentifier($item_id); 1313 1313 if ($item_views) { 1314 1314 $selected_view = head($item_views);
+2 -2
src/applications/search/engine/PhabricatorProfileMenuItemView.php
··· 140 140 ->setName($this->getName()); 141 141 142 142 $uri = $this->getURI(); 143 - if (strlen($uri)) { 143 + if (phutil_nonempty_string($uri)) { 144 144 if ($this->getIsExternalLink()) { 145 145 if (!PhabricatorEnv::isValidURIForLink($uri)) { 146 146 $uri = '#'; ··· 176 176 } 177 177 178 178 $tooltip = $this->getTooltip(); 179 - if (strlen($tooltip)) { 179 + if (phutil_nonempty_string($tooltip)) { 180 180 $view->setTooltip($tooltip); 181 181 } 182 182
+1 -1
src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
··· 117 117 return pht('Archived Dashboard'); 118 118 } 119 119 120 - if (strlen($this->getName($config))) { 120 + if (phutil_nonempty_string($this->getName($config))) { 121 121 return $this->getName($config); 122 122 } else { 123 123 return $dashboard->getName();
+1 -1
src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
··· 71 71 if (!$form) { 72 72 return pht('(Restricted/Invalid Form)'); 73 73 } 74 - if (strlen($this->getName($config))) { 74 + if (phutil_nonempty_string($this->getName($config))) { 75 75 return $this->getName($config); 76 76 } else { 77 77 return $form->getName();
+1 -1
src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
··· 31 31 PhabricatorProfileMenuItemConfiguration $config) { 32 32 $name = $config->getMenuItemProperty('name'); 33 33 34 - if (strlen($name)) { 34 + if (phutil_nonempty_string($name)) { 35 35 return $name; 36 36 } 37 37
+1 -1
src/view/page/PhabricatorStandardPageView.php
··· 188 188 } 189 189 } 190 190 191 - if (strlen($prefix)) { 191 + if (phutil_nonempty_string($prefix)) { 192 192 $title = $prefix.' '.$title; 193 193 } 194 194
+1 -1
src/view/page/menu/PhabricatorMainMenuView.php
··· 333 333 334 334 335 335 $wordmark_text = PhabricatorCustomLogoConfigType::getLogoWordmark(); 336 - if (!strlen($wordmark_text)) { 336 + if (!phutil_nonempty_string($wordmark_text)) { 337 337 $wordmark_text = PlatformSymbols::getPlatformServerName(); 338 338 } 339 339
+1 -1
src/view/phui/PHUIObjectItemListView.php
··· 120 120 require_celerity_resource('phui-oi-color-css'); 121 121 122 122 $header = null; 123 - if (strlen($this->header)) { 123 + if (phutil_nonempty_string($this->header)) { 124 124 $header = phutil_tag( 125 125 'h1', 126 126 array(
+2 -1
src/view/phui/PHUIObjectItemView.php
··· 659 659 $this->getImageIcon()); 660 660 } 661 661 662 - if ($image && (strlen($this->href) || strlen($this->imageHref))) { 662 + if ($image && (phutil_nonempty_string($this->href) || 663 + phutil_nonempty_string($this->imageHref))) { 663 664 $image_href = ($this->imageHref) ? $this->imageHref : $this->href; 664 665 $image = phutil_tag( 665 666 'a',