diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-10-29 15:28:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-29 15:28:47 +0100 |
commit | 2d5060d1e3161aadfafb11d3690bc337b9092d31 (patch) | |
tree | 5b558b5e63649d47e975ff9da042dc02d7613086 /lib/private | |
parent | ce2e1a001b2b046a8a763d6e36c1c6256acc7598 (diff) | |
parent | 89cd3b4f88253158bc585b5bda0f3be8df878f10 (diff) | |
download | nextcloud-server-2d5060d1e3161aadfafb11d3690bc337b9092d31.tar.gz nextcloud-server-2d5060d1e3161aadfafb11d3690bc337b9092d31.zip |
Merge pull request #46151 from nextcloud/enh/do-not-enforce-cache-for-cli
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Memcache/Factory.php | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 1d5bcdac16a..a44f0127651 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -72,14 +72,28 @@ class Factory implements ICacheFactory { $missingCacheMessage = 'Memcache {class} not available for {use} cache'; $missingCacheHint = 'Is the matching PHP module installed and enabled?'; if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) { - throw new \OCP\HintException(strtr($missingCacheMessage, [ - '{class}' => $localCacheClass, '{use}' => 'local' - ]), $missingCacheHint); + if (\OC::$CLI && !defined('PHPUNIT_RUN') && $localCacheClass === APCu::class) { + // CLI should not fail if APCu is not available but fallback to NullCache. + // This can be the case if APCu is used without apc.enable_cli=1. + // APCu however cannot be shared between PHP instances (CLI and web) anyway. + $localCacheClass = self::NULL_CACHE; + } else { + throw new \OCP\HintException(strtr($missingCacheMessage, [ + '{class}' => $localCacheClass, '{use}' => 'local' + ]), $missingCacheHint); + } } if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) { - throw new \OCP\HintException(strtr($missingCacheMessage, [ - '{class}' => $distributedCacheClass, '{use}' => 'distributed' - ]), $missingCacheHint); + if (\OC::$CLI && !defined('PHPUNIT_RUN') && $distributedCacheClass === APCu::class) { + // CLI should not fail if APCu is not available but fallback to NullCache. + // This can be the case if APCu is used without apc.enable_cli=1. + // APCu however cannot be shared between Nextcloud (PHP) instances anyway. + $distributedCacheClass = self::NULL_CACHE; + } else { + throw new \OCP\HintException(strtr($missingCacheMessage, [ + '{class}' => $distributedCacheClass, '{use}' => 'distributed' + ]), $missingCacheHint); + } } if (!($lockingCacheClass && class_exists($lockingCacheClass) && $lockingCacheClass::isAvailable())) { // don't fall back since the fallback might not be suitable for storing lock |