Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DifferentialRevision: show active diff ID in response (bug 1798737) #34

Merged
merged 1 commit into from
May 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1140,6 +1140,7 @@ public function getFieldValuesForConduit() {
'status' => $status_info,
'repositoryPHID' => $this->getRepositoryPHID(),
'diffPHID' => $this->getActiveDiffPHID(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the PHID insufficient?

Copy link
Collaborator Author

@zzzeid zzzeid Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lando (specifically the revision worker) uses the diff ID (and so do other parts of Lando and moz-phab but those generally rely on the differential.diff.* endpoints.) This change removes the need to call the diff endpoints just to fetch the ID.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More specifically, why does the revision worker need the diff ID, surely it can use the PHID? Is there an API endpoint that requires the diff ID and doesn't take the PHID?

r+ anyways cause this is a small change, but it's still unclear why we need two IDs for the same object.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So generally Lando, moz-phab, and even Phabricator expose the diff ID (and also use it in the backend). PHIDs and IDs are generally included in API responses for the particular resource you are requesting, but generally referenced fields show the PHID and not the ID. IDs are integers, PHIDs are long strings.

Using the ID instead of the PHID matches the convention of using the more human readable ID elsewhere today (although we do currently use both in different places). There's no downside that I can think of to using the ID instead of the PHID.

it's still unclear why we need two IDs for the same object

This is part of Phabricator's design. As far as I understand PHIDs are universally unique across databases and tables and are composed of a string, and IDs are what you would expect from a unique integer within a table (e.g. a primary key). I suspect it was part of the original design in order to be able to query any object easily no matter which table or database it is in. It might come down to a matter of preference, but I prefer using the ID.

'diffID' => $this->loadActiveDiff()->getID(),
'summary' => $this->getSummary(),
'testPlan' => $this->getTestPlan(),
'isDraft' => !$this->getShouldBroadcast(),