@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

With APCu 5+, use `apcu_*` function to examine cache state

Summary: Ref T9640. APCu 5.0+ (for PHP7) uses `apcu_*` functions instead of `apc_` functions. Test for function existence and call the appropriate functions.

Test Plan: {F2352695}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9640

Differential Revision: https://secure.phabricator.com/D17198

+31 -19
+31 -19
src/applications/cache/spec/PhabricatorDataCacheSpec.php
··· 79 79 } 80 80 81 81 private function initAPCCommonSpec() { 82 - $mem = apc_sma_info(); 83 - $this->setTotalMemory($mem['num_seg'] * $mem['seg_size']); 82 + $state = array(); 84 83 85 - $info = apc_cache_info('user'); 86 - $this->setUsedMemory($info['mem_size']); 87 - $this->setEntryCount(count($info['cache_list'])); 84 + if (function_exists('apcu_sma_info')) { 85 + $mem = apcu_sma_info(); 86 + $info = apcu_cache_info(); 87 + } else if (function_exists('apc_sma_info')) { 88 + $mem = apc_sma_info(); 89 + $info = apc_cache_info('user'); 90 + } else { 91 + $mem = null; 92 + } 88 93 89 - $cache = $info['cache_list']; 90 - $state = array(); 91 - foreach ($cache as $item) { 92 - $info = idx($item, 'info', '<unknown-key>'); 93 - $key = self::getKeyPattern($info); 94 - if (empty($state[$key])) { 95 - $state[$key] = array( 96 - 'max' => 0, 97 - 'total' => 0, 98 - 'count' => 0, 99 - ); 94 + if ($mem) { 95 + $this->setTotalMemory($mem['num_seg'] * $mem['seg_size']); 96 + 97 + $this->setUsedMemory($info['mem_size']); 98 + $this->setEntryCount(count($info['cache_list'])); 99 + 100 + $cache = $info['cache_list']; 101 + $state = array(); 102 + foreach ($cache as $item) { 103 + $info = idx($item, 'info', '<unknown-key>'); 104 + $key = self::getKeyPattern($info); 105 + if (empty($state[$key])) { 106 + $state[$key] = array( 107 + 'max' => 0, 108 + 'total' => 0, 109 + 'count' => 0, 110 + ); 111 + } 112 + $state[$key]['max'] = max($state[$key]['max'], $item['mem_size']); 113 + $state[$key]['total'] += $item['mem_size']; 114 + $state[$key]['count']++; 100 115 } 101 - $state[$key]['max'] = max($state[$key]['max'], $item['mem_size']); 102 - $state[$key]['total'] += $item['mem_size']; 103 - $state[$key]['count']++; 104 116 } 105 117 106 118 $this->setCacheSummary($state);