Differential D20180 Diff 48209 src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
| <?php | <?php | ||||
| final class HarbormasterBuildUnitMessage | final class HarbormasterBuildUnitMessage | ||||
| extends HarbormasterDAO | extends HarbormasterDAO | ||||
| implements PhabricatorPolicyInterface { | implements PhabricatorPolicyInterface { | ||||
| protected $buildTargetPHID; | protected $buildTargetPHID; | ||||
| protected $engine; | protected $engine; | ||||
| protected $namespace; | protected $namespace; | ||||
| protected $name; | protected $name; | ||||
| protected $nameIndex; | |||||
| protected $result; | protected $result; | ||||
| protected $duration; | protected $duration; | ||||
| protected $properties = array(); | protected $properties = array(); | ||||
| private $buildTarget = self::ATTACHABLE; | private $buildTarget = self::ATTACHABLE; | ||||
| const FORMAT_TEXT = 'text'; | const FORMAT_TEXT = 'text'; | ||||
| const FORMAT_REMARKUP = 'remarkup'; | const FORMAT_REMARKUP = 'remarkup'; | ||||
| ▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | protected function getConfiguration() { | ||||
| return array( | return array( | ||||
| self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
| 'properties' => self::SERIALIZATION_JSON, | 'properties' => self::SERIALIZATION_JSON, | ||||
| ), | ), | ||||
| self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
| 'engine' => 'text255', | 'engine' => 'text255', | ||||
| 'namespace' => 'text255', | 'namespace' => 'text255', | ||||
| 'name' => 'text255', | 'name' => 'text255', | ||||
| 'nameIndex' => 'bytes12', | |||||
| 'result' => 'text32', | 'result' => 'text32', | ||||
| 'duration' => 'double?', | 'duration' => 'double?', | ||||
| ), | ), | ||||
| self::CONFIG_KEY_SCHEMA => array( | self::CONFIG_KEY_SCHEMA => array( | ||||
| 'key_target' => array( | 'key_target' => array( | ||||
| 'columns' => array('buildTargetPHID'), | 'columns' => array('buildTargetPHID'), | ||||
| ), | ), | ||||
| ), | ), | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | $parts = array( | ||||
| $this->getNamespace(), | $this->getNamespace(), | ||||
| $this->getName(), | $this->getName(), | ||||
| $this->getID(), | $this->getID(), | ||||
| ); | ); | ||||
| return implode("\0", $parts); | return implode("\0", $parts); | ||||
| } | } | ||||
| public function save() { | |||||
| if ($this->nameIndex === null) { | |||||
| $this->nameIndex = HarbormasterString::newIndex($this->getName()); | |||||
| } | |||||
| // See T13088. While we're letting installs do online migrations to avoid | |||||
| // downtime, don't populate the "name" column for new writes. New writes | |||||
| // use the "HarbormasterString" table instead. | |||||
| $old_name = $this->name; | |||||
| $this->name = ''; | |||||
| $caught = null; | |||||
| try { | |||||
| $result = parent::save(); | |||||
| } catch (Exception $ex) { | |||||
| $caught = $ex; | |||||
amckinley: Should this `catch` block be scoped more tightly than just `Exception`? I'm worried about what… | |||||
| } | |||||
| $this->name = $old_name; | |||||
| if ($caught) { | |||||
| throw $caught; | |||||
| } | |||||
Done Inline ActionsWe throw anything we catch down here anyway, this is just because I want to finally { $this->name = $old_name; } but we don't have finally until PHP 5.5. If save() fails for whatever reason, I just want to avoid removing the object's name as a surprising side effect. epriestley: We throw anything we catch down here anyway, this is just because I want to `finally { $this… | |||||
| return $result; | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array( | return array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| ); | ); | ||||
| Show All 14 Lines | |||||
Should this catch block be scoped more tightly than just Exception? I'm worried about what else we might end up eating.