@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 remaining calls to discontinued APC

Summary:
Followup to rP3f5f18a8d6ee7e67e45842b2e63b6485283ee42a. No clue why I missed all this stuff at that time.

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 remaining calls to APC functions.

The PHP documentation does not even include APC functions anymore, you need to visit web archives, for example:
* https://web.archive.org/web/20200518114542/https://www.php.net/manual/en/function.apc-cache-info.php
* https://web.archive.org/web/20200518114557/https://www.php.net/manual/en/function.apc-clear-cache.php
* https://web.archive.org/web/20200518114721/https://www.php.net/manual/en/function.apc-sma-info.php

Closes T16116

Test Plan: Same as rP3f5f18a8d6ee7e67e45842b2e63b6485283ee42a, I assume.

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16116

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

+9 -51
-5
src/applications/cache/spec/PhabricatorDataCacheSpec.php
··· 33 33 if (ini_get('apc.enabled')) { 34 34 if (function_exists('apcu_clear_cache')) { 35 35 $clear_callback = 'apcu_clear_cache'; 36 - } else { 37 - $clear_callback = 'apc_clear_cache'; 38 36 } 39 37 40 38 $this ··· 67 65 if (function_exists('apcu_sma_info')) { 68 66 $mem = apcu_sma_info(); 69 67 $info = apcu_cache_info(); 70 - } else if (function_exists('apc_sma_info')) { 71 - $mem = apc_sma_info(); 72 - $info = apc_cache_info('user'); 73 68 } else { 74 69 $mem = null; 75 70 }
+3 -11
src/infrastructure/cache/PhutilAPCKeyValueCache.php
··· 11 11 12 12 13 13 public function isAvailable() { 14 - return (function_exists('apc_fetch') || function_exists('apcu_fetch')) && 14 + return function_exists('apcu_fetch') && 15 15 ini_get('apc.enabled') && 16 16 (ini_get('apc.enable_cli') || php_sapi_name() != 'cli'); 17 17 } ··· 27 27 foreach ($keys as $key) { 28 28 if ($is_apcu) { 29 29 $result = apcu_fetch($key, $fetched); 30 - } else { 31 - $result = apc_fetch($key, $fetched); 32 30 } 33 31 34 32 if ($fetched) { ··· 48 46 $ttl = 0; 49 47 } 50 48 51 - // NOTE: Although modern APC supports passing an array to `apc_store()`, 52 - // it is not supported by older version of APC or by HPHP. 49 + // NOTE: Although late APC supported passing an array to `apc_store()`, 50 + // it was not supported by older versions of APC or by HPHP. 53 51 54 52 // See T13525 for discussion of use of "@" to silence this warning: 55 53 // > GC cache entry "<some-key-name>" was on gc-list for <X> seconds ··· 57 55 foreach ($keys as $key => $value) { 58 56 if ($is_apcu) { 59 57 @apcu_store($key, $value, $ttl); 60 - } else { 61 - @apc_store($key, $value, $ttl); 62 58 } 63 59 } 64 60 ··· 74 70 foreach ($keys as $key) { 75 71 if ($is_apcu) { 76 72 apcu_delete($key); 77 - } else { 78 - apc_delete($key); 79 73 } 80 74 } 81 75 ··· 90 84 91 85 if ($is_apcu) { 92 86 apcu_clear_cache(); 93 - } else { 94 - apc_clear_cache('user'); 95 87 } 96 88 97 89 return $this;
+3 -3
src/infrastructure/cache/__tests__/PhutilKeyValueCacheTestCase.php
··· 234 234 235 235 236 236 // NOTE: The TTL tests are necessarily slow (we must sleep() through the 237 - // TTLs) and do not work with APC (it does not TTL until the next request) 238 - // so they're disabled by default. If you're developing the cache stack, 239 - // it may be useful to run them. 237 + // TTLs) and did not work with old APC (it does not TTL until the next 238 + // request) so they're disabled by default. If you're developing the cache 239 + // stack, it may be useful to run them. 240 240 241 241 return; 242 242
+3 -16
support/startup/PhabricatorClientLimit.php
··· 37 37 // NOTE: We can not use pht() here because this runs before libraries 38 38 // load. 39 39 40 - if (!function_exists('apc_fetch') && !function_exists('apcu_fetch')) { 40 + if (!function_exists('apcu_fetch')) { 41 41 throw new Exception( 42 - 'You can not configure connection rate limits unless APC/APCu are '. 43 - 'available. Rate limits rely on APC/APCu to track clients and '. 42 + 'You can not configure connection rate limits unless APCu is '. 43 + 'available. Rate limits rely on APCu to track clients and '. 44 44 'connections.'); 45 45 } 46 46 ··· 199 199 200 200 if ($is_apcu) { 201 201 $bucket = apcu_fetch($bucket_key); 202 - } else { 203 - $bucket = apc_fetch($bucket_key); 204 202 } 205 203 206 204 if (!is_array($bucket)) { ··· 216 214 217 215 if ($is_apcu) { 218 216 @apcu_store($bucket_key, $bucket); 219 - } else { 220 - @apc_store($bucket_key, $bucket); 221 217 } 222 218 223 219 return $this; ··· 237 233 $min_key = $this->getMinimumBucketCacheKey(); 238 234 if ($is_apcu) { 239 235 $min = apcu_fetch($min_key); 240 - } else { 241 - $min = apc_fetch($min_key); 242 236 } 243 237 244 238 // If we don't have any buckets stored yet, store the current bucket as ··· 247 241 if (!$min) { 248 242 if ($is_apcu) { 249 243 @apcu_store($min_key, $cur); 250 - } else { 251 - @apc_store($min_key, $cur); 252 244 } 253 245 $min = $cur; 254 246 } ··· 262 254 if ($is_apcu) { 263 255 apcu_delete($bucket_key); 264 256 @apcu_store($min_key, $cursor + 1); 265 - } else { 266 - apc_delete($bucket_key); 267 - @apc_store($min_key, $cursor + 1); 268 257 } 269 258 } 270 259 ··· 276 265 $bucket_key = $this->getBucketCacheKey($cursor); 277 266 if ($is_apcu) { 278 267 $bucket = apcu_fetch($bucket_key); 279 - } else { 280 - $bucket = apc_fetch($bucket_key); 281 268 } 282 269 if (isset($bucket[$client_key])) { 283 270 $score += $bucket[$client_key];
-16
support/startup/PhabricatorStartup.php
··· 557 557 } 558 558 } 559 559 560 - if (extension_loaded('apc')) { 561 - $apc_version = phpversion('apc'); 562 - $known_bad = array( 563 - '3.1.14' => true, 564 - '3.1.15' => true, 565 - '3.1.15-dev' => true, 566 - ); 567 - if (isset($known_bad[$apc_version])) { 568 - self::didFatal( 569 - "You have APC {$apc_version} installed. This version of APC is ". 570 - "known to be bad, and does not work with Phorge (it will cause ". 571 - "Phorge to fatal unrecoverably with nonsense errors).". 572 - "Downgrade to version 3.1.13."); 573 - } 574 - } 575 - 576 560 if (isset($_SERVER['HTTP_PROXY'])) { 577 561 self::didFatal( 578 562 'This HTTP request included a "Proxy:" header, poisoning the '.