@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

Correctly implementing mailkey for Phurl

Summary: Re T6049, Correctly implementing mailkey for Phurl

Test Plan: Edit Phurl URL, receive email.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

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

+34 -7
+2
resources/sql/autopatches/20151130.phurl.mailkey.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phurl.phurl_url 2 + ADD mailKey binary(20) NOT NULL;
+18
resources/sql/autopatches/20151130.phurl.mailkey.2.php
··· 1 + <?php 2 + 3 + $table = new PhabricatorPhurlURL(); 4 + $conn_w = $table->establishConnection('w'); 5 + $iterator = new LiskMigrationIterator($table); 6 + foreach ($iterator as $url) { 7 + $id = $url->getID(); 8 + 9 + echo pht('Adding mail key for Phurl %d...', $id); 10 + echo "\n"; 11 + 12 + queryfx( 13 + $conn_w, 14 + 'UPDATE %T SET mailKey = %s WHERE id = %d', 15 + $table->getTableName(), 16 + Filesystem::readRandomCharacters(20), 17 + $id); 18 + }
+2 -4
src/applications/phurl/editor/PhabricatorPhurlURLEditor.php
··· 211 211 212 212 public function getMailTagsMap() { 213 213 return array( 214 - PhabricatorPhurlURLTransaction::MAILTAG_CONTENT => 214 + PhabricatorPhurlURLTransaction::MAILTAG_DETAILS => 215 215 pht( 216 - "A URL's name or path changes."), 217 - PhabricatorPhurlURLTransaction::MAILTAG_OTHER => 218 - pht('Other event activity not listed above occurs.'), 216 + "A URL's details change."), 219 217 ); 220 218 } 221 219
+10
src/applications/phurl/storage/PhabricatorPhurlURL.php
··· 22 22 protected $authorPHID; 23 23 protected $spacePHID; 24 24 25 + protected $mailKey; 26 + 25 27 const DEFAULT_ICON = 'fa-compress'; 26 28 27 29 public static function initializeNewPhurlURL(PhabricatorUser $actor) { ··· 45 47 'alias' => 'sort64?', 46 48 'longURL' => 'text', 47 49 'description' => 'text', 50 + 'mailKey' => 'bytes20', 48 51 ), 49 52 self::CONFIG_KEY_SCHEMA => array( 50 53 'key_instance' => array( ··· 56 59 ), 57 60 ), 58 61 ) + parent::getConfiguration(); 62 + } 63 + 64 + public function save() { 65 + if (!$this->getMailKey()) { 66 + $this->setMailKey(Filesystem::readRandomCharacters(20)); 67 + } 68 + return parent::save(); 59 69 } 60 70 61 71 public function generatePHID() {
+2 -3
src/applications/phurl/storage/PhabricatorPhurlURLTransaction.php
··· 8 8 const TYPE_ALIAS = 'phurl.alias'; 9 9 const TYPE_DESCRIPTION = 'phurl.description'; 10 10 11 - const MAILTAG_CONTENT = 'phurl:content'; 12 - const MAILTAG_OTHER = 'phurl:other'; 11 + const MAILTAG_DETAILS = 'phurl-details'; 13 12 14 13 public function getApplicationName() { 15 14 return 'phurl'; ··· 235 234 case self::TYPE_DESCRIPTION: 236 235 case self::TYPE_URL: 237 236 case self::TYPE_ALIAS: 238 - $tags[] = self::MAILTAG_CONTENT; 237 + $tags[] = self::MAILTAG_DETAILS; 239 238 break; 240 239 } 241 240 return $tags;