diff --git a/config/config.sample.php b/config/config.sample.php index 8b714a1763..a9bb0067e5 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -909,7 +909,6 @@ $CONFIG = array( * * Available cache backends: * - * * ``\OC\Memcache\APC`` Alternative PHP Cache backend * * ``\OC\Memcache\APCu`` APC user backend * * ``\OC\Memcache\ArrayCache`` In-memory array-based backend (not recommended) * * ``\OC\Memcache\Memcached`` Memcached backend diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 78a3fb183d..88845edf08 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -605,7 +605,6 @@ return array( 'OC\\Log\\Syslog' => $baseDir . '/lib/private/Log/Syslog.php', 'OC\\Mail\\Mailer' => $baseDir . '/lib/private/Mail/Mailer.php', 'OC\\Mail\\Message' => $baseDir . '/lib/private/Mail/Message.php', - 'OC\\Memcache\\APC' => $baseDir . '/lib/private/Memcache/APC.php', 'OC\\Memcache\\APCu' => $baseDir . '/lib/private/Memcache/APCu.php', 'OC\\Memcache\\ArrayCache' => $baseDir . '/lib/private/Memcache/ArrayCache.php', 'OC\\Memcache\\CADTrait' => $baseDir . '/lib/private/Memcache/CADTrait.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index cec3bd18f1..532598ca25 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -635,7 +635,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Log\\Syslog' => __DIR__ . '/../../..' . '/lib/private/Log/Syslog.php', 'OC\\Mail\\Mailer' => __DIR__ . '/../../..' . '/lib/private/Mail/Mailer.php', 'OC\\Mail\\Message' => __DIR__ . '/../../..' . '/lib/private/Mail/Message.php', - 'OC\\Memcache\\APC' => __DIR__ . '/../../..' . '/lib/private/Memcache/APC.php', 'OC\\Memcache\\APCu' => __DIR__ . '/../../..' . '/lib/private/Memcache/APCu.php', 'OC\\Memcache\\ArrayCache' => __DIR__ . '/../../..' . '/lib/private/Memcache/ArrayCache.php', 'OC\\Memcache\\CADTrait' => __DIR__ . '/../../..' . '/lib/private/Memcache/CADTrait.php', diff --git a/lib/private/Memcache/APC.php b/lib/private/Memcache/APC.php deleted file mode 100644 index 7db6d64b08..0000000000 --- a/lib/private/Memcache/APC.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @author Clark Tomlinson - * @author Morris Jobke - * @author Otto Sabart - * @author Robin Appelman - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Memcache; - -use OCP\IMemcache; - -class APC extends Cache implements IMemcache { - use CASTrait { - cas as casEmulated; - } - - use CADTrait; - - public function get($key) { - $result = apc_fetch($this->getPrefix() . $key, $success); - if (!$success) { - return null; - } - return $result; - } - - public function set($key, $value, $ttl = 0) { - return apc_store($this->getPrefix() . $key, $value, $ttl); - } - - public function hasKey($key) { - return apc_exists($this->getPrefix() . $key); - } - - public function remove($key) { - return apc_delete($this->getPrefix() . $key); - } - - public function clear($prefix = '') { - $ns = $this->getPrefix() . $prefix; - $ns = preg_quote($ns, '/'); - $iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY); - return apc_delete($iter); - } - - /** - * Set a value in the cache if it's not already stored - * - * @param string $key - * @param mixed $value - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 - * @return bool - */ - public function add($key, $value, $ttl = 0) { - return apc_add($this->getPrefix() . $key, $value, $ttl); - } - - /** - * Increase a stored number - * - * @param string $key - * @param int $step - * @return int | bool - */ - public function inc($key, $step = 1) { - $this->add($key, 0); - return apc_inc($this->getPrefix() . $key, $step); - } - - /** - * Decrease a stored number - * - * @param string $key - * @param int $step - * @return int | bool - */ - public function dec($key, $step = 1) { - return apc_dec($this->getPrefix() . $key, $step); - } - - /** - * Compare and set - * - * @param string $key - * @param mixed $old - * @param mixed $new - * @return bool - */ - public function cas($key, $old, $new) { - // apc only does cas for ints - if (is_int($old) and is_int($new)) { - return apc_cas($this->getPrefix() . $key, $old, $new); - } else { - return $this->casEmulated($key, $old, $new); - } - } - - static public function isAvailable() { - if (!extension_loaded('apc')) { - return false; - } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) { - return false; - } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) { - return false; - } else { - return true; - } - } -} - -if (!function_exists('apc_exists')) { - function apc_exists($keys) { - $result = false; - apc_fetch($keys, $result); - return $result; - } -} diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index f3841d3167..8e62e020fa 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -83,7 +83,7 @@ class Factory implements ICacheFactory { $missingCacheMessage = 'Memcache {class} not available for {use} cache'; $missingCacheHint = 'Is the matching PHP module installed and enabled?'; - if (!$localCacheClass::isAvailable()) { + if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) { if (\OC::$CLI && !defined('PHPUNIT_RUN')) { // CLI should not hard-fail on broken memcache $this->logger->info($missingCacheMessage, [ @@ -98,7 +98,7 @@ class Factory implements ICacheFactory { ]), $missingCacheHint); } } - if (!$distributedCacheClass::isAvailable()) { + if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) { if (\OC::$CLI && !defined('PHPUNIT_RUN')) { // CLI should not hard-fail on broken memcache $this->logger->info($missingCacheMessage, [ @@ -113,7 +113,7 @@ class Factory implements ICacheFactory { ]), $missingCacheHint); } } - if (!($lockingCacheClass && $lockingCacheClass::isAvailable())) { + if (!($lockingCacheClass && class_exists($distributedCacheClass) && $lockingCacheClass::isAvailable())) { // don't fallback since the fallback might not be suitable for storing lock $lockingCacheClass = self::NULL_CACHE; } diff --git a/tests/lib/Memcache/APCTest.php b/tests/lib/Memcache/APCTest.php deleted file mode 100644 index 4bd7e62b94..0000000000 --- a/tests/lib/Memcache/APCTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Test\Memcache; - -class APCTest extends Cache { - protected function setUp() { - parent::setUp(); - - if(!\OC\Memcache\APC::isAvailable()) { - $this->markTestSkipped('The apc extension is not available.'); - return; - } - if(\OC\Memcache\APCu::isAvailable()) { - $this->markTestSkipped('The apc extension is emulated by ACPu.'); - return; - } - $this->instance=new \OC\Memcache\APC($this->getUniqueID()); - } -}