@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Extract PHIDs from transactions later, fixing Paste extraction/attachment

Summary:
Fixes T9787. Currently, file PHID extraction logic happens very early, before we normalize/merge/etc the transactions.

In D14390, I changed how the CONTENT transaction works: before, callers would pass in a file PHID. Afterward, they just pass in the content.

Passing in the content is generaly easier and feels more correct, but inadvertenly broke PHID extraction because converting the content into a file PHID now happened after we extracted the PHID. So we'd extract the entire text of the paste as a "file PHID", which wouldn't work.

Instead, extract file PHIDs later. This impacts a couple of other applications (Conpherence, Pholio) which receive an object or have an unusual file-oriented transaction.

Test Plan:
- Made a new paste, verified the raw file attached to it properly.
- Made and updated a mock, verified all the files attached properly.
- Updated a Conpherence room image, verified the files attached properly.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9787

Differential Revision: https://secure.phabricator.com/D14494

+21 -11
+1 -2
src/applications/conpherence/editor/ConpherenceEditor.php
··· 623 623 624 624 switch ($xaction->getTransactionType()) { 625 625 case ConpherenceTransaction::TYPE_PICTURE: 626 - return array($xaction->getNewValue()->getPHID()); 627 626 case ConpherenceTransaction::TYPE_PICTURE_CROP: 628 - return array($xaction->getNewValue()); 627 + return array($xaction->getNewValue()); 629 628 } 630 629 631 630 return parent::extractFilePHIDsFromCustomTransaction($object, $xaction);
+19 -7
src/applications/pholio/editor/PholioMockEditor.php
··· 120 120 PhabricatorLiskDAO $object, 121 121 PhabricatorApplicationTransaction $xaction) { 122 122 123 + $images = $this->getNewImages(); 124 + $images = mpull($images, null, 'getPHID'); 125 + 123 126 switch ($xaction->getTransactionType()) { 124 127 case PholioTransaction::TYPE_IMAGE_FILE: 125 - $new = $xaction->getNewValue(); 126 - $phids = array(); 127 - foreach ($new as $key => $images) { 128 - $phids[] = mpull($images, 'getFilePHID'); 128 + $file_phids = array(); 129 + foreach ($xaction->getNewValue() as $image_phid) { 130 + $image = idx($images, $image_phid); 131 + if (!$image) { 132 + continue; 133 + } 134 + $file_phids[] = $image->getFilePHID(); 129 135 } 130 - return array_mergev($phids); 136 + return $file_phids; 131 137 case PholioTransaction::TYPE_IMAGE_REPLACE: 132 - return array($xaction->getNewValue()->getFilePHID()); 138 + $image_phid = $xaction->getNewValue(); 139 + $image = idx($images, $image_phid); 140 + 141 + if ($image) { 142 + return array($image->getFilePHID()); 143 + } 144 + break; 133 145 } 134 146 135 - return array(); 147 + return parent::extractFilePHIDsFromCustomTransaction($object, $xaction); 136 148 } 137 149 138 150
+1 -2
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 775 775 throw new PhabricatorApplicationTransactionValidationException($errors); 776 776 } 777 777 778 - $file_phids = $this->extractFilePHIDs($object, $xactions); 779 - 780 778 if ($object->getID()) { 781 779 foreach ($xactions as $xaction) { 782 780 ··· 822 820 } 823 821 824 822 $xactions = $this->sortTransactions($xactions); 823 + $file_phids = $this->extractFilePHIDs($object, $xactions); 825 824 826 825 if ($is_preview) { 827 826 $this->loadHandles($xactions);