Page MenuHomePhorge

fix PHP 8 "strlen(null)" when moving paths with missing options
ClosedPublic

Authored by jeanguyomarch on Dec 2 2023, 09:51.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 30, 19:21
Unknown Object (File)
Wed, Apr 17, 18:16
Unknown Object (File)
Wed, Apr 17, 06:37
Unknown Object (File)
Thu, Apr 11, 05:08
Unknown Object (File)
Apr 4 2024, 01:41
Unknown Object (File)
Apr 4 2024, 01:35
Unknown Object (File)
Apr 1 2024, 06:38
Unknown Object (File)
Mar 31 2024, 19:37

Details

Summary

Running ./bin/repository move-paths without specifying --from nor --to
leads to the PHP 8 error about strlen() not accepting null parameters.

Test Plan

Running ./bin/repository move-paths without --from/--to (shows a proper error)

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Add maniphest task to the commit message

speck subscribed.

This seems fine, though I wonder if we should introduce a phutil_empty_string() or phutil_is_empty_string function to avoid the double-negative logic. I think this reads more easily:

if (phutil_empty_string($from)) {
  throw new Exception()
}

than this:

if (!phutil_nonempty_string($from)) {
  throw new Exception()
}
This revision is now accepted and ready to land.Dec 2 2023, 19:10

In the future it may be nice to also have a getArgStr() that always return a string, never NULL. So, we can just if ( $to === '' )

@jeanguyomarch: Hi, would you like to arc land your accepted patch?