@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.

Fix old image macros and memes for logged out users

Summary:
Fixes T6013. Old image macros/memes never had the file edge written.

We also never wrote file edges for audio.

Finally, the meme controller didn't allow public access.

Write edges for images and audio, perform a migration to populate the historic ones, and make the Editor keep them up to date going forward.

Test Plan:
- Updated image, saw new image attach and old image detach.
- Updated audio, saw new audio attach and old audio detach.
- Ran migration.
- Viewed memes as a logged-out user.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6013

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

+70 -20
+11 -11
resources/celerity/map.php
··· 8 8 return array( 9 9 'names' => array( 10 10 'core.pkg.css' => '974635bb', 11 - 'core.pkg.js' => '4e529147', 11 + 'core.pkg.js' => 'cebacb31', 12 12 'darkconsole.pkg.js' => 'df001cab', 13 13 'differential.pkg.css' => '36884139', 14 14 'differential.pkg.js' => '73337d1d', ··· 438 438 'rsrc/js/application/uiexample/notification-example.js' => '7a9677fc', 439 439 'rsrc/js/core/Busy.js' => '6453c869', 440 440 'rsrc/js/core/DragAndDropFileUpload.js' => '8c49f386', 441 - 'rsrc/js/core/DraggableList.js' => '98d13594', 441 + 'rsrc/js/core/DraggableList.js' => '2a6a1041', 442 442 'rsrc/js/core/FileUpload.js' => 'a4ae61bf', 443 443 'rsrc/js/core/Hovercard.js' => '7e8468ae', 444 444 'rsrc/js/core/KeyboardShortcut.js' => '1ae869f2', ··· 713 713 'phabricator-crumbs-view-css' => 'a49339de', 714 714 'phabricator-dashboard-css' => 'a2bfdcbf', 715 715 'phabricator-drag-and-drop-file-upload' => '8c49f386', 716 - 'phabricator-draggable-list' => '98d13594', 716 + 'phabricator-draggable-list' => '2a6a1041', 717 717 'phabricator-fatal-config-template-css' => '25d446d6', 718 718 'phabricator-feed-css' => '7bfc6f12', 719 719 'phabricator-file-upload' => 'a4ae61bf', ··· 987 987 'javelin-install', 988 988 'javelin-util', 989 989 ), 990 + '2a6a1041' => array( 991 + 'javelin-install', 992 + 'javelin-dom', 993 + 'javelin-stratcom', 994 + 'javelin-util', 995 + 'javelin-vector', 996 + 'javelin-magical-init', 997 + ), 990 998 '2b228192' => array( 991 999 'javelin-behavior', 992 1000 'javelin-dom', ··· 1436 1444 'javelin-install', 1437 1445 'javelin-dom', 1438 1446 'javelin-reactor-dom', 1439 - ), 1440 - '98d13594' => array( 1441 - 'javelin-install', 1442 - 'javelin-dom', 1443 - 'javelin-stratcom', 1444 - 'javelin-util', 1445 - 'javelin-vector', 1446 - 'javelin-magical-init', 1447 1447 ), 1448 1448 '9c2623f4' => array( 1449 1449 'javelin-behavior',
+26
resources/sql/autopatches/20140904.macroattach.php
··· 1 + <?php 2 + 3 + $table = new PhabricatorFileImageMacro(); 4 + foreach (new LiskMigrationIterator($table) as $macro) { 5 + $name = $macro->getName(); 6 + 7 + echo "Linking macro '{$name}'...\n"; 8 + 9 + $editor = new PhabricatorEdgeEditor(); 10 + 11 + $phids[] = $macro->getFilePHID(); 12 + $phids[] = $macro->getAudioPHID(); 13 + $phids = array_filter($phids); 14 + 15 + if ($phids) { 16 + foreach ($phids as $phid) { 17 + $editor->addEdge( 18 + $macro->getPHID(), 19 + PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE, 20 + $phid); 21 + } 22 + $editor->save(); 23 + } 24 + } 25 + 26 + echo "Done.\n";
+4
src/applications/macro/controller/PhabricatorMacroMemeController.php
··· 3 3 final class PhabricatorMacroMemeController 4 4 extends PhabricatorMacroController { 5 5 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 6 10 public function processRequest() { 7 11 $request = $this->getRequest(); 8 12 $macro_name = $request->getStr('macro');
+29 -9
src/applications/macro/editor/PhabricatorMacroEditor.php
··· 82 82 protected function applyCustomExternalTransaction( 83 83 PhabricatorLiskDAO $object, 84 84 PhabricatorApplicationTransaction $xaction) { 85 - return; 86 - } 87 - 88 - protected function extractFilePHIDsFromCustomTransaction( 89 - PhabricatorLiskDAO $object, 90 - PhabricatorApplicationTransaction $xaction) { 91 85 92 86 switch ($xaction->getTransactionType()) { 93 87 case PhabricatorMacroTransactionType::TYPE_FILE: 94 - return array($xaction->getNewValue()); 95 - } 88 + case PhabricatorMacroTransactionType::TYPE_AUDIO: 89 + // When changing a macro's image or audio, attach the underlying files 90 + // to the macro (and detach the old files). 91 + $old = $xaction->getOldValue(); 92 + $new = $xaction->getNewValue(); 93 + $all = array(); 94 + if ($old) { 95 + $all[] = $old; 96 + } 97 + if ($new) { 98 + $all[] = $new; 99 + } 96 100 97 - return array(); 101 + $files = id(new PhabricatorFileQuery()) 102 + ->setViewer($this->requireActor()) 103 + ->withPHIDs($all) 104 + ->execute(); 105 + $files = mpull($files, null, 'getPHID'); 106 + 107 + $old_file = idx($files, $old); 108 + if ($old_file) { 109 + $old_file->detachFromObject($object->getPHID()); 110 + } 111 + 112 + $new_file = idx($files, $new); 113 + if ($new_file) { 114 + $new_file->attachToObject($this->requireActor(), $object->getPHID()); 115 + } 116 + break; 117 + } 98 118 } 99 119 100 120 protected function mergeTransactions(