From bf043deba39af2b7586b3617aa1bc534df98b6ee Mon Sep 17 00:00:00 2001
From: Joas Schilling <coding@schilljs.com>
Date: Thu, 5 Jan 2017 10:51:17 +0100
Subject: [PATCH] Kill APC because it requires PHP 5.4

Signed-off-by: Joas Schilling <coding@schilljs.com>
---
 config/config.sample.php                    |   1 -
 lib/composer/composer/autoload_classmap.php |   1 -
 lib/composer/composer/autoload_static.php   |   1 -
 lib/private/Memcache/APC.php                | 136 --------------------
 tests/lib/Memcache/APCTest.php              |  26 ----
 5 files changed, 165 deletions(-)
 delete mode 100644 lib/private/Memcache/APC.php
 delete mode 100644 tests/lib/Memcache/APCTest.php

diff --git a/config/config.sample.php b/config/config.sample.php
index 8b714a1763c..a9bb0067e5b 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 78a3fb183df..88845edf085 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 cec3bd18f15..532598ca25f 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 7db6d64b085..00000000000
--- a/lib/private/Memcache/APC.php
+++ /dev/null
@@ -1,136 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Andreas Fischer <bantu@owncloud.com>
- * @author Clark Tomlinson <fallen013@gmail.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Otto Sabart <ottosabart@seberm.com>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @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 <http://www.gnu.org/licenses/>
- *
- */
-
-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/tests/lib/Memcache/APCTest.php b/tests/lib/Memcache/APCTest.php
deleted file mode 100644
index 4bd7e62b94a..00000000000
--- a/tests/lib/Memcache/APCTest.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * 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());
-	}
-}
-- 
GitLab