Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit a590db2

Browse files
author
epriestley
committed
Fix an issue where non-ID changeset state keys were used as changeset IDs
Summary: Ref T13519. This is a little fuzzy, but I think the workflow here is: - View an intradiff, generating an ephemeral comparison changeset with no changeset ID. This produces a state key of "*". - Apply "hidden" state changes to the changeset. - View some other intradiff and/or diff view. - The code attempts to use "*" as a changset ID? I'm not entirely sure this is accurate; this was observed in production and I couldn't get a clean reproduction case locally. Optimistically, try making changeset IDs explicit rather than relying on state keys to be "usually changeset-ID-like". Test Plan: Used "hidden" locally across multiple intradiffs, but I wasn't cleanly able to reproduce the initial issue. Maniphest Tasks: T13519 Differential Revision: https://secure.phabricator.com/D21223
1 parent 6b69102 commit a590db2

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/applications/differential/storage/DifferentialViewState.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public function setChangesetProperty(
4949
$properties['diffID'] = (int)$diff_id;
5050
}
5151

52+
$changeset_id = $changeset->getID();
53+
if ($changeset_id !== null) {
54+
$properties['changesetID'] = (int)$changeset_id;
55+
}
56+
5257
$path_hash = $this->getChangesetPathHash($changeset);
5358
$changeset_phid = $this->getChangesetKey($changeset);
5459

src/infrastructure/diff/viewstate/PhabricatorChangesetViewStateEngine.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ private function updateHiddenState(PhabricatorChangesetViewState $state) {
197197
$entries = isort($entries, 'epoch');
198198

199199
if ($entries) {
200-
$other_key = last_key($entries);
201200
$other_spec = last($entries);
202201

203202
$this_version = (int)$changeset->getDiffID();
204203
$other_version = (int)idx($other_spec, 'diffID');
205204
$other_value = (bool)idx($other_spec, 'value', false);
205+
$other_id = (int)idx($other_spec, 'changesetID');
206206

207207
if ($other_value === false) {
208208
$is_hidden = false;
@@ -211,10 +211,14 @@ private function updateHiddenState(PhabricatorChangesetViewState $state) {
211211
} else {
212212
$viewer = $this->getViewer();
213213

214-
$other_changeset = id(new DifferentialChangesetQuery())
215-
->setViewer($viewer)
216-
->withIDs(array($other_key))
217-
->executeOne();
214+
if ($other_id) {
215+
$other_changeset = id(new DifferentialChangesetQuery())
216+
->setViewer($viewer)
217+
->withIDs(array($other_id))
218+
->executeOne();
219+
} else {
220+
$other_changeset = null;
221+
}
218222

219223
$is_modified = false;
220224
if ($other_changeset) {

0 commit comments

Comments
 (0)