Skip to content

Commit

Permalink
Don't allow executing cli if cache backend is unavailable
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <[email protected]>
  • Loading branch information
st3iny committed Feb 23, 2021
1 parent ff54a04 commit 2d6f391
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions lib/private/Memcache/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,34 +86,14 @@ public function __construct(string $globalPrefix, ILogger $logger,
$missingCacheMessage = 'Memcache {class} not available for {use} cache';
$missingCacheHint = 'Is the matching PHP module installed and enabled?';
if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) {
if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
// CLI should not hard-fail on broken memcache
$this->logger->info($missingCacheMessage, [
'class' => $localCacheClass,
'use' => 'local',
'app' => 'cli'
]);
$localCacheClass = self::NULL_CACHE;
} else {
throw new \OC\HintException(strtr($missingCacheMessage, [
'{class}' => $localCacheClass, '{use}' => 'local'
]), $missingCacheHint);
}
throw new \OC\HintException(strtr($missingCacheMessage, [
'{class}' => $localCacheClass, '{use}' => 'local'
]), $missingCacheHint);
}
if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) {
if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
// CLI should not hard-fail on broken memcache
$this->logger->info($missingCacheMessage, [
'class' => $distributedCacheClass,
'use' => 'distributed',
'app' => 'cli'
]);
$distributedCacheClass = self::NULL_CACHE;
} else {
throw new \OC\HintException(strtr($missingCacheMessage, [
'{class}' => $distributedCacheClass, '{use}' => 'distributed'
]), $missingCacheHint);
}
throw new \OC\HintException(strtr($missingCacheMessage, [
'{class}' => $distributedCacheClass, '{use}' => 'distributed'
]), $missingCacheHint);
}
if (!($lockingCacheClass && class_exists($distributedCacheClass) && $lockingCacheClass::isAvailable())) {
// don't fallback since the fallback might not be suitable for storing lock
Expand Down

0 comments on commit 2d6f391

Please sign in to comment.