Page MenuHomePhorge

Fix exception handling a numeric git branch ("Call to phutil_nonempty_string() expected null or a string, got: int" in PhabricatorRepository)
ClosedPublic

Authored by aklapper on Apr 2 2025, 11:55.
Tags
None
Referenced Files
F3998468: D25945.1746609215.diff
Tue, May 6, 09:13
F3702164: D25945.1745618864.diff
Thu, Apr 24, 22:07
F3605066: D25945.1745251496.diff
Sun, Apr 20, 16:04
F3582728: D25945.1745113353.diff
Sat, Apr 19, 01:42
F3554059: D25945.1744971178.diff
Thu, Apr 17, 10:12
F3552458: D25945.1744904287.diff
Wed, Apr 16, 15:38
F3531860: D25945.1744885067.diff
Wed, Apr 16, 10:17
F3479757: D25945.1744765114.diff
Tue, Apr 15, 00:58

Details

Summary

PHP casts an array key which is a string that contains a decimal integer automatically into int type.
Quoting https://www.php.net/manual/en/language.types.array.php#language.types.array.syntax: "Strings containing valid decimal ints, unless the number is preceded by a + sign, will be cast to the int type."

As we check git branch names via phutil_nonempty_string($key), this throws an exception.
Thus explicitly cast the int to string.

Closes T15640.

Test Plan

Diff Detail

Repository
rP Phorge
Branch
T15640 (branched from master)
Lint
Lint Warnings
SeverityLocationCodeMessage
Warningsrc/applications/diffusion/data/DiffusionGitBranch.php:109TXT3Line Too Long
Unit
Tests Passed
Build Status
Buildable 1839
Build 1839: arc lint + arc unit

Event Timeline

aklapper requested review of this revision.Apr 2 2025, 11:55

Check if the comments are interesting - thanks for this Phorgi patchi that seems lovely

src/applications/diffusion/data/DiffusionGitBranch.php
82–87

Maybe nice to add a minor PHPdoc here to say @return array and inform that the key is the branch name (and may be numeric) and the value is (?)

This revision is now accepted and ready to land.Apr 2 2025, 12:03