@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 file PHID extraction in Owners and Differential

Summary:
Ref T9787. To fix this, I want to change how file PHIDs are extracted slightly: specifically, I'm going to extract them later in the editing process.

Before doing this, clean up a couple of bad implementations:

- Owners extracts its description as a file PHID. This is an error.
- Extract the description as a remarkup block instead.
- Add an edge table so stuff like file attachment works properly.
- Differential has a no-op extract method. This is presumably just a copy/paste issue from long ago.

Test Plan:
- Edited a revision in Differential.
- Dropped a file into the description of an Owners package.
- Before change: this did not attach the file.
- After change: the file now attaches properly and shows up as "Attached" in the file details.

Reviewers: chad, joshuaspence

Reviewed By: joshuaspence

Subscribers: joshuaspence

Maniphest Tasks: T9787

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

+40 -21
+16
resources/sql/autopatches/20151116.owners.edge.sql
··· 1 + CREATE TABLE {$NAMESPACE}_owners.edge ( 2 + src VARBINARY(64) NOT NULL, 3 + type INT UNSIGNED NOT NULL, 4 + dst VARBINARY(64) NOT NULL, 5 + dateCreated INT UNSIGNED NOT NULL, 6 + seq INT UNSIGNED NOT NULL, 7 + dataID INT UNSIGNED, 8 + PRIMARY KEY (src, type, dst), 9 + KEY `src` (src, type, dateCreated, seq), 10 + UNIQUE KEY `key_dst` (dst, type, src) 11 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT}; 12 + 13 + CREATE TABLE {$NAMESPACE}_owners.edgedata ( 14 + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 15 + data LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT} 16 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+2
src/__phutil_library_map__.php
··· 2563 2563 'PhabricatorOwnersPackageTransactionQuery' => 'applications/owners/query/PhabricatorOwnersPackageTransactionQuery.php', 2564 2564 'PhabricatorOwnersPath' => 'applications/owners/storage/PhabricatorOwnersPath.php', 2565 2565 'PhabricatorOwnersPathsController' => 'applications/owners/controller/PhabricatorOwnersPathsController.php', 2566 + 'PhabricatorOwnersSchemaSpec' => 'applications/owners/storage/PhabricatorOwnersSchemaSpec.php', 2566 2567 'PhabricatorOwnersSearchField' => 'applications/owners/searchfield/PhabricatorOwnersSearchField.php', 2567 2568 'PhabricatorPHDConfigOptions' => 'applications/config/option/PhabricatorPHDConfigOptions.php', 2568 2569 'PhabricatorPHID' => 'applications/phid/storage/PhabricatorPHID.php', ··· 6718 6719 'PhabricatorOwnersPackageTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6719 6720 'PhabricatorOwnersPath' => 'PhabricatorOwnersDAO', 6720 6721 'PhabricatorOwnersPathsController' => 'PhabricatorOwnersController', 6722 + 'PhabricatorOwnersSchemaSpec' => 'PhabricatorConfigSchemaSpec', 6721 6723 'PhabricatorOwnersSearchField' => 'PhabricatorSearchTokenizerField', 6722 6724 'PhabricatorPHDConfigOptions' => 'PhabricatorApplicationConfigOptions', 6723 6725 'PhabricatorPHID' => 'Phobject',
-9
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 1298 1298 return true; 1299 1299 } 1300 1300 1301 - protected function extractFilePHIDsFromCustomTransaction( 1302 - PhabricatorLiskDAO $object, 1303 - PhabricatorApplicationTransaction $xaction) { 1304 - 1305 - switch ($xaction->getTransactionType()) {} 1306 - 1307 - return parent::extractFilePHIDsFromCustomTransaction($object, $xaction); 1308 - } 1309 - 1310 1301 protected function expandCustomRemarkupBlockTransactions( 1311 1302 PhabricatorLiskDAO $object, 1312 1303 array $xactions,
-12
src/applications/owners/editor/PhabricatorOwnersPackageTransactionEditor.php
··· 205 205 return $errors; 206 206 } 207 207 208 - protected function extractFilePHIDsFromCustomTransaction( 209 - PhabricatorLiskDAO $object, 210 - PhabricatorApplicationTransaction $xaction) { 211 - 212 - switch ($xaction->getTransactionType()) { 213 - case PhabricatorOwnersPackageTransaction::TYPE_DESCRIPTION: 214 - return array($xaction->getNewValue()); 215 - } 216 - 217 - return parent::extractFilePHIDsFromCustomTransaction($object, $xaction); 218 - } 219 - 220 208 protected function shouldSendMail( 221 209 PhabricatorLiskDAO $object, 222 210 array $xactions) {
+12
src/applications/owners/storage/PhabricatorOwnersPackageTransaction.php
··· 208 208 return parent::renderChangeDetails($viewer); 209 209 } 210 210 211 + public function getRemarkupBlocks() { 212 + $blocks = parent::getRemarkupBlocks(); 213 + 214 + switch ($this->getTransactionType()) { 215 + case self::TYPE_DESCRIPTION: 216 + $blocks[] = $this->getNewValue(); 217 + break; 218 + } 219 + 220 + return $blocks; 221 + } 222 + 211 223 }
+10
src/applications/owners/storage/PhabricatorOwnersSchemaSpec.php
··· 1 + <?php 2 + 3 + final class PhabricatorOwnersSchemaSpec 4 + extends PhabricatorConfigSchemaSpec { 5 + 6 + public function buildSchemata() { 7 + $this->buildEdgeSchemata(new PhabricatorOwnersPackage()); 8 + } 9 + 10 + }