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

Maniphest - remove "attach file" action

Summary: Fixes T4655. Basically leaves the display code intact for legacy installs but removes the option from the UI and removes "create" code.

Test Plan:
tried to attach file and the action was not in the dropdown!
made a new task and it worked!
commented on an old task and it worked!

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4655

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

+4 -117
-13
src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php
··· 38 38 'ccPHIDs' => 'optional list<phid>', 39 39 'priority' => 'optional int', 40 40 'projectPHIDs' => 'optional list<phid>', 41 - 'filePHIDs' => 'optional list<phid>', 42 41 'auxiliary' => 'optional dict', 43 42 ); 44 43 ··· 124 123 PhabricatorProjectPHIDTypeProject::TYPECONST, 125 124 'projectPHIDS'); 126 125 $changes[ManiphestTransaction::TYPE_PROJECTS] = $project_phids; 127 - } 128 - 129 - $file_phids = $request->getValue('filePHIDs'); 130 - if ($file_phids !== null) { 131 - $this->validatePHIDList($file_phids, 132 - PhabricatorFilePHIDTypeFile::TYPECONST, 133 - 'filePHIDS'); 134 - $file_map = array_fill_keys($file_phids, true); 135 - $attached = $task->getAttached(); 136 - $attached[PhabricatorFilePHIDTypeFile::TYPECONST] = $file_map; 137 - 138 - $changes[ManiphestTransaction::TYPE_ATTACH] = $attached; 139 126 } 140 127 141 128 $template = new ManiphestTransaction();
-2
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 155 155 ManiphestTransaction::TYPE_OWNER => pht('Reassign / Claim'), 156 156 ManiphestTransaction::TYPE_CCS => pht('Add CCs'), 157 157 ManiphestTransaction::TYPE_PRIORITY => pht('Change Priority'), 158 - ManiphestTransaction::TYPE_ATTACH => pht('Upload File'), 159 158 ManiphestTransaction::TYPE_PROJECTS => pht('Associate Projects'), 160 159 ); 161 160 ··· 304 303 ManiphestTransaction::TYPE_CCS => 'ccs', 305 304 ManiphestTransaction::TYPE_PRIORITY => 'priority', 306 305 ManiphestTransaction::TYPE_PROJECTS => 'projects', 307 - ManiphestTransaction::TYPE_ATTACH => 'file', 308 306 ); 309 307 310 308 $tokenizer_map = array(
-42
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 25 25 $can_edit_status = $this->hasApplicationCapability( 26 26 ManiphestCapabilityEditStatus::CAPABILITY); 27 27 28 - $files = array(); 29 28 $parent_task = null; 30 29 $template_id = null; 31 30 ··· 106 105 } 107 106 } 108 107 } 109 - } 110 - 111 - $file_phids = $request->getArr('files', array()); 112 - if (!$file_phids) { 113 - // Allow a single 'file' key instead, mostly since Mac OS X urlencodes 114 - // square brackets in URLs when passed to 'open', so you can't 'open' 115 - // a URL like '?files[]=xyz' and have PHP interpret it correctly. 116 - $phid = $request->getStr('file'); 117 - if ($phid) { 118 - $file_phids = array($phid); 119 - } 120 - } 121 - 122 - if ($file_phids) { 123 - $files = id(new PhabricatorFileQuery()) 124 - ->setViewer($user) 125 - ->withPHIDs($file_phids) 126 - ->execute(); 127 108 } 128 109 129 110 $template_id = $request->getInt('template'); ··· 265 246 $request->getStr('viewPolicy'); 266 247 $changes[PhabricatorTransactions::TYPE_EDIT_POLICY] = 267 248 $request->getStr('editPolicy'); 268 - } 269 - 270 - if ($files) { 271 - $file_map = mpull($files, 'getPHID'); 272 - $file_map = array_fill_keys($file_map, array()); 273 - $changes[ManiphestTransaction::TYPE_ATTACH] = array( 274 - PhabricatorFilePHIDTypeFile::TYPECONST => $file_map, 275 - ); 276 249 } 277 250 278 251 $template = new ManiphestTransaction(); ··· 673 646 Javelin::initBehavior('project-create', array( 674 647 'tokenizerID' => $project_tokenizer_id, 675 648 )); 676 - 677 - if ($files) { 678 - $file_display = mpull($files, 'getName'); 679 - $file_display = phutil_implode_html(phutil_tag('br'), $file_display); 680 - 681 - $form->appendChild( 682 - id(new AphrontFormMarkupControl()) 683 - ->setLabel(pht('Files')) 684 - ->setValue($file_display)); 685 - 686 - foreach ($files as $ii => $file) { 687 - $form->addHiddenInput('files['.$ii.']', $file->getPHID()); 688 - } 689 - } 690 - 691 649 692 650 $description_control = new PhabricatorRemarkupControl(); 693 651 // "Upsell" creating tasks via email in create flows if the instance is
-53
src/applications/maniphest/controller/ManiphestTransactionSaveController.php
··· 20 20 21 21 $action = $request->getStr('action'); 22 22 23 - // If we have drag-and-dropped files, attach them first in a separate 24 - // transaction. These can come in on any transaction type, which is why we 25 - // handle them separately. 26 - $files = array(); 27 - 28 - // Look for drag-and-drop uploads first. 29 - $file_phids = $request->getArr('files'); 30 - if ($file_phids) { 31 - $files = id(new PhabricatorFileQuery()) 32 - ->setViewer($user) 33 - ->withPHIDs(array($file_phids)) 34 - ->execute(); 35 - } 36 - 37 - // This means "attach a file" even though we store other types of data 38 - // as 'attached'. 39 - if ($action == ManiphestTransaction::TYPE_ATTACH) { 40 - if (!empty($_FILES['file'])) { 41 - $err = idx($_FILES['file'], 'error'); 42 - if ($err != UPLOAD_ERR_NO_FILE) { 43 - $file = PhabricatorFile::newFromPHPUpload( 44 - $_FILES['file'], 45 - array( 46 - 'authorPHID' => $user->getPHID(), 47 - )); 48 - $files[] = $file; 49 - } 50 - } 51 - } 52 - 53 - // If we had explicit or drag-and-drop files, create a transaction 54 - // for those before we deal with whatever else might have happened. 55 - $file_transaction = null; 56 - if ($files) { 57 - $files = mpull($files, 'getPHID', 'getPHID'); 58 - $new = $task->getAttached(); 59 - foreach ($files as $phid) { 60 - if (empty($new[PhabricatorFilePHIDTypeFile::TYPECONST])) { 61 - $new[PhabricatorFilePHIDTypeFile::TYPECONST] = array(); 62 - } 63 - $new[PhabricatorFilePHIDTypeFile::TYPECONST][$phid] = array(); 64 - } 65 - $transaction = new ManiphestTransaction(); 66 - $transaction 67 - ->setTransactionType(ManiphestTransaction::TYPE_ATTACH); 68 - $transaction->setNewValue($new); 69 - $transactions[] = $transaction; 70 - } 71 - 72 23 // Compute new CCs added by @mentions. Several things can cause CCs to 73 24 // be added as side effects: mentions, explicit CCs, users who aren't 74 25 // CC'd interacting with the task, and ownership changes. We build up a ··· 113 64 break; 114 65 case ManiphestTransaction::TYPE_PRIORITY: 115 66 $transaction->setNewValue($request->getInt('priority')); 116 - break; 117 - case ManiphestTransaction::TYPE_ATTACH: 118 - // Nuke this, we created it above. 119 - $transaction = null; 120 67 break; 121 68 case PhabricatorTransactions::TYPE_COMMENT: 122 69 // Nuke this, we're going to create it below.
-6
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 16 16 $types[] = ManiphestTransaction::TYPE_OWNER; 17 17 $types[] = ManiphestTransaction::TYPE_CCS; 18 18 $types[] = ManiphestTransaction::TYPE_PROJECTS; 19 - $types[] = ManiphestTransaction::TYPE_ATTACH; 20 19 $types[] = ManiphestTransaction::TYPE_EDGE; 21 20 $types[] = ManiphestTransaction::TYPE_SUBPRIORITY; 22 21 $types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN; ··· 57 56 return array_values(array_unique($object->getCCPHIDs())); 58 57 case ManiphestTransaction::TYPE_PROJECTS: 59 58 return array_values(array_unique($object->getProjectPHIDs())); 60 - case ManiphestTransaction::TYPE_ATTACH: 61 - return $object->getAttached(); 62 59 case ManiphestTransaction::TYPE_EDGE: 63 60 case ManiphestTransaction::TYPE_PROJECT_COLUMN: 64 61 // These are pre-populated. ··· 84 81 case ManiphestTransaction::TYPE_STATUS: 85 82 case ManiphestTransaction::TYPE_TITLE: 86 83 case ManiphestTransaction::TYPE_DESCRIPTION: 87 - case ManiphestTransaction::TYPE_ATTACH: 88 84 case ManiphestTransaction::TYPE_EDGE: 89 85 case ManiphestTransaction::TYPE_SUBPRIORITY: 90 86 case ManiphestTransaction::TYPE_PROJECT_COLUMN: ··· 155 151 return $object->setCCPHIDs($xaction->getNewValue()); 156 152 case ManiphestTransaction::TYPE_PROJECTS: 157 153 return $object->setProjectPHIDs($xaction->getNewValue()); 158 - case ManiphestTransaction::TYPE_ATTACH: 159 - return $object->setAttached($xaction->getNewValue()); 160 154 case ManiphestTransaction::TYPE_EDGE: 161 155 // These are a weird, funky mess and are already being applied by the 162 156 // time we reach this.
+4 -1
src/applications/maniphest/storage/ManiphestTransaction.php
··· 11 11 const TYPE_PROJECTS = 'projects'; 12 12 const TYPE_PRIORITY = 'priority'; 13 13 const TYPE_EDGE = 'edge'; 14 - const TYPE_ATTACH = 'attach'; 15 14 const TYPE_SUBPRIORITY = 'subpriority'; 16 15 const TYPE_PROJECT_COLUMN = 'projectcolumn'; 16 + 17 + // NOTE: this type is deprecated. Keep it around for legacy installs 18 + // so any transactions render correctly. 19 + const TYPE_ATTACH = 'attach'; 17 20 18 21 public function getApplicationName() { 19 22 return 'maniphest';