Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering list of Active/All projects
ClosedPublic

Authored by aklapper on Apr 30 2023, 18:26.

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 T15312

Test Plan

Applied this change (on top of D25144, D25145, D25146, D25147, D25151, D25152, D25153 and /project/query/active/ rendered correctly in web browser.

Tested surfing various pages with and without Maniphest's maniphest.subtypes.

If you need some example custom fields, this is an example:

[
    {
      "key": "default",
      "name": "Task"
    },
    {
      "key": "bug",
      "name": "Bug"
    },
    {
      "key": "log",
      "name": "LogSpam"
    },
    {
      "key": "deadline",
      "name": "Deadline"
    }
  ]

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

valerio.bozzolan edited the test plan for this revision. (Show Details)
valerio.bozzolan edited the test plan for this revision. (Show Details)

hoping to be useful, add minor PHPDoc for future reference

Thanks for this fix! Tested locally with and without maniphest.subtypes confirming no explosions in various pages, also related to Maniphest Tasks with changed subtype.

src/applications/transactions/editengine/PhabricatorEditEngineSubtype.php
108

✅ The only usage of setTagText() seems to be in PhabricatorEditEngineSubtype and the input domain is just a string coming from phutil_utf8_strtoupper() (like "BUG") or null (default). The phutil_nonempty_string() will report alien values and this is OK.

Also, the method was returning a bool, and it still returns a bool.

This revision is now accepted and ready to land.May 1 2023, 08:40