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
F2330360: D25484.1722074613.diff
Fri, Jul 26, 10:03
Unknown Object (File)
Thu, Jul 25, 00:33
Unknown Object (File)
Mon, Jul 22, 00:48
Unknown Object (File)
Sun, Jul 21, 16:15
Unknown Object (File)
Sun, Jul 21, 05:31
Unknown Object (File)
Fri, Jul 19, 20:57
Unknown Object (File)
Fri, Jul 19, 04:26
Unknown Object (File)
Tue, Jul 16, 19:20

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?