From df21391b8e7b23de4fe18193b19b5b252da3efd1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 Aug 2017 14:04:08 -0700 Subject: [PATCH] When "apcu_clear_cache()" exists, prefer it as a cache clear callback over "apc_clear_cache()" Summary: See PHI36. APCu originally had `apc_` methods, but at some point dropped these and only provides `apcu_` methods. When the `apcu_` method is present, use it. It may not be present for older versions of APCu, so keep the fallback. Test Plan: - With modern APCu, clicked "Purge Caches" in Config > Caches. - Before: fatal on bad `apc_clear_caches` call. - After: Valid cache clear. Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D18449 --- src/applications/cache/spec/PhabricatorDataCacheSpec.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/applications/cache/spec/PhabricatorDataCacheSpec.php b/src/applications/cache/spec/PhabricatorDataCacheSpec.php index 482af00d00..bf6a495f7f 100644 --- a/src/applications/cache/spec/PhabricatorDataCacheSpec.php +++ b/src/applications/cache/spec/PhabricatorDataCacheSpec.php @@ -50,9 +50,15 @@ final class PhabricatorDataCacheSpec extends PhabricatorCacheSpec { ->setVersion(phpversion('apcu')); if (ini_get('apc.enabled')) { + if (function_exists('apcu_clear_cache')) { + $clear_callback = 'apcu_clear_cache'; + } else { + $clear_callback = 'apc_clear_cache'; + } + $this ->setIsEnabled(true) - ->setClearCacheCallback('apc_clear_cache'); + ->setClearCacheCallback($clear_callback); $this->initAPCCommonSpec(); } else { $this->setIsEnabled(false);