diff --git a/src/applications/feed/storage/story/PhabricatorFeedStoryData.php b/src/applications/feed/storage/story/PhabricatorFeedStoryData.php index 0050a9ffd7..36519fe56a 100644 --- a/src/applications/feed/storage/story/PhabricatorFeedStoryData.php +++ b/src/applications/feed/storage/story/PhabricatorFeedStoryData.php @@ -1,7 +1,7 @@ chronologicalKey >> 32; + if (PHP_INT_SIZE < 8) { + // We're on a 32-bit machine. + if (function_exists('bcadd')) { + // Try to use the 'bc' extension. + return bcdiv($this->chronologicalKey, bcpow(2,32)); + } else { + // Do the math in MySQL. TODO: If we formalize a bc dependency, get + // rid of this. + // See: PhabricatorFeedStoryPublisher::generateChronologicalKey() + $conn_r = id($this->establishConnection('r')); + $result = queryfx_one( + $conn_r, + // Insert the chronologicalKey as a string since longs don't seem to + // be supported by qsprintf and ints get maxed on 32 bit machines. + 'SELECT (%s >> 32) as N', + $this->chronologicalKey); + return $result['N']; + } + } else { + return $this->chronologicalKey >> 32; + } } public function getValue($key, $default = null) { diff --git a/src/applications/feed/storage/story/__init__.php b/src/applications/feed/storage/story/__init__.php index 831e139d30..8e4defec91 100644 --- a/src/applications/feed/storage/story/__init__.php +++ b/src/applications/feed/storage/story/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'applications/feed/storage/base'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); +phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phutil', 'utils');