@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
at upstream/main 63 lines 1.6 kB view raw
1<?php 2 3final class PhabricatorFileExternalRequest extends PhabricatorFileDAO 4 implements 5 PhabricatorDestructibleInterface { 6 7 protected $uri; 8 protected $uriIndex; 9 protected $ttl; 10 protected $filePHID; 11 protected $isSuccessful; 12 protected $responseMessage; 13 14 protected function getConfiguration() { 15 return array( 16 self::CONFIG_COLUMN_SCHEMA => array( 17 'uri' => 'text', 18 'uriIndex' => 'bytes12', 19 'ttl' => 'epoch', 20 'filePHID' => 'phid?', 21 'isSuccessful' => 'bool', 22 'responseMessage' => 'text?', 23 ), 24 self::CONFIG_KEY_SCHEMA => array( 25 'key_uriindex' => array( 26 'columns' => array('uriIndex'), 27 'unique' => true, 28 ), 29 'key_ttl' => array( 30 'columns' => array('ttl'), 31 ), 32 'key_file' => array( 33 'columns' => array('filePHID'), 34 ), 35 ), 36 ) + parent::getConfiguration(); 37 } 38 39 public function save() { 40 $hash = PhabricatorHash::digestForIndex($this->getURI()); 41 $this->setURIIndex($hash); 42 return parent::save(); 43 } 44 45/* -( PhabricatorDestructibleInterface )----------------------------------- */ 46 47 public function destroyObjectPermanently( 48 PhabricatorDestructionEngine $engine) { 49 50 $file_phid = $this->getFilePHID(); 51 if ($file_phid) { 52 $file = id(new PhabricatorFileQuery()) 53 ->setViewer($engine->getViewer()) 54 ->withPHIDs(array($file_phid)) 55 ->executeOne(); 56 if ($file) { 57 $engine->destroyObject($file); 58 } 59 } 60 $this->delete(); 61 } 62 63}