@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 which block rendering page of a File

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.

Closes T15341

Test Plan: Applied these four changes and file page at `/F91` 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: T15341

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

+4 -4
+1 -1
src/applications/files/controller/PhabricatorFileViewController.php
··· 311 311 $file->getStorageHandle()); 312 312 313 313 $custom_alt = $file->getCustomAltText(); 314 - if (strlen($custom_alt)) { 314 + if (phutil_nonempty_string($custom_alt)) { 315 315 $finfo->addProperty(pht('Custom Alt Text'), $custom_alt); 316 316 } 317 317
+2 -2
src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
··· 60 60 } 61 61 62 62 $encode_setting = $request->getStr('encode'); 63 - if (strlen($encode_setting)) { 63 + if (phutil_nonempty_string($encode_setting)) { 64 64 $engine->setEncodingConfiguration($encode_setting); 65 65 } 66 66 67 67 $highlight_setting = $request->getStr('highlight'); 68 - if (strlen($highlight_setting)) { 68 + if (phutil_nonempty_string($highlight_setting)) { 69 69 $engine->setHighlightingConfiguration($highlight_setting); 70 70 } 71 71
+1 -1
src/applications/files/storage/PhabricatorFile.php
··· 1278 1278 public function getAltText() { 1279 1279 $alt = $this->getCustomAltText(); 1280 1280 1281 - if (strlen($alt)) { 1281 + if (phutil_nonempty_string($alt)) { 1282 1282 return $alt; 1283 1283 } 1284 1284