From d41fd4a0fa213a8f61adf37722486530aa17fd04 Mon Sep 17 00:00:00 2001 From: Hua Wang Date: Sun, 18 Sep 2011 23:04:03 -0700 Subject: [PATCH] T494 Image displaye issue Summary: The display of images pairs is not corresponding to the selected two image diffs. The fix is to use reference to get the phid for each image. Test Plan: Create a revision with two diffs of images. Test the display between base and diff1/diff2. Test the rendering of images between diff1 and diff2. Test the inline comments also. Reviewers: epriestley, jungejason CC: Differential Revision: 955 --- .../changeset/DifferentialChangesetParser.php | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index b8ace11c4d..e3c605dc9c 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -874,12 +874,35 @@ class DifferentialChangesetParser { case DifferentialChangeType::FILE_IMAGE: $old = null; $cur = null; + // TODO: Improve the architectural issue as discussed in D955 + // https://secure.phabricator.com/D955 + $reference = $this->renderingReference; + $parts = explode('/', $reference); + if (count($parts) == 2) { + list($id, $vs) = $parts; + } else { + $id = $parts[0]; + $vs = 0; + } + $id = (int)$id; + $vs = (int)$vs; - $metadata = $this->changeset->getMetadata(); - $data = idx($metadata, 'attachment-data'); + if (!$vs) { + $metadata = $this->changeset->getMetadata(); + $data = idx($metadata, 'attachment-data'); + + $old_phid = idx($metadata, 'old:binary-phid'); + $new_phid = idx($metadata, 'new:binary-phid'); + } else { + $vs_changeset = id(new DifferentialChangeset())->load($vs); + $vs_metadata = $vs_changeset->getMetadata(); + $old_phid = idx($vs_metadata, 'new:binary-phid'); + + $changeset = id(new DifferentialChangeset())->load($id); + $metadata = $changeset->getMetadata(); + $new_phid = idx($metadata, 'new:binary-phid'); + } - $old_phid = idx($metadata, 'old:binary-phid'); - $new_phid = idx($metadata, 'new:binary-phid'); if ($old_phid || $new_phid) { if ($old_phid) { $old_uri = PhabricatorFileURI::getViewURIForPHID($old_phid); @@ -927,18 +950,17 @@ class DifferentialChangesetParser { ''; } - $changset_id = $this->changeset->getID(); if (!$old) { $th_old = ''; } else { - $th_old = '1'; + $th_old = '1'; } if (!$cur) { $th_new = ''; } else { - $th_new = '1'; + $th_new = '1'; } $output = $this->renderChangesetTable(