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 Wed, Apr 2, 11:55.
Tags
None
Referenced Files
F3479757: D25945.1744765114.diff
Tue, Apr 15, 00:58
F3452346: D25945.1744720020.diff
Mon, Apr 14, 12:27
F3438455: D25945.1744684315.diff
Mon, Apr 14, 02:31
F3400808: D25945.1744558976.diff
Sat, Apr 12, 15:42
F3398949: D25945.1744543523.diff
Sat, Apr 12, 11:25
F3395824: D25945.1744517954.diff
Sat, Apr 12, 04:19
F3389021: D25945.1744451854.diff
Fri, Apr 11, 09:57
F3388776: D25945.1744448280.diff
Fri, Apr 11, 08: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:106TXT3Line Too Long
Unit
Tests Passed
Build Status
Buildable 1838
Build 1838: arc lint + arc unit

Event Timeline

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

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

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

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.Wed, Apr 2, 12:03