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.
Tags
None
Referenced Files
F2164756: D25247.id844.diff
Thu, Apr 25, 16:57
F2164755: D25247.id815.diff
Thu, Apr 25, 16:57
F2164754: D25247.id.diff
Thu, Apr 25, 16:57
F2158057: D25247.diff
Thu, Apr 25, 04:20
Unknown Object (File)
Mon, Apr 22, 05:11
Unknown Object (File)
Sun, Apr 21, 16:30
Unknown Object (File)
Tue, Apr 16, 07:43
Unknown Object (File)
Wed, Apr 10, 21:45

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

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