diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-01 12:30:05 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-09-01 12:30:05 +0200 |
commit | 7f8c5ed4975524a8f7c65a0169cc3932c4a8dbf3 (patch) | |
tree | 741c07f476287cebc15a91af5a123fd63c34ff7e /lib/private | |
parent | 1ae4a2f9e4ed34a1f3fa6beae3cd513e2bdf51c3 (diff) | |
download | nextcloud-server-7f8c5ed4975524a8f7c65a0169cc3932c4a8dbf3.tar.gz nextcloud-server-7f8c5ed4975524a8f7c65a0169cc3932c4a8dbf3.zip |
Activate APCu on PHP 7
Fix an issue with APCus inc and dec methods on PHP 7
see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221 for details
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Memcache/APCu.php | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/private/Memcache/APCu.php b/lib/private/Memcache/APCu.php index 713ed152648..70f0d73d2d4 100644 --- a/lib/private/Memcache/APCu.php +++ b/lib/private/Memcache/APCu.php @@ -88,7 +88,21 @@ class APCu extends Cache implements IMemcache { */ public function inc($key, $step = 1) { $this->add($key, 0); - return apcu_inc($this->getPrefix() . $key, $step); + /** + * TODO - hack around a PHP 7 specific issue in APCu + * + * on PHP 7 the apcu_inc method on a non-existing object will increment + * "0" and result in "1" as value - therefore we check for existence + * first + * + * on PHP 5.6 this is not the case + * + * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221 + * for details + */ + return apcu_exists($this->getPrefix() . $key) + ? apcu_inc($this->getPrefix() . $key, $step) + : false; } /** @@ -99,7 +113,21 @@ class APCu extends Cache implements IMemcache { * @return int | bool */ public function dec($key, $step = 1) { - return apcu_dec($this->getPrefix() . $key, $step); + /** + * TODO - hack around a PHP 7 specific issue in APCu + * + * on PHP 7 the apcu_dec method on a non-existing object will decrement + * "0" and result in "-1" as value - therefore we check for existence + * first + * + * on PHP 5.6 this is not the case + * + * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221 + * for details + */ + return apcu_exists($this->getPrefix() . $key) + ? apcu_dec($this->getPrefix() . $key, $step) + : false; } /** |