@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.

Remove PHP APC support and APC references

Summary:
APC saw its last release in 2012.
It has been discontinued as PHP 5.5+ includes OpCache.
It has been superseded by APCu for object caching.
See https://pecl.php.net/package-info.php?package=APC

Phorge requires PHP 7.2.
Thus remove any references to APC.

Also note that "If APCu is installed, it reports that APC is installed" does not hold true anymore: In PHP 8.3, "php -m" correctly reports "apcu".

Test Plan:
* Make sure APCU is not installed, see `PHP Extension "APCu" Not Installed" under "Unresolved Setup Issues" as an admin
* Apply patch, still see same issue listed.
* Install `php-pecl-apcu` package on Fedora system; see that now the issue is not listed anymore under "Unresolved Setup Issues"

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25950

+32 -164
+6 -20
src/applications/cache/spec/PhabricatorCacheSpec.php
··· 78 78 return $this->entryCount; 79 79 } 80 80 81 - protected function raiseInstallAPCIssue() { 82 - $message = pht( 83 - "Installing the PHP extension 'APC' (Alternative PHP Cache) will ". 84 - "dramatically improve performance. Note that APC versions 3.1.14 and ". 85 - "3.1.15 are broken; 3.1.13 is recommended instead."); 86 - 87 - return $this 88 - ->newIssue('extension.apc') 89 - ->setShortName(pht('APC')) 90 - ->setName(pht("PHP Extension 'APC' Not Installed")) 91 - ->setMessage($message) 92 - ->addPHPExtension('apc'); 93 - } 94 - 95 81 protected function raiseEnableAPCIssue() { 96 - $summary = pht('Enabling APC/APCu will improve performance.'); 82 + $summary = pht('Enabling APCu will improve performance.'); 97 83 $message = pht( 98 - 'The APC or APCu PHP extensions are installed, but not enabled in your '. 99 - 'PHP configuration. Enabling these extensions will improve performance. '. 100 - 'Edit the "%s" setting to enable these extensions.', 84 + 'The APCu PHP extension is installed, but not enabled in your '. 85 + 'PHP configuration. Enabling this extension will improve performance. '. 86 + 'Edit the "%s" setting to enable this extension.', 101 87 'apc.enabled'); 102 88 103 89 return $this 104 90 ->newIssue('extension.apc.enabled') 105 - ->setShortName(pht('APC/APCu Disabled')) 106 - ->setName(pht('APC/APCu Extensions Not Enabled')) 91 + ->setShortName(pht('APCu Disabled')) 92 + ->setName(pht('APCu Extension Not Enabled')) 107 93 ->setSummary($summary) 108 94 ->setMessage($message) 109 95 ->addPHPConfig('apc.enabled');
+13 -36
src/applications/cache/spec/PhabricatorDataCacheSpec.php
··· 16 16 public static function getActiveCacheSpec() { 17 17 $spec = new PhabricatorDataCacheSpec(); 18 18 19 - // NOTE: If APCu is installed, it reports that APC is installed. 20 - if (extension_loaded('apc') && !extension_loaded('apcu')) { 21 - $spec->initAPCSpec(); 22 - } else if (extension_loaded('apcu')) { 19 + if (extension_loaded('apcu')) { 23 20 $spec->initAPCuSpec(); 24 21 } else { 25 22 $spec->initNoneSpec(); ··· 28 25 return $spec; 29 26 } 30 27 31 - private function initAPCSpec() { 32 - $this 33 - ->setName(pht('APC User Cache')) 34 - ->setVersion(phpversion('apc')); 35 - 36 - if (ini_get('apc.enabled')) { 37 - $this 38 - ->setIsEnabled(true) 39 - ->setClearCacheCallback('apc_clear_cache'); 40 - $this->initAPCCommonSpec(); 41 - } else { 42 - $this->setIsEnabled(false); 43 - $this->raiseEnableAPCIssue(); 44 - } 45 - } 46 - 47 28 private function initAPCuSpec() { 48 29 $this 49 30 ->setName(pht('APCu')) ··· 67 48 } 68 49 69 50 private function initNoneSpec() { 70 - if (version_compare(phpversion(), '5.5', '>=')) { 71 - $message = pht( 72 - 'Installing the "APCu" PHP extension will improve performance. '. 73 - 'This extension is strongly recommended. Without it, this software '. 74 - 'must rely on a very inefficient disk-based cache.'); 51 + $message = pht( 52 + 'Installing the "APCu" PHP extension will improve performance. '. 53 + 'This extension is strongly recommended. Without it, this software '. 54 + 'must rely on a very inefficient disk-based cache.'); 75 55 76 - $this 77 - ->newIssue('extension.apcu') 78 - ->setShortName(pht('APCu')) 79 - ->setName(pht('PHP Extension "APCu" Not Installed')) 80 - ->setMessage($message) 81 - ->addPHPExtension('apcu'); 82 - } else { 83 - $this->raiseInstallAPCIssue(); 84 - } 56 + $this 57 + ->newIssue('extension.apcu') 58 + ->setShortName(pht('APCu')) 59 + ->setName(pht('PHP Extension "APCu" Not Installed')) 60 + ->setMessage($message) 61 + ->addPHPExtension('apcu'); 85 62 } 86 63 87 64 private function initAPCCommonSpec() { ··· 107 84 $state = array(); 108 85 foreach ($cache as $item) { 109 86 // Some older versions of APCu report the cachekey as "key", while 110 - // newer APCu and APC report it as "info". Just check both indexes 111 - // for commpatibility. See T13164 for details. 87 + // newer APCu report it as "info". Just check both indexes for 88 + // compatibility. See T13164 for details. 112 89 113 90 $info = idx($item, 'info'); 114 91 if ($info === null) {
+10 -105
src/applications/cache/spec/PhabricatorOpcodeCacheSpec.php
··· 5 5 public static function getActiveCacheSpec() { 6 6 $spec = new PhabricatorOpcodeCacheSpec(); 7 7 8 - // NOTE: If APCu is installed, it reports that APC is installed. 9 - if (extension_loaded('apc') && !extension_loaded('apcu')) { 10 - $spec->initAPCSpec(); 11 - } else if (extension_loaded('Zend OPcache')) { 8 + if (extension_loaded('Zend OPcache')) { 12 9 $spec->initOpcacheSpec(); 13 10 } else { 14 11 $spec->initNoneSpec(); ··· 17 14 return $spec; 18 15 } 19 16 20 - private function initAPCSpec() { 21 - $this 22 - ->setName(pht('APC')) 23 - ->setVersion(phpversion('apc')); 24 - 25 - if (ini_get('apc.enabled')) { 26 - $this 27 - ->setIsEnabled(true) 28 - ->setClearCacheCallback('apc_clear_cache'); 29 - 30 - $mem = apc_sma_info(); 31 - $this->setTotalMemory($mem['num_seg'] * $mem['seg_size']); 32 - 33 - $info = apc_cache_info(); 34 - $this->setUsedMemory($info['mem_size']); 35 - 36 - $write_lock = ini_get('apc.write_lock'); 37 - $slam_defense = ini_get('apc.slam_defense'); 38 - 39 - if (!$write_lock || $slam_defense) { 40 - $summary = pht('Adjust APC settings to quiet unnecessary errors.'); 41 - 42 - $message = pht( 43 - 'Some versions of APC may emit unnecessary errors into the '. 44 - 'error log under the current APC settings. To resolve this, '. 45 - 'enable "%s" and disable "%s" in your PHP configuration.', 46 - 'apc.write_lock', 47 - 'apc.slam_defense'); 48 - 49 - $this 50 - ->newIssue('extension.apc.write-lock') 51 - ->setShortName(pht('Noisy APC')) 52 - ->setName(pht('APC Has Noisy Configuration')) 53 - ->setSummary($summary) 54 - ->setMessage($message) 55 - ->addPHPConfig('apc.write_lock') 56 - ->addPHPConfig('apc.slam_defense'); 57 - } 58 - 59 - $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); 60 - $is_stat_enabled = ini_get('apc.stat'); 61 - if ($is_stat_enabled && !$is_dev) { 62 - $summary = pht( 63 - '"%s" is currently enabled, but should probably be disabled.', 64 - 'apc.stat'); 65 - 66 - $message = pht( 67 - 'The "%s" setting is currently enabled in your PHP configuration. '. 68 - 'In production mode, "%s" should be disabled. '. 69 - 'This will improve performance slightly.', 70 - 'apc.stat', 71 - 'apc.stat'); 72 - 73 - $this 74 - ->newIssue('extension.apc.stat-enabled') 75 - ->setShortName(pht('"%s" Enabled', 'apc.stat')) 76 - ->setName(pht('"%s" Enabled in Production', 'apc.stat')) 77 - ->setSummary($summary) 78 - ->setMessage($message) 79 - ->addPHPConfig('apc.stat') 80 - ->addPhabricatorConfig('phabricator.developer-mode'); 81 - } else if (!$is_stat_enabled && $is_dev) { 82 - $summary = pht( 83 - '"%s" is currently disabled, but should probably be enabled.', 84 - 'apc.stat'); 85 - 86 - $message = pht( 87 - 'The "%s" setting is currently disabled in your PHP configuration, '. 88 - 'but this software is running in development mode. This option '. 89 - 'should normally be enabled in development so you do not need to '. 90 - 'restart anything after making changes to the code.', 91 - 'apc.stat'); 92 - 93 - $this 94 - ->newIssue('extension.apc.stat-disabled') 95 - ->setShortName(pht('"%s" Disabled', 'apc.stat')) 96 - ->setName(pht('"%s" Disabled in Development', 'apc.stat')) 97 - ->setSummary($summary) 98 - ->setMessage($message) 99 - ->addPHPConfig('apc.stat') 100 - ->addPhabricatorConfig('phabricator.developer-mode'); 101 - } 102 - } else { 103 - $this->setIsEnabled(false); 104 - $this->raiseEnableAPCIssue(); 105 - } 106 - } 107 - 108 17 private function initOpcacheSpec() { 109 18 $this 110 19 ->setName(pht('Zend OPcache')) ··· 187 96 } 188 97 189 98 private function initNoneSpec() { 190 - if (version_compare(phpversion(), '5.5', '>=')) { 191 - $message = pht( 192 - 'Installing the "Zend OPcache" extension will dramatically improve '. 193 - 'performance.'); 99 + $message = pht( 100 + 'Installing the "Zend OPcache" extension will dramatically improve '. 101 + 'performance.'); 194 102 195 - $this 196 - ->newIssue('extension.opcache') 197 - ->setShortName(pht('OPcache')) 198 - ->setName(pht('Zend OPcache Not Installed')) 199 - ->setMessage($message) 200 - ->addPHPExtension('Zend OPcache'); 201 - } else { 202 - $this->raiseInstallAPCIssue(); 203 - } 103 + $this 104 + ->newIssue('extension.opcache') 105 + ->setShortName(pht('OPcache')) 106 + ->setName(pht('Zend OPcache Not Installed')) 107 + ->setMessage($message) 108 + ->addPHPExtension('Zend OPcache'); 204 109 } 205 110 }
+3 -3
src/infrastructure/cache/PhutilKeyValueCache.php
··· 1 1 <?php 2 2 3 3 /** 4 - * Interface to a key-value cache like Memcache or APC. This class provides a 4 + * Interface to a key-value cache like Memcache or APCu. This class provides a 5 5 * uniform interface to multiple different key-value caches and integration 6 6 * with PhutilServiceProfiler. 7 7 * ··· 14 14 15 15 16 16 /** 17 - * Determine if the cache is available. For example, the APC cache tests if 18 - * APC is installed. If this method returns false, the cache is not 17 + * Determine if the cache is available. For example, the APCu cache tests if 18 + * APCu is installed. If this method returns false, the cache is not 19 19 * operational and can not be used. 20 20 * 21 21 * @return bool True if the cache can be used.