[Pkg-owncloud-commits] [owncloud] 28/104: Backport of PR #4378: Don't use xcache in case admin auth is enabled.

David Prévot taffit at moszumanska.debian.org
Sat Jan 18 13:33:37 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 93b6c83814007633f3b4333ec9b113306e24b584
Author: Andreas Fischer <bantu at owncloud.com>
Date:   Fri Dec 20 17:15:48 2013 +0100

    Backport of PR #4378: Don't use xcache in case admin auth is enabled.
---
 lib/private/memcache/xcache.php | 26 +++++++++++++++++---------
 lib/private/util.php            |  6 +++++-
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/lib/private/memcache/xcache.php b/lib/private/memcache/xcache.php
index 4485f90..1337a7a 100644
--- a/lib/private/memcache/xcache.php
+++ b/lib/private/memcache/xcache.php
@@ -8,9 +8,13 @@
 
 namespace OC\Memcache;
 
+/**
+ * See http://xcache.lighttpd.net/wiki/XcacheApi for provided constants and
+ * functions etc.
+ */
 class XCache extends Cache {
 	/**
-	 * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
+	 * entries in XCache gets namespaced to prevent collisions between ownCloud instances and users
 	 */
 	protected function getNameSpace() {
 		return $this->prefix;
@@ -37,7 +41,12 @@ class XCache extends Cache {
 	}
 
 	public function clear($prefix='') {
-		xcache_unset_by_prefix($this->getNamespace().$prefix);
+		if (function_exists('xcache_unset_by_prefix')) {
+			return xcache_unset_by_prefix($this->getNamespace().$prefix);
+		} else {
+			// Since we can not clear by prefix, we just clear the whole cache.
+			xcache_clear_cache(\XC_TYPE_VAR, 0);
+		}
 		return true;
 	}
 
@@ -48,6 +57,12 @@ class XCache extends Cache {
 		if (\OC::$CLI) {
 			return false;
 		}
+		if (!function_exists('xcache_unset_by_prefix') && ini_get('xcache.admin.enable_auth')) {
+			// We do not want to use XCache if we can not clear it without
+			// using the administration function xcache_clear_cache()
+			// AND administration functions are password-protected.
+			return false;
+		}
 		$var_size = (int) ini_get('xcache.var_size');
 		if (!$var_size) {
 			return false;
@@ -55,10 +70,3 @@ class XCache extends Cache {
 		return true;
 	}
 }
-
-if(!function_exists('xcache_unset_by_prefix')) {
-	function xcache_unset_by_prefix($prefix) {
-		// Since we can't clear targetted cache, we'll clear all. :(
-		xcache_clear_cache(\XC_TYPE_VAR, 0);
-	}
-}
diff --git a/lib/private/util.php b/lib/private/util.php
index a73564b..c0e618c 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -1085,7 +1085,11 @@ class OC_Util {
 		}
 		// XCache
 		if (function_exists('xcache_clear_cache')) {
-			xcache_clear_cache(XC_TYPE_VAR, 0);
+			if (ini_get('xcache.admin.enable_auth')) {
+				OC_Log::write('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OC_Log::WARN);
+			} else {
+				xcache_clear_cache(XC_TYPE_PHP, 0);
+			}
 		}
 		// Opcache (PHP >= 5.5)
 		if (function_exists('opcache_reset')) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list