Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering a Diffusion repository page
ClosedPublic

Authored by aklapper on May 26 2023, 21:22.

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 T15421

Test Plan

Applied this change, create a repository, and afterwards the repository page at /diffusion/9/ is shown with its name and "Empty Repository - This repository does not have any commits yet."

  • have a Diffusion repository with Staging Area and Automation already setup
  • create a Differential patch from arc
  • press the Land button on the UI and write random things inside

Diff Detail

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

Event Timeline

Thanks

+1 from myself.

Is somebody able to indicate to me how to have a datasourceQuery that is not null? I would like to test the intended value and see that is a string with my eyes.

Looks like create a brand new repository then navigate to it in Diffusion. I ran across this same issue.

In D25247#7556, @speck wrote:

Looks like create a brand new repository then navigate to it in Diffusion. I ran across this same issue.

So you obtain null. But how to obtain a string or something?

Oh I completely misread your question, my mistake. I’m not actually sure what the data source query is.

(My friend no need to sorry, thank you for your help)

Uhm I played with git blame and I've found this interesting commit message:

Part of it:

This will let me put a "Branch: [____]" control on the "Land Revision" dialog so users can choose a branch to target.
Test Plan: Used /typeahead/class/ to vet basic behavior.
rP8dcdc7534d9c: Add a DiffusionRefDatasource for typeahead'ing branches, tags, bookmarks and…
https://secure.phabricator.com/T9952

So it seems this can be tested from this page:

https://we.phorge.it/typeahead/class/

But, I was not able to test its current value.


Anyway, I've inspected my database and the refNameRaw should really be just a string (a branch name or a tag):

MariaDB [phabricator_repository]> SELECT * FROM repository_refcursor;
                                                                                                 ↓↓↓↓↓↓↓↓↓↓↓↓
+----+--------------------------------+--------------------------------+---------+--------------+------------+-----------------+-------------+
| id | phid                           | repositoryPHID                 | refType | refNameHash  | refNameRaw | refNameEncoding | isPermanent |
+----+--------------------------------+--------------------------------+---------+--------------+------------+-----------------+-------------+
| 47 | PHID-RREF-m74blvfp6krgmic7pmcp | PHID-REPO-i5l52bvmuuswuv6ji4bt | branch  | fCKLrzDyaVYn | master     | utf8            |           1 |
| 48 | PHID-RREF-5cosoalq5olsb3hfxpoh | PHID-REPO-i5l52bvmuuswuv6ji4bt | branch  | GIFlNpebwI17 | devnew     | utf8            |           1 |
...
| 87 | PHID-RREF-tpbvvdviqlc4g7u5zf3b | PHID-REPO-i5l52bvmuuswuv6ji4bt | tag     | qgg0XvWyBVjM | 1.4.2      | utf8            |           0 |
| 88 | PHID-RREF-3dttj73xjovytetyo2iu | PHID-REPO-i5l52bvmuuswuv6ji4bt | tag     | FI0L6dPDbedt | 1.4.1      | utf8            |           0 |
| 89 | PHID-RREF-4obv5wwycgt5qrlejxhd | PHID-REPO-i5l52bvmuuswuv6ji4bt | tag     | yL30bS9F7Xgm | 1.4        | utf8            |           0 |
| 90 | PHID-RREF-xgpkwaeumo3kifhdyaz4 | PHID-REPO-i5l52bvmuuswuv6ji4bt | tag     | 1kVq.AQvn06S | 1.2        | utf8            |           0 |
| 91 | PHID-RREF-k7gk3atgaitj7gxhfmre | PHID-REPO-i5l52bvmuuswuv6ji4bt | tag     | 4hURI0ttz8GT | 1.1        | utf8            |           0 |
| 92 | PHID-RREF-y2v4wnxx6rn6ycdprijr | PHID-REPO-i5l52bvmuuswuv6ji4bt | tag     | Es5ZP6BGJYOi | 1.0        | utf8            |           0 |
+----+--------------------------------+--------------------------------+---------+--------------+------------+-----------------+-------------+

See refNameRaw (that is our datasourceQuery).

So probably we can be 90% sure that only null+string should arrive from the sky and so that the patch is nice. Waiting for other people with same feeling.

(I forgot how much time is needed to setup a staging area and an automation locally)

I TESTED THIS IN MY PRODUCTION :D :D :D

I was able to do fuzzy tests in this textarea, finally receiving null... and normal strings:

Phorge Gitpull.it Diffusion Land button.png (500×943 px, 46 KB)

I've logged all my fuzzy tests with phlog() just to be sure. No nuclear implosion detected.

sgtm

This revision is now accepted and ready to land.May 30 2023, 06:40