Page MenuHomePhabricator

Fix diffusion.branchquery returning dictionary instead of array when branches are filtered out
ClosedPublic

Authored by artms on Feb 10 2020, 1:24 PM.
Tags
None
Referenced Files
F18783887: D20973.id49978.diff
Mon, Oct 13, 10:28 AM
F18765015: D20973.id49971.diff
Tue, Oct 7, 9:07 AM
F18705848: D20973.id.diff
Sun, Sep 28, 1:28 PM
F18705334: D20973.diff
Sun, Sep 28, 10:53 AM
F18698479: D20973.diff
Sat, Sep 27, 11:22 AM
F18656788: D20973.id.diff
Mon, Sep 22, 11:26 PM
F18567621: D20973.id.diff
Sep 9 2025, 3:59 PM
F18363275: D20973.diff
Aug 27 2025, 4:13 PM
Subscribers

Details

Summary

diffusion.branchquery can return dictionary instead of array if some branches are filtered out.
Eg.:

{
  "result": [
    {
      "shortName": "master",
      "commitIdentifier": "2817b0d8f79748ddfad0220c46d9b20bea34f460",
      "refType": "branch",
      "rawFields": {
        "objectname": "2817b0d8f79748ddfad0220c46d9b20bea34f460",
        "objecttype": "commit",

might become:

{
  "result": {
    "1": {
      "shortName": "master",
      "commitIdentifier": "2817b0d8f79748ddfad0220c46d9b20bea34f460",
      "refType": "branch",
      "rawFields": {
        "objectname": "2817b0d8f79748ddfad0220c46d9b20bea34f460",
        "objecttype": "commit",

Reproduction - find repository which has couple of branches, setup to track only some of them, execute diffusion.branchquery API call - result is dictionary instead of array

Test Plan

Apply patch, execution diffusion.branchquery call - result is no longer dictionary if it was one before

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

artms requested review of this revision.Feb 10 2020, 1:25 PM
src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php
106

This essentially punches holes in array and makes out of it a dictionary with array positions becoming integer keys in dictionary.

$ php -a
Interactive shell

php > $a=array("a", "b", "c");
php > var_dump($a);
array(3) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(1) "c"
}
php > unset($a[1]);
php > var_dump($a);
array(2) {
  [0]=>
  string(1) "a"
  [2]=>
  string(1) "c"
}
This revision is now accepted and ready to land.Feb 12 2020, 7:50 PM