From 507e48ee5605826067293deaa169e8e0d90d9f35 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 9 Aug 2013 22:13:31 +0200 Subject: don't call xcache_clear_cache on clearOpcodeCache() in case admin auth is enabled for xcache in php.ini --- lib/util.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index b7dc2207e6c..53ebe024724 100755 --- a/lib/util.php +++ b/lib/util.php @@ -869,7 +869,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 will not be cleared because "xcache.admin.enable_auth" is enabled in php.ini.', \OC_Log::WARN); + } else { + xcache_clear_cache(XC_TYPE_VAR, 0); + } } // Opcache (PHP >= 5.5) if (function_exists('opcache_reset')) { -- cgit v1.2.3 From c84171cec0669dbe459ea2b5daf573a50f20e314 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Fri, 9 Aug 2013 22:14:28 +0200 Subject: don't use xcache in case admin auth is enabled in php.ini - this can cause issues --- lib/memcache/xcache.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/memcache/xcache.php b/lib/memcache/xcache.php index 33de30562f9..7880518fd9f 100644 --- a/lib/memcache/xcache.php +++ b/lib/memcache/xcache.php @@ -10,7 +10,7 @@ namespace OC\Memcache; 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; @@ -44,11 +44,16 @@ class XCache extends Cache { static public function isAvailable(){ if (!extension_loaded('xcache')) { return false; - } elseif (\OC::$CLI) { + } + if (\OC::$CLI) { + return false; + } + // as soon as admin auth is enabled we can run into issues with admin ops like xcache_clear_cache + if (ini_get('xcache.admin.enable_auth')) { return false; - }else{ - return true; } + + return true; } } -- cgit v1.2.3 From fb2761a2034ed3ae786145418a6ca0b0262ef393 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:31:42 +0200 Subject: Do not define xcache_unset_by_prefix() if it does not exist. The defined function is not compatible with the function provided by xcache because it does not honor the prefix parameter. Thus defining it like this is a bad idea. --- lib/memcache/xcache.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/memcache/xcache.php b/lib/memcache/xcache.php index 7880518fd9f..e0acb11b054 100644 --- a/lib/memcache/xcache.php +++ b/lib/memcache/xcache.php @@ -37,7 +37,12 @@ class XCache extends Cache { } public function clear($prefix='') { - xcache_unset_by_prefix($this->getNamespace().$prefix); + if (function_exists('xcache_unset_by_prefix')) { + 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; } @@ -56,10 +61,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); - } -} -- cgit v1.2.3 From 8d762f659a24a6b133d6bd4ca1cc2030bdce5ab0 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:34:43 +0200 Subject: Allow usage of xCache variable cache if xcache_unset_by_prefix() is present. --- lib/memcache/xcache.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/memcache/xcache.php b/lib/memcache/xcache.php index e0acb11b054..91b9810cc6b 100644 --- a/lib/memcache/xcache.php +++ b/lib/memcache/xcache.php @@ -53,8 +53,10 @@ class XCache extends Cache { if (\OC::$CLI) { return false; } - // as soon as admin auth is enabled we can run into issues with admin ops like xcache_clear_cache - if (ini_get('xcache.admin.enable_auth')) { + 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; } -- cgit v1.2.3 From 799106db811c432a6eea4d15b57339e980ab8cf7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:35:52 +0200 Subject: Clear xCache OpCode cache instead of variable cache in clearOpcodeCache(). --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 53ebe024724..e9360b44f9e 100755 --- a/lib/util.php +++ b/lib/util.php @@ -872,7 +872,7 @@ class OC_Util { if (ini_get('xcache.admin.enable_auth')) { OC_Log::write('core', 'XCache will not be cleared because "xcache.admin.enable_auth" is enabled in php.ini.', \OC_Log::WARN); } else { - xcache_clear_cache(XC_TYPE_VAR, 0); + xcache_clear_cache(XC_TYPE_PHP, 0); } } // Opcache (PHP >= 5.5) -- cgit v1.2.3 From 341d9caf79531b636e6db37a18e46df8c0eadbb4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:36:42 +0200 Subject: xcache_unset_by_prefix() returns feedback, return it. --- lib/memcache/xcache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/memcache/xcache.php b/lib/memcache/xcache.php index 91b9810cc6b..115603109c9 100644 --- a/lib/memcache/xcache.php +++ b/lib/memcache/xcache.php @@ -38,7 +38,7 @@ class XCache extends Cache { public function clear($prefix='') { if (function_exists('xcache_unset_by_prefix')) { - xcache_unset_by_prefix($this->getNamespace().$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); -- cgit v1.2.3 From 49cfd08f08d6c0f0174b47f1cc69bc48b63064f3 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:37:59 +0200 Subject: Add link to XCache API in class documentation. --- lib/memcache/xcache.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/memcache/xcache.php b/lib/memcache/xcache.php index 115603109c9..7e721313c5d 100644 --- a/lib/memcache/xcache.php +++ b/lib/memcache/xcache.php @@ -8,6 +8,10 @@ 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 -- cgit v1.2.3 From 9770f52da6cb4445344c3e3641376d36a2c996a9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:40:02 +0200 Subject: xCache -> XCache --- lib/memcache/xcache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/memcache/xcache.php b/lib/memcache/xcache.php index 7e721313c5d..2dc4a3a6016 100644 --- a/lib/memcache/xcache.php +++ b/lib/memcache/xcache.php @@ -58,7 +58,7 @@ class XCache extends Cache { 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 + // 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; -- cgit v1.2.3 From 7fa53eae7fffcb517f56c96a9f2f67db5ef0d643 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:40:57 +0200 Subject: Make it clear that log message is about the XCache opcode cache. --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index e9360b44f9e..525a8d9d5d3 100755 --- a/lib/util.php +++ b/lib/util.php @@ -870,7 +870,7 @@ class OC_Util { // XCache if (function_exists('xcache_clear_cache')) { if (ini_get('xcache.admin.enable_auth')) { - OC_Log::write('core', 'XCache will not be cleared because "xcache.admin.enable_auth" is enabled in php.ini.', \OC_Log::WARN); + OC_Log::write('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled in php.ini.', \OC_Log::WARN); } else { xcache_clear_cache(XC_TYPE_PHP, 0); } -- cgit v1.2.3 From d73285c1869591da74c148b577d780a73313fe90 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 15 Aug 2013 03:41:33 +0200 Subject: Do not mention php.ini, it may be defined in xcache.ini or so. --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index 525a8d9d5d3..b9d678dced8 100755 --- a/lib/util.php +++ b/lib/util.php @@ -870,7 +870,7 @@ class OC_Util { // XCache if (function_exists('xcache_clear_cache')) { 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 in php.ini.', \OC_Log::WARN); + 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); } -- cgit v1.2.3