mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 13:22:42 +01:00
Transactions - fix bug in differential where older inlines weren't appearing
Summary: Fixes T6699. We need to "loadInlineComments" consistently, though for an unexpected reason - this mutates the $changesets to include all $changesets that have an associated inline comment, which is necessary to make them render properly. Test Plan: Took a diff with inline comments and updated it, noting the inline comments disappeared. applied this patch and the inlines reappeared. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6699 Differential Revision: https://secure.phabricator.com/D10935
This commit is contained in:
parent
39351f0a5a
commit
ac1c955986
2 changed files with 42 additions and 41 deletions
|
@ -96,9 +96,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
$props = mpull($props, 'getData', 'getName');
|
$props = mpull($props, 'getData', 'getName');
|
||||||
|
|
||||||
$all_changesets = $changesets;
|
$all_changesets = $changesets;
|
||||||
$inlines = $this->loadInlineComments(
|
$inlines = $revision->loadInlineComments($all_changesets);
|
||||||
$revision,
|
|
||||||
$all_changesets);
|
|
||||||
|
|
||||||
$object_phids = array_merge(
|
$object_phids = array_merge(
|
||||||
$revision->getReviewers(),
|
$revision->getReviewers(),
|
||||||
|
@ -644,44 +642,6 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
return $actions_dict;
|
return $actions_dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadInlineComments(
|
|
||||||
DifferentialRevision $revision,
|
|
||||||
array &$changesets) {
|
|
||||||
assert_instances_of($changesets, 'DifferentialChangeset');
|
|
||||||
|
|
||||||
$inline_comments = array();
|
|
||||||
|
|
||||||
$inline_comments = id(new DifferentialInlineCommentQuery())
|
|
||||||
->withRevisionIDs(array($revision->getID()))
|
|
||||||
->withNotDraft(true)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$load_changesets = array();
|
|
||||||
foreach ($inline_comments as $inline) {
|
|
||||||
$changeset_id = $inline->getChangesetID();
|
|
||||||
if (isset($changesets[$changeset_id])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$load_changesets[$changeset_id] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$more_changesets = array();
|
|
||||||
if ($load_changesets) {
|
|
||||||
$changeset_ids = array_keys($load_changesets);
|
|
||||||
$more_changesets += id(new DifferentialChangeset())
|
|
||||||
->loadAllWhere(
|
|
||||||
'id IN (%Ld)',
|
|
||||||
$changeset_ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($more_changesets) {
|
|
||||||
$changesets += $more_changesets;
|
|
||||||
$changesets = msort($changesets, 'getSortKey');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $inline_comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function loadChangesetsAndVsMap(
|
private function loadChangesetsAndVsMap(
|
||||||
DifferentialDiff $target,
|
DifferentialDiff $target,
|
||||||
DifferentialDiff $diff_vs = null,
|
DifferentialDiff $diff_vs = null,
|
||||||
|
|
|
@ -280,6 +280,44 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadInlineComments(
|
||||||
|
array &$changesets) {
|
||||||
|
assert_instances_of($changesets, 'DifferentialChangeset');
|
||||||
|
|
||||||
|
$inline_comments = array();
|
||||||
|
|
||||||
|
$inline_comments = id(new DifferentialInlineCommentQuery())
|
||||||
|
->withRevisionIDs(array($this->getID()))
|
||||||
|
->withNotDraft(true)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$load_changesets = array();
|
||||||
|
foreach ($inline_comments as $inline) {
|
||||||
|
$changeset_id = $inline->getChangesetID();
|
||||||
|
if (isset($changesets[$changeset_id])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$load_changesets[$changeset_id] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$more_changesets = array();
|
||||||
|
if ($load_changesets) {
|
||||||
|
$changeset_ids = array_keys($load_changesets);
|
||||||
|
$more_changesets += id(new DifferentialChangeset())
|
||||||
|
->loadAllWhere(
|
||||||
|
'id IN (%Ld)',
|
||||||
|
$changeset_ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($more_changesets) {
|
||||||
|
$changesets += $more_changesets;
|
||||||
|
$changesets = msort($changesets, 'getSortKey');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $inline_comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
@ -495,6 +533,9 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
->setViewer($request->getUser())
|
->setViewer($request->getUser())
|
||||||
->withDiffs(array($right_diff))
|
->withDiffs(array($right_diff))
|
||||||
->execute();
|
->execute();
|
||||||
|
// NOTE: this mutates $changesets to include changesets for all inline
|
||||||
|
// comments...!
|
||||||
|
$inlines = $this->loadInlineComments($changesets);
|
||||||
$changesets = mpull($changesets, null, 'getID');
|
$changesets = mpull($changesets, null, 'getID');
|
||||||
|
|
||||||
return $timeline
|
return $timeline
|
||||||
|
|
Loading…
Reference in a new issue