Path: blob/master/src/applications/feed/storage/PhabricatorFeedStoryData.php
12241 views
<?php12final class PhabricatorFeedStoryData3extends PhabricatorFeedDAO4implements PhabricatorDestructibleInterface {56protected $phid;78protected $storyType;9protected $storyData;10protected $authorPHID;11protected $chronologicalKey;1213protected function getConfiguration() {14return array(15self::CONFIG_AUX_PHID => true,16self::CONFIG_SERIALIZATION => array(17'storyData' => self::SERIALIZATION_JSON,18),19self::CONFIG_COLUMN_SCHEMA => array(20'chronologicalKey' => 'uint64',21'storyType' => 'text64',22),23self::CONFIG_KEY_SCHEMA => array(24'key_phid' => null,25'phid' => array(26'columns' => array('phid'),27'unique' => true,28),29'chronologicalKey' => array(30'columns' => array('chronologicalKey'),31'unique' => true,32),33),34) + parent::getConfiguration();35}3637public function generatePHID() {38return PhabricatorPHID::generateNewPHID(39PhabricatorPHIDConstants::PHID_TYPE_STRY);40}4142public function getEpoch() {43if (PHP_INT_SIZE < 8) {44// We're on a 32-bit machine.45if (function_exists('bcadd')) {46// Try to use the 'bc' extension.47return bcdiv($this->chronologicalKey, bcpow(2, 32));48} else {49// Do the math in MySQL. TODO: If we formalize a bc dependency, get50// rid of this.51// See: PhabricatorFeedStoryPublisher::generateChronologicalKey()52$conn_r = id($this->establishConnection('r'));53$result = queryfx_one(54$conn_r,55// Insert the chronologicalKey as a string since longs don't seem to56// be supported by qsprintf and ints get maxed on 32 bit machines.57'SELECT (%s >> 32) as N',58$this->chronologicalKey);59return $result['N'];60}61} else {62return $this->chronologicalKey >> 32;63}64}6566public function getValue($key, $default = null) {67return idx($this->storyData, $key, $default);68}697071/* -( PhabricatorDestructibleInterface )----------------------------------- */727374public function destroyObjectPermanently(75PhabricatorDestructionEngine $engine) {7677$this->openTransaction();78$conn = $this->establishConnection('w');7980queryfx(81$conn,82'DELETE FROM %T WHERE chronologicalKey = %s',83id(new PhabricatorFeedStoryNotification())->getTableName(),84$this->getChronologicalKey());8586queryfx(87$conn,88'DELETE FROM %T WHERE chronologicalKey = %s',89id(new PhabricatorFeedStoryReference())->getTableName(),90$this->getChronologicalKey());9192$this->delete();93$this->saveTransaction();94}9596}979899