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
F3389021: D25945.1744451854.diff
Fri, Apr 11, 09:57
F3388776: D25945.1744448280.diff
Fri, Apr 11, 08:58
F3388775: D25945.1744448277.diff
Fri, Apr 11, 08:57
F3388774: D25945.1744448273.diff
Fri, Apr 11, 08:57
F3388773: D25945.1744448262.diff
Fri, Apr 11, 08:57
F3385463: D25945.1744417031.diff
Fri, Apr 11, 00:17
F3375320: D25945.1744306938.diff
Wed, Apr 9, 17:42
F3374258: D25945.1744287020.diff
Wed, Apr 9, 12:10

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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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