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
F3766889: D25193.1745847896.diff
Sun, Apr 27, 13:44
F3763567: D25193.1745839353.diff
Sun, Apr 27, 11:22
F3733762: D25193.1745751073.diff
Sat, Apr 26, 10:51
F3659274: D25193.1745458414.diff
Wed, Apr 23, 01:33
F3605316: D25193.1745262687.diff
Sun, Apr 20, 19:11
F3553226: D25193.1744924734.diff
Wed, Apr 16, 21:18
F3553040: D25193.1744916680.diff
Wed, Apr 16, 19:04
F3519745: D25193.1744813705.diff
Tue, Apr 15, 14:28

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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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