3 final class PhabricatorFeedStoryData
4 extends PhabricatorFeedDAO
5 implements PhabricatorDestructibleInterface
{
11 protected $authorPHID;
12 protected $chronologicalKey;
14 protected function getConfiguration() {
16 self
::CONFIG_AUX_PHID
=> true,
17 self
::CONFIG_SERIALIZATION
=> array(
18 'storyData' => self
::SERIALIZATION_JSON
,
20 self
::CONFIG_COLUMN_SCHEMA
=> array(
21 'chronologicalKey' => 'uint64',
22 'storyType' => 'text64',
24 self
::CONFIG_KEY_SCHEMA
=> array(
27 'columns' => array('phid'),
30 'chronologicalKey' => array(
31 'columns' => array('chronologicalKey'),
35 ) + parent
::getConfiguration();
38 public function generatePHID() {
39 return PhabricatorPHID
::generateNewPHID(
40 PhabricatorPHIDConstants
::PHID_TYPE_STRY
);
43 public function getEpoch() {
44 if (PHP_INT_SIZE
< 8) {
45 // We're on a 32-bit machine.
46 if (function_exists('bcadd')) {
47 // Try to use the 'bc' extension.
48 return bcdiv($this->chronologicalKey
, bcpow(2, 32));
50 // Do the math in MySQL. TODO: If we formalize a bc dependency, get
52 // See: PhabricatorFeedStoryPublisher::generateChronologicalKey()
53 $conn_r = id($this->establishConnection('r'));
54 $result = queryfx_one(
56 // Insert the chronologicalKey as a string since longs don't seem to
57 // be supported by qsprintf and ints get maxed on 32 bit machines.
58 'SELECT (%s >> 32) as N',
59 $this->chronologicalKey
);
63 return $this->chronologicalKey
>> 32;
67 public function getValue($key, $default = null) {
68 return idx($this->storyData
, $key, $default);
72 /* -( PhabricatorDestructibleInterface )----------------------------------- */
75 public function destroyObjectPermanently(
76 PhabricatorDestructionEngine
$engine) {
78 $this->openTransaction();
79 $conn = $this->establishConnection('w');
83 'DELETE FROM %T WHERE chronologicalKey = %s',
84 id(new PhabricatorFeedStoryNotification())->getTableName(),
85 $this->getChronologicalKey());
89 'DELETE FROM %T WHERE chronologicalKey = %s',
90 id(new PhabricatorFeedStoryReference())->getTableName(),
91 $this->getChronologicalKey());
94 $this->saveTransaction();