Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering Pholio mock preview
ClosedPublic

Authored by aklapper on May 6 2023, 09:52.
Tags
None
Referenced Files
F3308685: D25193.1743173418.diff
Thu, Mar 27, 14:50
F3304467: D25193.1743098684.diff
Wed, Mar 26, 18:04
F3299163: D25193.1743016251.diff
Tue, Mar 25, 19:10
F3290726: D25193.1742871505.diff
Mon, Mar 24, 02:58
F3252702: D25193.1742399627.diff
Tue, Mar 18, 15:53
F3220934: D25193.1741813242.diff
Tue, Mar 11, 21:00
F3220930: D25193.1741813239.diff
Tue, Mar 11, 21:00
F3216189: D25193.1741683570.diff
Mon, Mar 10, 08: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 T15353

Test Plan

Applied this change and /pholio/create/ displayed an image preview after uploading an image file.

Diff Detail

Repository
rP Phorge
Branch
createPholio (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 364
Build 364: arc lint + arc unit

Event Timeline

aklapper requested review of this revision.May 6 2023, 09:52

I tested this patch locally with some fuzzy tests. Obviously without issues since this is an easy-peasy case.

Thanks again

yesyes

src/applications/pholio/controller/PholioImageUploadController.php
21

✅ I verified the above line

The $title comes from Aphront#getStr() that always return a string or null.

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

This revision is now accepted and ready to land.May 7 2023, 09:51