Skip to content

Commit

Permalink
chore: drop APCIterator as apc is long dead + require ext-apcu (#41000)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 authored Sep 28, 2023
1 parent 2b11ae7 commit 722b822
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"sabre/vobject": "^4.5",
"dg/composer-cleaner": "^2.2",
"firebase/php-jwt": "^6.8",
"ext-curl": "*"
"ext-curl": "*",
"ext-apcu": "*"
},
"extra": {
"bamarni-bin": {
Expand Down
5 changes: 3 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions lib/private/Memcache/APCu.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ public function remove($key) {
public function clear($prefix = '') {
$ns = $this->getPrefix() . $prefix;
$ns = \preg_quote($ns, '/');
if (\class_exists('\APCIterator')) {
$iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY);
} else {
$iter = new \APCuIterator('/^' . $ns . '/', APC_ITER_KEY);
}
$iter = new \APCuIterator('/^' . $ns . '/', APC_ITER_KEY);
return \apcu_delete($iter);
}

Expand Down Expand Up @@ -111,11 +107,11 @@ public function dec($key, $step = 1) {
*/
public function cas($key, $old, $new) {
// apc only does cas for ints
if (\is_int($old) and \is_int($new)) {
if (\is_int($old) && \is_int($new)) {
return \apcu_cas($this->getPrefix() . $key, $old, $new);
} else {
return $this->casEmulated($key, $old, $new);
}

return $this->casEmulated($key, $old, $new);
}

/**
Expand All @@ -124,17 +120,20 @@ public function cas($key, $old, $new) {
public static function isAvailable() {
if (!\extension_loaded('apcu')) {
return false;
} elseif (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) {
}

if (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) {
return false;
} elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) {
}

if (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) {
return false;
} elseif (
\version_compare(\phpversion('apc'), '4.0.6') === -1 &&
\version_compare(\phpversion('apcu'), '5.1.0') === -1
) {
}

if (\version_compare(\phpversion('apcu'), '5.1.0') === -1) {
return false;
} else {
return true;
}

return true;
}
}

0 comments on commit 722b822

Please sign in to comment.