Homestyx hydra
Diffusion hydra 5405134fa5db

Fix PHP 8.1 "strlen(null)" exception which can block repository imports

Description

Fix PHP 8.1 "strlen(null)" exception which can block repository imports

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.

Interestingly, in upstream they started fixing this yesterday, with just this minimal change:

https://secure.phabricator.com/rPf6214f060e780ecf7b565c5a0edbd28d85c03275#C11580NL1139

Premising counting the length of a string just to answer the question "is this empty?" may be overkill,
but premising that adopting stuff like phutil_nonempty_string() could be too risky, we just do
an explicit cast to string, to answer the question "Is this string empty?" just like it was done
under the hood by the strlen() function.

In short, this is probably nice and more readable than upstream (but not a competition).

Closes T15370

Test Plan:

  • create a Mercurial repository
  • push some things
  • it should conclude the import (or at least unlock a different Exception)

Reviewers: O1 Blessed Committers, speck, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, amit, speck, tobiaswiese, Matthew, Cigaryno

Maniphest Tasks: T15370

Differential Revision: https://we.phorge.it/D25204

Details

Provenance
Valerio BozzolanAuthored on May 25 2023, 10:10 AM
sirocylPushed on Oct 16 2024, 5:49 AM
Parents
R1:82e7f30a825d: Update the supported PHP versions in the docs
Branches
Unknown
Tags
Unknown

Event Timeline