Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exceptions which block rendering page of a File
ClosedPublic

Authored by aklapper on May 4 2023, 11:41.
Tags
None
Referenced Files
F3283920: D25186.1742762272.diff
Sat, Mar 22, 20:37
F3224936: D25186.1742089751.diff
Sat, Mar 15, 01:49
F3220867: D25186.1741813188.diff
Tue, Mar 11, 20:59
F3220862: D25186.1741813185.diff
Tue, Mar 11, 20:59
F3220857: D25186.1741813180.diff
Tue, Mar 11, 20:59
F3220852: D25186.1741813176.diff
Tue, Mar 11, 20:59
F3219693: D25186.1741758741.diff
Tue, Mar 11, 05:52
F3216751: D25186.1741712362.diff
Mon, Mar 10, 16:59

Details

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.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.May 4 2023, 11:41

Thanks for this patch, again (!!!)

I tested this patch, locally, trying to do lot of fuzzy tests. With/withno alternative texts, changing encoding types, etc. I was not able to reproduce any nuclear crash.

Green light

sgtm

src/applications/files/controller/PhabricatorFileViewController.php
314

✅ I verified the above line

The $custom_alt variable is the alternative image text that assumes null as default, or a string.

The function phutil_nonempty_string() will report alien types, and this is OK here.

src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
63

✅ I verified the above line

The Aphront#getStr() only returns strings, or null (default).

The function phutil_nonempty_string() will report other alien types, and that is OK.

68

✅ I verified the above line

The Aphront#getStr() only returns strings, or null (default).

The function phutil_nonempty_string() will report other alien types, and that is OK.

src/applications/files/storage/PhabricatorFile.php
1281

✅ I verified the above line

The $alt variable is the alternative image text that assumes null as default, or a string.

The function phutil_nonempty_string() will report alien types, and this is good.

This revision is now accepted and ready to land.May 5 2023, 20:34