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

Add PHIDs to Herald Rules

Summary: Ref T2769. Precursor to various Herald-related modernizations.

Test Plan: Ran migration; loaded Herald via web.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2769

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

+135
+2
resources/sql/patches/20130802.heraldphid.sql
··· 1 + ALTER TABLE {$NAMESPACE}_herald.herald_rule 2 + ADD phid VARCHAR(64) NOT NULL COLLATE utf8_bin;
+24
resources/sql/patches/20130802.heraldphids.php
··· 1 + <?php 2 + 3 + $table = new HeraldRule(); 4 + $conn_w = $table->establishConnection('w'); 5 + 6 + echo "Assigning PHIDs to Herald Rules...\n"; 7 + 8 + foreach (new LiskMigrationIterator(new HeraldRule()) as $rule) { 9 + $id = $rule->getID(); 10 + echo "Rule {$id}.\n"; 11 + 12 + if ($rule->getPHID()) { 13 + continue; 14 + } 15 + 16 + queryfx( 17 + $conn_w, 18 + 'UPDATE %T SET phid = %s WHERE id = %d', 19 + $table->getTableName(), 20 + PhabricatorPHID::generateNewPHID(HeraldPHIDTypeRule::TYPECONST), 21 + $rule->getID()); 22 + } 23 + 24 + echo "Done.\n";
+2
resources/sql/patches/20130802.heraldphidukey.sql
··· 1 + ALTER TABLE {$NAMESPACE}_herald.herald_rule 2 + ADD UNIQUE KEY (phid);
+2
src/__phutil_library_map__.php
··· 617 617 'HeraldNewController' => 'applications/herald/controller/HeraldNewController.php', 618 618 'HeraldObjectAdapter' => 'applications/herald/adapter/HeraldObjectAdapter.php', 619 619 'HeraldObjectTranscript' => 'applications/herald/storage/transcript/HeraldObjectTranscript.php', 620 + 'HeraldPHIDTypeRule' => 'applications/herald/phid/HeraldPHIDTypeRule.php', 620 621 'HeraldRecursiveConditionsException' => 'applications/herald/engine/engine/HeraldRecursiveConditionsException.php', 621 622 'HeraldRepetitionPolicyConfig' => 'applications/herald/config/HeraldRepetitionPolicyConfig.php', 622 623 'HeraldRule' => 'applications/herald/storage/HeraldRule.php', ··· 2621 2622 'HeraldInvalidConditionException' => 'Exception', 2622 2623 'HeraldInvalidFieldException' => 'Exception', 2623 2624 'HeraldNewController' => 'HeraldController', 2625 + 'HeraldPHIDTypeRule' => 'PhabricatorPHIDType', 2624 2626 'HeraldRecursiveConditionsException' => 'Exception', 2625 2627 'HeraldRule' => 'HeraldDAO', 2626 2628 'HeraldRuleController' => 'HeraldController',
+45
src/applications/herald/phid/HeraldPHIDTypeRule.php
··· 1 + <?php 2 + 3 + final class HeraldPHIDTypeRule extends PhabricatorPHIDType { 4 + 5 + const TYPECONST = 'HRUL'; 6 + 7 + public function getTypeConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getTypeName() { 12 + return pht('Herald Rule'); 13 + } 14 + 15 + public function newObject() { 16 + return new HeraldRule(); 17 + } 18 + 19 + public function loadObjects( 20 + PhabricatorObjectQuery $query, 21 + array $phids) { 22 + 23 + return id(new HeraldRuleQuery()) 24 + ->setViewer($query->getViewer()) 25 + ->withPHIDs($phids) 26 + ->execute(); 27 + } 28 + 29 + public function loadHandles( 30 + PhabricatorHandleQuery $query, 31 + array $handles, 32 + array $objects) { 33 + 34 + foreach ($handles as $phid => $handle) { 35 + $rule = $objects[$phid]; 36 + 37 + $id = $rule->getID(); 38 + $name = $rule->getName(); 39 + 40 + $handle->setName($name); 41 + $handle->setURI("/herald/rule/{$id}/"); 42 + } 43 + } 44 + 45 + }
+38
src/applications/herald/query/HeraldRuleQuery.php
··· 2 2 3 3 final class HeraldRuleQuery extends PhabricatorOffsetPagedQuery { 4 4 5 + private $ids; 6 + private $phids; 5 7 private $authorPHIDs; 6 8 private $ruleTypes; 7 9 private $contentTypes; 8 10 11 + // TODO: Remove when this becomes policy-aware. 12 + private $viewer; 13 + 14 + public function setViewer($viewer) { 15 + $this->viewer = $viewer; 16 + return $this; 17 + } 18 + 19 + public function getViewer() { 20 + return $this->viewer; 21 + } 22 + 23 + public function withIDs(array $ids) { 24 + $this->ids = $ids; 25 + return $this; 26 + } 27 + 28 + public function withPHIDs(array $phids) { 29 + $this->phids = $phids; 30 + return $this; 31 + } 32 + 9 33 public function withAuthorPHIDs(array $author_phids) { 10 34 $this->authorPHIDs = $author_phids; 11 35 return $this; ··· 42 66 43 67 private function buildWhereClause($conn_r) { 44 68 $where = array(); 69 + 70 + if ($this->ids) { 71 + $where[] = qsprintf( 72 + $conn_r, 73 + 'rule.id IN (%Ld)', 74 + $this->ids); 75 + } 76 + 77 + if ($this->phids) { 78 + $where[] = qsprintf( 79 + $conn_r, 80 + 'rule.phid IN (%Ls)', 81 + $this->phids); 82 + } 45 83 46 84 if ($this->authorPHIDs) { 47 85 $where[] = qsprintf(
+10
src/applications/herald/storage/HeraldRule.php
··· 19 19 private $conditions; 20 20 private $actions; 21 21 22 + public function getConfiguration() { 23 + return array( 24 + self::CONFIG_AUX_PHID => true, 25 + ) + parent::getConfiguration(); 26 + } 27 + 28 + public function generatePHID() { 29 + return PhabricatorPHID::generateNewPHID(HeraldPHIDTypeRule::TYPECONST); 30 + } 31 + 22 32 public static function loadAllByContentTypeWithFullData( 23 33 $content_type, 24 34 $object_phid) {
+12
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1519 1519 'type' => 'php', 1520 1520 'name' => $this->getPatchPath('20130805.pastemailkeypop.php'), 1521 1521 ), 1522 + '20130802.heraldphid.sql' => array( 1523 + 'type' => 'sql', 1524 + 'name' => $this->getPatchPath('20130802.heraldphid.sql'), 1525 + ), 1526 + '20130802.heraldphids.php' => array( 1527 + 'type' => 'php', 1528 + 'name' => $this->getPatchPath('20130802.heraldphids.php'), 1529 + ), 1530 + '20130802.heraldphidukey.sql' => array( 1531 + 'type' => 'sql', 1532 + 'name' => $this->getPatchPath('20130802.heraldphidukey.sql'), 1533 + ), 1522 1534 ); 1523 1535 } 1524 1536 }