From 118f989366a03245965ca7261d61d69fdf3b8d13 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Mon, 1 Jul 2024 18:40:28 +0200 Subject: [PATCH] Fix missing file attachment in Phriction Summary: When you drag and drop a file in the Phriction editor and then save the corresponding wiki document, the file was only visible by the author. Now the file is also attached to that document, making it visible. Refs T15106 Test Plan: 1) open the Phriction editor to edit an existing or create a new wiki document 2) drag and drop file in it 3) save wiki document 4) verify file is attached to wiki document (other user can see file in wiki page) Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15106 Differential Revision: https://we.phorge.it/D25705 --- .../controller/PhrictionEditController.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php index e6dea7f0ad..c48cac6400 100644 --- a/src/applications/phriction/controller/PhrictionEditController.php +++ b/src/applications/phriction/controller/PhrictionEditController.php @@ -134,9 +134,31 @@ final class PhrictionEditController $xactions[] = id(new PhrictionTransaction()) ->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) ->setNewValue($title); - $xactions[] = id(new PhrictionTransaction()) + $content_xaction = id(new PhrictionTransaction()) ->setTransactionType($edit_type) ->setNewValue($content_text); + + $content_metadata = $request->getStr('content_metadata'); + if ($content_metadata) { + $content_metadata = phutil_json_decode($content_metadata); + $attached_file_phids = idx( + $content_metadata, + 'attachedFilePHIDs', + array()); + + if ($attached_file_phids) { + $metadata_object = array( + 'remarkup.control' => array( + 'attachedFilePHIDs' => $attached_file_phids, + ), + ); + + $content_xaction->setMetadata($metadata_object); + } + } + + $xactions[] = $content_xaction; + $xactions[] = id(new PhrictionTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) ->setNewValue($v_view)